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: * Brin topologique (orientation positive).
034: * <P> L'operation "CoBoundary" redefinie sur TP_Object renvoie ici une liste de TP_DirectedFace, indiquant quelles faces ont self pour frontiere.
035: * Cette liste n'est pas ordonnee.
036: * <P> L'operation "Boundary" redefinie sur TP_Object renvoie le point initial du brin (TP_DirectedNode negatif) et le point final (TP_DirectedNode positif) ;
037: * Ces points sont structures en TP_EdgeBoundary.
038: *
039: * EXPLIQUER la structure de graphe
040: *
041: * @author Thierry Badard, Arnaud Braun & Audrey Simon
042: * @version 1.0
043: *
044: */
045:
046: public class TP_Edge extends TP_DirectedEdge {
047:
048: /** Les 2 primitives orientees de this. */
049: // hesitation sur le fait : proxy[0] = this ou proxy[0] = new TP_DirectedEdge(id) + proxy[0].topo = this
050: protected TP_DirectedEdge[] proxy;
051:
052: /////////////////////////////////////////////////////////////////////////////////////
053: // constructeur /////////////////////////////////////////////////////////////////////
054: /////////////////////////////////////////////////////////////////////////////////////
055: public TP_Edge() {
056: orientation = +1;
057: proxy = new TP_DirectedEdge[2];
058: proxy[0] = this ;
059: topo = this ;
060: proxy[1] = new TP_DirectedEdge();
061: proxy[1].topo = this ;
062: proxy[1].orientation = -1;
063: }
064:
065: // redefinition pour affecter un bon id au proxy negatif
066: public void setId(int Id) {
067: super .setId(Id);
068: proxy[1].setId(-Id);
069: if (Id < 0)
070: System.out
071: .println("TP_Edge::setId(id) : L'identifiant doit être positif");
072: }
073:
074: /////////////////////////////////////////////////////////////////////////////////////
075: // asTP_DirectedTopo() //////////////////////////////////////////////////////////////
076: /////////////////////////////////////////////////////////////////////////////////////
077: /** Renvoie le TP_DirectedEdge d'orientation "sign". "sign" doit valoir +1 ou -1, sinon renvoie null. */
078: public TP_DirectedEdge asTP_DirectedTopo(int sign) {
079: if (sign == +1)
080: return proxy[0];
081: else if (sign == -1)
082: return proxy[1];
083: else {
084: System.out
085: .println("TP_Edge::asTP_DirectedTopo(sign) : Passer +1 ou -1 en paramètre.");
086: return null;
087: }
088: }
089:
090: /////////////////////////////////////////////////////////////////////////////////////
091: // container ////////////////////////////////////////////////////////////////////////
092: /////////////////////////////////////////////////////////////////////////////////////
093: /** Solide dans lequel est inclus this, pour les brins isoles. */
094: public TP_Solid container;
095:
096: public TP_Solid getContainer() {
097: return container;
098: };
099:
100: public void setContainer(TP_Solid Container) {
101: container = Container;
102: }
103:
104: /////////////////////////////////////////////////////////////////////////////////////
105: // boundary /////////////////////////////////////////////////////////////////////////
106: /////////////////////////////////////////////////////////////////////////////////////
107: /** Noeud initial. */
108: public TP_Node startnode;
109:
110: public TP_Node getStartnode() {
111: return startnode;
112: }
113:
114: public void setStartnode(TP_Node StartNode) {
115: if (StartNode != null) {
116: this .startnode = StartNode;
117: this .startnodeID = StartNode.getId();
118: if (!StartNode.getSortant().contains(this ))
119: StartNode.addSortant(this );
120: } else {
121: startnode = null;
122: startnodeID = 0;
123: }
124: }
125:
126: // pour le mapping avec OJB
127: public int startnodeID;
128:
129: public int getStartnodeID() {
130: return startnodeID;
131: }
132:
133: public void setStartnodeID(int StartnodeID) {
134: startnodeID = StartnodeID;
135: }
136:
137: /** Noeud final. */
138: public TP_Node endnode;
139:
140: public TP_Node getEndnode() {
141: return endnode;
142: }
143:
144: public void setEndnode(TP_Node EndNode) {
145: if (EndNode != null) {
146: this .endnode = EndNode;
147: this .endnodeID = EndNode.getId();
148: if (!EndNode.getEntrant().contains(this ))
149: EndNode.addEntrant(this );
150: } else {
151: endnode = null;
152: endnodeID = 0;
153: }
154: }
155:
156: // pour le mapping avec OJB
157: public int endnodeID;
158:
159: public int getEndnodeID() {
160: return endnodeID;
161: }
162:
163: public void setEndnodeID(int EndnodeID) {
164: endnodeID = EndnodeID;
165: }
166:
167: /** Renvoie les TP_DirectedNode frontiere du TP_Edge, structure en TP_EdgeBoundary.
168: * Un peut lourd a utiliser, mieux d'utiliser endNode() et startNode().*/
169: public TP_EdgeBoundary boundary() {
170: return new TP_EdgeBoundary(
171: this .startnode.asTP_DirectedTopo(-1), this .endnode
172: .asTP_DirectedTopo(+1));
173: }
174:
175: /////////////////////////////////////////////////////////////////////////////////////
176: // coBoundary ///////////////////////////////////////////////////////////////////////
177: /////////////////////////////////////////////////////////////////////////////////////
178: /** Les TP_DirectedFace associes au TP_Edge. La face gauche est orientee positivement,
179: la face droite est orientee negativement. */
180: public List coBoundary() {
181: List result = new ArrayList();
182: if (leftface != null)
183: result.add(this .leftface.asTP_DirectedTopo(+1));
184: if (rightface != null)
185: result.add(this .rightface.asTP_DirectedTopo(-1));
186: return result;
187: }
188:
189: /** Face gauche. */
190: public TP_Face leftface;
191:
192: public TP_Face getLeftface() {
193: return leftface;
194: }
195:
196: public void setLeftface(TP_Face Leftface) {
197: if (Leftface.getId() == -1)
198: leftface = null;
199: else if (Leftface != null) {
200: this .leftface = Leftface;
201: this .leftfaceID = Leftface.getId();
202: if (!Leftface.getLeft().contains(this ))
203: Leftface.addLeft(this );
204: } else {
205: leftface = null;
206: leftfaceID = 0;
207: }
208: }
209:
210: // pour le mapping avec OJB
211: // on affecte -1 pour avoir une valeur par defaut non nulle
212: // il faut un objet topo avec un id = -1 (TP_Face) dans la table TP_Object;
213: // cela accelere le chargement
214: public int leftfaceID = -1;
215:
216: public int getLeftfaceID() {
217: return leftfaceID;
218: }
219:
220: public void setLeftfaceID(int LeftfaceID) {
221: leftfaceID = LeftfaceID;
222: }
223:
224: /** Face droite. */
225: public TP_Face rightface;
226:
227: public TP_Face getRightface() {
228: return rightface;
229: }
230:
231: public void setRightface(TP_Face Rightface) {
232: if (Rightface.getId() == -1)
233: rightface = null;
234: else if (Rightface != null) {
235: this .rightface = Rightface;
236: this .rightfaceID = Rightface.getId();
237: if (!Rightface.getRight().contains(this ))
238: Rightface.addRight(this );
239: } else {
240: rightface = null;
241: rightfaceID = 0;
242: }
243: }
244:
245: // pour le mapping avec OJB
246: // on affecte -1 pour avoir une valeur par defaut non nulle
247: // il faut un objet topo avec un id = -1 (TP_Face) dans la table TP_Object;
248: // cela accelere le chargement
249: public int rightfaceID = -1;
250:
251: public int getRightfaceID() {
252: return rightfaceID;
253: }
254:
255: public void setRightfaceID(int RightfaceID) {
256: rightfaceID = RightfaceID;
257: }
258:
259: }
|