Revision 29001 branches/v2_0_0_prep/libraries/libDwg/src/org/gvsig/dwg/lib/objects/DwgEllipse.java

View differences:

DwgEllipse.java
35 35
package org.gvsig.dwg.lib.objects;
36 36

  
37 37
import java.awt.geom.Point2D;
38
import java.util.ArrayList;
39 38
import java.util.List;
40 39
import java.util.Map;
41 40

  
......
44 43
import org.gvsig.dwg.lib.IDwg2FMap;
45 44
import org.gvsig.dwg.lib.IDwg3DTestable;
46 45
import org.gvsig.dwg.lib.IDwgBlockMember;
47
import org.gvsig.dwg.lib.util.FMapUtil;
48
import org.gvsig.dwg.lib.util.GisModelCurveCalculator;
49 46
import org.gvsig.fmap.geom.Geometry;
50
import org.gvsig.fmap.geom.GeometryFactory;
47
import org.gvsig.fmap.geom.GeometryLocator;
51 48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.geom.exception.CreateGeometryException;
50
import org.gvsig.fmap.geom.primitive.EllipticArc;
51
import org.gvsig.fmap.geom.primitive.Point;
52 52
import org.gvsig.fmap.geom.util.UtilFunctions;
53 53

  
54 54

  
......
157 157
	/* (non-Javadoc)
158 158
	 * @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean)
159 159
	 */
160
	public Geometry toFMapGeometry(boolean is3DFile) {
160
	public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException {
161 161

  
162
		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
162
		GeometryManager gMan = GeometryLocator.getGeometryManager();
163 163
		double[] c = getCenter();
164
		Point2D center = new Point2D.Double(c[0], c[1]);
165 164
		double[] semiMajorAxisVector = getSemiMajorAxisVector();
166
		Point2D smav = new Point2D.Double(semiMajorAxisVector[0],semiMajorAxisVector[1]);
167 165
		double axisRatio = getAxisRatio();
168 166
		double angSt = getInitAngle();
169 167
		double angEnd = getEndAngle();
170 168
		double angExt = UtilFunctions.angleDistance(angSt, angEnd);
171
		Point2D axis1Start = new Point2D.Double(center.getX()+smav.getX(), center.getY()+smav.getY());
172
		Point2D axis1End = new Point2D.Double(center.getX()-smav.getX(), center.getY()-smav.getY());
169

  
170

  
171
		//Point2D axis1Start = new Point2D.Double(center.getX()+smav.getX(), center.getY()+smav.getY());
172
		Point axis1Start = (Point)gMan.create(Geometry.TYPES.POINT,
173
				getGeometrySubType(is3DFile));
174
		double[] tmp;
175
		tmp = new double[c.length];
176
		for (int i=0;i< c.length;i++){
177
			tmp[i]=c[i]+semiMajorAxisVector[i];
178
		}
179
		axis1Start.setCoordinates(tmp);
180

  
181
		//Point2D axis1End = new Point2D.Double(center.getX()-smav.getX(), center.getY()-smav.getY());
182
		Point axis1End = (Point)gMan.create(Geometry.TYPES.POINT,
183
				getGeometrySubType(is3DFile));
184

  
185
		tmp = new double[c.length];
186
		for (int i=0;i< c.length;i++){
187
			tmp[i]=c[i]-semiMajorAxisVector[i];
188
		}
189
		axis1End.setCoordinates(tmp);
190

  
191

  
192
		Point2D smav = new Point2D.Double(semiMajorAxisVector[0],semiMajorAxisVector[1]);
173 193
		Point2D origen = new Point2D.Double(0.0,0.0);
174 194
		double semiMajorAxisLenght = origen.distance(smav);
175 195
		double semiMinorAxisLenght = semiMajorAxisLenght * axisRatio;
176 196

  
177
		if (is3DFile) {
178
			return gFactory.createEllipticArc2DZ(axis1Start, axis1End, semiMinorAxisLenght, -angSt, -angExt, c[2]);
179 197

  
180
		} else {
181
			return gFactory.createEllipticArc2D(axis1Start, axis1End, semiMinorAxisLenght, -angSt, -angExt);
182
		}
198

  
199
		EllipticArc ellipse = (EllipticArc) gMan.create(getGeometryType(),
200
				getGeometrySubType(is3DFile));
201
		ellipse.setPoints(axis1Start, axis1End, semiMinorAxisLenght, -angSt,
202
				-angExt);
203

  
204
		return ellipse;
183 205
	}
184 206

  
185 207
	/* (non-Javadoc)
186 208
	 * @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean)
187 209
	 */
188 210
	public String toFMapString(boolean is3DFile) {
189
		if(is3DFile)
211
		if(is3DFile) {
190 212
			return "EllipticArc2DZ";
191
		else
213
		} else {
192 214
			return "EllipticArc2D";
215
		}
193 216
	}
194 217

  
195 218
	public String toString(){
......
259 282

  
260 283
	}
261 284

  
285
	public int getGeometrySubType(boolean is3DFile) {
286
		if (is3DFile) {
287
			return Geometry.SUBTYPES.GEOM3D;
288
		} else {
289
			return Geometry.SUBTYPES.GEOM2D;
290
		}
291
	}
292
	public int getGeometryType() {
293
		return Geometry.TYPES.ELLIPTICARC;
294
	}
262 295
}

Also available in: Unified diff