001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.spatial.topoprim;
028:
029: import java.util.ArrayList;
030: import java.util.List;
031:
032: /**
033: * Face topologique orientée. Supporte la classe TP_Face pour les TP_Expression.
034: * Dans notre implémentation, l'identifiant d'un TP_DirectedTopo est celui de sa primitive avec le signe de l'orientation.
035: * EXPLIQUER QUE C'EST PAS PERISTANT et que A PRIORI ca n'a pas de GEOMETRIE *
036: *
037: * @author Thierry Badard, Arnaud Braun & Audrey Simon
038: * @version 1.0
039: *
040: */
041:
042: public class TP_DirectedFace extends TP_DirectedTopo {
043:
044: /////////////////////////////////////////////////////////////////////////////////////
045: // constructeur /////////////////////////////////////////////////////////////////////
046: /////////////////////////////////////////////////////////////////////////////////////
047: /** Constructeur par défaut. */
048: public TP_DirectedFace() {
049: }
050:
051: /////////////////////////////////////////////////////////////////////////////////////
052: // topo() ///////////////////////////////////////////////////////////////////////////
053: /////////////////////////////////////////////////////////////////////////////////////
054: /** Primitive de this. */
055: protected TP_Face topo;
056:
057: /** Primitive de this. */
058: public TP_Face topo() {
059: return topo;
060: }
061:
062: /////////////////////////////////////////////////////////////////////////////////////
063: // negate() /////////////////////////////////////////////////////////////////////////
064: /////////////////////////////////////////////////////////////////////////////////////
065: /** Renvoie le TP_DirectedFace d'orientation opposée. */
066: public TP_DirectedFace negate() {
067: if (orientation < 0)
068: return topo.proxy[0];
069: else
070: return topo.proxy[1];
071: }
072:
073: /////////////////////////////////////////////////////////////////////////////////////
074: // boundary() ///////////////////////////////////////////////////////////////////////
075: /////////////////////////////////////////////////////////////////////////////////////
076: /** Renvoie les TP_DirectedEdge associés au TP_DirectedFace, structurés en TP_FaceBoundary. */
077: public TP_FaceBoundary boundary() {
078: TP_FaceBoundary result = null;
079:
080: if (orientation == +1)
081: return this .topo().boundary();
082:
083: // sinon on retourne tout
084: else /*if (orientation == -1)*/{
085: TP_FaceBoundary boundary = this .topo().boundary();
086: TP_Ring ring = boundary.getExterior();
087: int n = ring.sizeTerm();
088: List theEdges = new ArrayList();
089: for (int i = 0; i < n; i++) {
090: TP_DirectedEdge edge = (TP_DirectedEdge) ring.getTerm(n
091: - i - 1);
092: edge = (TP_DirectedEdge) edge.negate();
093: theEdges.add(edge);
094: }
095: try {
096: TP_Ring ext = new TP_Ring(theEdges);
097: result = new TP_FaceBoundary(ext);
098: } catch (Exception e) {
099: e.printStackTrace();
100: }
101:
102: if (boundary.sizeInterior() > 0)
103: for (int j = 0; j < boundary.sizeInterior(); j++) {
104: ring = boundary.getInterior(j);
105: n = ring.sizeTerm();
106: theEdges = new ArrayList();
107: for (int i = 0; i < n; i++) {
108: TP_DirectedEdge edge = (TP_DirectedEdge) ring
109: .getTerm(n - i - 1);
110: edge = (TP_DirectedEdge) edge.negate();
111: theEdges.add(edge);
112: }
113: try {
114: TP_Ring inte = new TP_Ring(theEdges);
115: result.addInterior(inte);
116: } catch (Exception e) {
117: e.printStackTrace();
118: }
119: }
120: return result;
121: }
122: }
123:
124: /////////////////////////////////////////////////////////////////////////////////////
125: // coBoundary() /////////////////////////////////////////////////////////////////////
126: /////////////////////////////////////////////////////////////////////////////////////
127: /** non implémenté (renvoie null). */
128: public List coBoundary() {
129: return null;
130: }
131:
132: }
|