01: /*
02: * This file is part of the GeOxygene project source files.
03: *
04: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
05: * the development and deployment of geographic (GIS) applications. It is a open source
06: * contribution of the COGIT laboratory at the Institut Géographique National (the French
07: * National Mapping Agency).
08: *
09: * See: http://oxygene-project.sourceforge.net
10: *
11: * Copyright (C) 2005 Institut Géographique National
12: *
13: * This library is free software; you can redistribute it and/or modify it under the terms
14: * of the GNU Lesser General Public License as published by the Free Software Foundation;
15: * either version 2.1 of the License, or any later version.
16: *
17: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
20: *
21: * You should have received a copy of the GNU Lesser General Public License along with
22: * this library (see file LICENSE if present); if not, write to the Free Software
23: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24: *
25: */
26:
27: package fr.ign.cogit.geoxygene.spatial.geomprim;
28:
29: import fr.ign.cogit.geoxygene.spatial.coordgeom.DirectPositionList;
30:
31: /**
32: * Courbe orientée. L'orientation traduit le sens de paramétrisation.
33: * Utilisée comme frontière d'une surface, la surface dont la courbe est frontière est à gauche de la courbe.
34: * Si l'orientation est +1, alors self est une GM_Curve, de primitive elle-même.
35: * Si l'orientation est -1, alors self est une GM_OrientableCurve, de primitive une GM_Curve renversée par rapport à la courbe positive.
36: *
37: * <P> Utilisation : on ne construit pas une GM_OrientableCurve directement,
38: * mais a partir d'une GM_Curve en utilisant getPositive() et getNegative().
39: *
40: * @author Thierry Badard & Arnaud Braun
41: * @version 1.0
42: *
43: */
44:
45: public class GM_OrientableCurve extends GM_OrientablePrimitive {
46:
47: /** Primitive */
48: public GM_Curve primitive;
49:
50: /** Renvoie la primitive de self */
51: public GM_Curve getPrimitive() {
52: return this .primitive;
53: }
54:
55: /** Attribut stockant les primitives orientées de cette primitive.
56: * Proxy[0] est celle orientée positivement.
57: * Proxy[1] est celle orientée négativement.
58: * On accède aux primitives orientées par getPositive() et getNegative(). */
59: public GM_OrientableCurve[] proxy = new GM_OrientableCurve[2];
60:
61: /** Renvoie la primitive orientée positivement correspondant à self. */
62: public GM_OrientableCurve getPositive() {
63: return proxy[0];
64: }
65:
66: /** Renvoie la primitive orientée négativement correspondant à self. */
67: // on recalcule en dynamique la primitive de la primitive orientee negativement, qui est "renversee"
68: // par rapport a la primitive orientee positivement.
69: public GM_OrientableCurve getNegative() {
70: GM_Curve proxy1prim = (GM_Curve) proxy[1].primitive;
71: proxy1prim.getSegment().clear();
72: GM_Curve proxy0 = (GM_Curve) proxy[1].proxy[0];
73: int n = proxy0.sizeSegment();
74: if (n > 1)
75: for (int i = 0; i < n; i++)
76: proxy1prim.addSegment(proxy0.getSegment(n - 1 - i)
77: .reverse());
78: else if (n == 1) // Braun - 14/06/02 : modif ajoutee suite a l'heritage de GM_CurveSegment sur GM_Curve
79: proxy1prim.segment.add(proxy0.getSegment(0).reverse());
80: return proxy[1];
81: }
82:
83: /** Redéfinition de l'opérateur "boundary" sur GM_Object. Renvoie une GM_CurveBoundary, c'est-à-dire deux GM_Point. */
84: public GM_CurveBoundary boundary() {
85: GM_Curve prim = (GM_Curve) this .getPrimitive();
86: GM_CurveBoundary bdy = new GM_CurveBoundary(prim);
87: return bdy;
88: }
89:
90: /** Renvoie les coordonnees de la primitive. */
91: public DirectPositionList coord() {
92: return getPrimitive().coord();
93: }
94:
95: }
|