|
From: <de...@us...> - 2013-01-15 00:16:15
|
Revision: 8208
http://fudaa.svn.sourceforge.net/fudaa/?rev=8208&view=rev
Author: deniger
Date: 2013-01-15 00:15:11 +0000 (Tue, 15 Jan 2013)
Log Message:
-----------
Ajout support filtre de points
Modified Paths:
--------------
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlImplementation.java
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlSceneEditor.java
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/action/CalqueCreateGridAction.java
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/AbstractCalqueCreateGridProcessor.java
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/CalqueGridSemisSynchronizeProcess.java
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/LayerGridController.java
trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlImplementation.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlImplementation.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlImplementation.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -94,8 +94,8 @@
static {
isMdl_.name = MdlResource.getS("Modeleur");
- isMdl_.version = "1.2RC4";
- isMdl_.date = "2013-01-10";
+ isMdl_.version = "1.2RC5";
+ isMdl_.date = "2013-01-14";
isMdl_.rights = MdlResource.getS("Tous droits r\xE9serv\xE9s") + ". CETMEF (c)1999-2011";
isMdl_.license = "GPL2";
isMdl_.languages = "fr,en";
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlSceneEditor.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -7,6 +7,7 @@
*/
package org.fudaa.fudaa.modeleur;
+import com.memoire.fu.FuLog;
import gnu.trove.TIntArrayList;
import java.util.ArrayList;
@@ -59,6 +60,7 @@
import com.vividsolutions.jts.geom.CoordinateSequence;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
+import org.fudaa.ebli.commun.EbliLib;
/**
* L'\xE9diteur effectuant les traitements sur la scene sp\xE9cifiques au modeleur.
@@ -343,6 +345,7 @@
if (pnDecimation_.afficheModaleOk(pn_.getFrame(), title)) {
// Les g\xE9om\xE9tries. On n'a plusieurs g\xE9om\xE9tries que dans le cas o\xF9 on n'est
// pas en mode sommet.
+ int nbRemoved=0;
int[] geoms = getScene().getSelectionHelper().getSelectedIndexes();
for (int i = 0; i < geoms.length; i++) {
int idxGeom = geoms[i];
@@ -364,10 +367,13 @@
ZModeleDonnees mdld = getScene().getLayerForId(idxGeom).modeleDonnees();
if (mdld instanceof MdlModel2dLine) {
MdlModel2dLine mdl = (MdlModel2dLine) mdld;
- mdl.decimate(getScene().sceneId2LayerId(idxGeom), idxdeb, idxfin, pnDecimation_.isNbPtsGiven() ? 0 : 1, pnDecimation_
+ nbRemoved+= mdl.decimate(getScene().sceneId2LayerId(idxGeom), idxdeb, idxfin, pnDecimation_.isNbPtsGiven() ? 0 : 1, pnDecimation_
.getNbPts(), pnDecimation_.getDistance(), cmp);
}
}
+ final String msg = EbliLib.getS("D\xE9cimation: {0} point(s) enlev\xE9(s)", Integer.toString(nbRemoved));
+ FuLog.warning("MOD:" + msg);
+ getUI().message(null, msg, true);
}
getScene().clearSelection();
@@ -397,6 +403,7 @@
// Les g\xE9om\xE9tries. On a plusieurs g\xE9om\xE9tries que dans le cas o\xF9 on n'est
// pas en mode sommet.
int[] geoms = getScene().getSelectionHelper().getSelectedIndexes();
+ int nbATotaldded = 0;
for (int i = 0; i < geoms.length; i++) {
int idxGeom = geoms[i];
Geometry geom = (Geometry) getScene().getObject(idxGeom);
@@ -417,11 +424,16 @@
ZModeleDonnees mdld = getScene().getLayerForId(idxGeom).modeleDonnees();
if (mdld instanceof MdlModel2dLine) {
MdlModel2dLine mdl = (MdlModel2dLine) mdld;
- mdl.refine(getScene().sceneId2LayerId(idxGeom), idxdeb, idxfin, pnRaffinement_.isNbPtsGiven() ? 0 : 1, pnRaffinement_
+ int nb = mdl.refine(getScene().sceneId2LayerId(idxGeom), idxdeb, idxfin, pnRaffinement_.isNbPtsGiven() ? 0 : 1, pnRaffinement_
.getNbPts(), pnRaffinement_.getDistance(), cmd);
+
+ nbATotaldded=nbATotaldded+nb;
}
}
getScene().clearSelection();
+ final String msg = EbliLib.getS("Raffinement: {0} point(s) ajout\xE9(s)", Integer.toString(nbATotaldded));
+ FuLog.warning("MOD:" + msg);
+ getUI().message(null, msg, true);
}
if (getMng() != null) {
getMng().addCmd(cmd.getSimplify());
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/action/CalqueCreateGridAction.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/action/CalqueCreateGridAction.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/action/CalqueCreateGridAction.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -6,6 +6,7 @@
import com.vividsolutions.jts.geom.LineString;
import org.fudaa.fudaa.modeleur.grid.CalqueGridSemisSynchronizeProcess;
import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.operation.valid.IsValidOp;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
@@ -72,7 +73,7 @@
@Override
public void actionPerformed(ActionEvent _e) {
- layer.getLayerGridDelegate().clearGrid();
+
stop = false;
setEnabled(false);
running = true;
@@ -84,6 +85,7 @@
boolean ok = panel.afficheModaleOk(editor.getUi().getParentComponent(), MdlResource.getS("Selectionner le calque de contour"));
final MdlLayer2dContour finalContourLayer = (MdlLayer2dContour) panel.getSelectedLayer();
if (ok) {
+ layer.getLayerGridDelegate().clearGrid();
ok = checkParameters(finalContourLayer, editor, panel);
}
if (!ok) {
@@ -124,8 +126,9 @@
GISAttributeModel model = finalContourLayer.modeleDonnees().getGeomData().getModel(GISAttributeConstants.TITRE);
for (int i = 0; i < numGeometries; i++) {
LineString line = (LineString) finalContourLayer.modeleDonnees().getGeomData().getGeometry(i);
- if (!line.isValid()) {
- nonValideLines.add((String) model.getObjectValueAt(i));
+ IsValidOp isValid = new IsValidOp(line);
+ if (!isValid.isValid()) {
+ nonValideLines.add((String) model.getObjectValueAt(i) + ". " + isValid.getValidationError().getMessage() + "; Point: " + isValid.getValidationError().getCoordinate());
}
}
if (!nonValideLines.isEmpty()) {
@@ -200,7 +203,7 @@
@Override
public void run() {
- eps=panel.getEps();
+ eps = panel.getEps();
final LinearRing finalConvexHull = panel.getSelectedConvexHull();
final MdlLayer2dContour finalContourLayer = (MdlLayer2dContour) panel.getSelectedLayer();
if (panel.isTriangleSelected()) {
@@ -222,10 +225,17 @@
model.setPointsAdapter(processor.getPointsAdapter());
model.setAltiIdxByGridPtIdx(relations.getRelations());
model.setInitPointPaintedByMesh(relations.getInitPointPaintedByMesh());
+ if (progression != null) {
+ progression.setDesc(MdlResource.getS("Affichage"));
+ progression.setProgression(0);
+ }
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
installGridLayer(model);
+ if (progression != null) {
+ progression.reset();
+ }
}
});
} else {
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/AbstractCalqueCreateGridProcessor.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/AbstractCalqueCreateGridProcessor.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/AbstractCalqueCreateGridProcessor.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -16,7 +16,6 @@
import org.fudaa.ctulu.gis.GisZoneCollectionAsListPointAdapter;
import org.fudaa.ctulu.gis.process.GisZoneCollectionPointDoublonRemover;
import org.fudaa.ctulu.gis.process.PointsMapping;
-import org.fudaa.ctulu.gis.process.PointsMappingEmpty;
import org.fudaa.dodico.ef.EfGridInterface;
import org.fudaa.dodico.ef.io.triangle.TriangulationPolyDataNodeDefault;
import org.fudaa.dodico.objet.CExecListener;
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/CalqueGridSemisSynchronizeProcess.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/CalqueGridSemisSynchronizeProcess.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/CalqueGridSemisSynchronizeProcess.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -5,14 +5,20 @@
import com.vividsolutions.jts.geom.Coordinate;
import gnu.trove.TIntArrayList;
+import gnu.trove.TIntHashSet;
import java.util.TreeMap;
+import org.fudaa.ctulu.CtuluAnalyze;
import org.fudaa.ctulu.CtuluListSelection;
import org.fudaa.ctulu.ProgressionInterface;
import org.fudaa.ctulu.ProgressionUpdater;
import org.fudaa.ctulu.gis.GisZoneCollectionAsListPointAdapter;
import org.fudaa.ctulu.gis.comparator.CoordinateComparator;
import org.fudaa.ctulu.interpolation.bilinear.InterpolationBilinearSupportSorted;
+import org.fudaa.dodico.ef.AllFrontierIteratorInterface;
+import org.fudaa.dodico.ef.EfFrontierInterface;
import org.fudaa.dodico.ef.EfGridInterface;
+import org.fudaa.dodico.ef.EfLib;
+import org.fudaa.dodico.ef.EfNeighborMesh;
import org.fudaa.fudaa.modeleur.resource.MdlResource;
/**
@@ -44,15 +50,16 @@
/**
* un tableau dont la taille est grid.nbPoint.Pour chaque point du maillage donne l'indice du noeud dans le mod\xE8les multipoint.
- * @return
+ *
+ * @return
*/
public int[][] getRelations() {
return relations;
}
/**
- *
- * @return les points de la zone support\xE9 par un unique point du maillage.
+ *
+ * @return les points de la zone support\xE9 par un unique point du maillage.
*/
public CtuluListSelection getInitPointPaintedByMesh() {
return initPointPaintedByMesh;
@@ -97,7 +104,7 @@
}
updater.setValue(10, grid.getPtsNb());
boolean rescanElt = false;
-
+ int nbToRescan = 0;
for (int i = 0; i < grid.getPtsNb(); i++) {
Coordinate gridCoor = new Coordinate(grid.getPtX(i), grid.getPtY(i));
TIntArrayList idxs = index.get(gridCoor);
@@ -108,17 +115,72 @@
//le premier point de la collection est pris.
res[i] = new int[]{idxs.get(0)};
} else {
+ nbToRescan++;
rescanElt = true;
}
updater.majAvancement();
}
if (rescanElt) {
+ //pour les points, on recherche les points adjacents avec des valeurs connus
+ final int[][] ptVoisins = EfLib.getConnexionFor(grid, prog, new CtuluAnalyze());
+ for (int globalIdx = 0; globalIdx < grid.getPtsNb(); globalIdx++) {
+ if (res[globalIdx] == null) {
+ int[] voisins = ptVoisins[globalIdx];
+ TIntArrayList knownVoisin = null;
+ for (int i = 0; i < voisins.length; i++) {
+ int idxVoisin = voisins[i];
+ if (res[idxVoisin] != null && res[idxVoisin].length == 1) {
+ if (knownVoisin == null) {
+ knownVoisin = new TIntArrayList();
+ }
+ knownVoisin.add(res[idxVoisin][0]);
+ }
+ }
+ if (knownVoisin != null) {
+ if (knownVoisin.size() == 1) {//pour \xE9viter que le point soit consid\xE9r\xE9 comme un point exact.
+ knownVoisin.add(-1);
+ }
+ res[globalIdx] = knownVoisin.toNativeArray();
+ nbToRescan--;
+ }
+ }
+ }
+ //pour les points fronti\xE8res isol\xE9s, on recommence \xE0 chercher les points \xE0 utiliser.
+ AllFrontierIteratorInterface allFrontierIterator = grid.getFrontiers().getAllFrontierIterator();
+ while (allFrontierIterator.hasNext()) {
+ int globalIdx = allFrontierIterator.next();
+ if (res[globalIdx] == null) {
+ int[] voisins = ptVoisins[globalIdx];
+ TIntHashSet knownVoisin = null;
+ for (int i = 0; i < voisins.length; i++) {
+ int idxVoisin = voisins[i];
+ if (res[idxVoisin] != null) {
+ if (knownVoisin == null) {
+ knownVoisin = new TIntHashSet();
+ }
+ knownVoisin.addAll(res[idxVoisin]);
+ }
+ }
+ if (knownVoisin != null) {
+ if (knownVoisin.size() == 1) {//pour \xE9viter que le point soit consid\xE9r\xE9 comme un point exact.
+ knownVoisin.add(-1);
+ }
+ res[globalIdx] = knownVoisin.toArray();
+ nbToRescan--;
+ }
+ }
+ }
+ }
+ updater.setValue(10, nbToRescan);
+
+ if (rescanElt && nbToRescan > 0) {
+ updater.majProgessionStateOnly(MdlResource.getS("Synchronisation des points hors semis"));
final InterpolationBilinearSupportSorted src = InterpolationBilinearSupportSorted.buildSortedSrc(zone, prog);
for (int i = 0; i < grid.getPtsNb(); i++) {
if (res[i] == null) {
-
res[i] = new int[4];
src.getQuadrantIdx(grid.getPtX(i), grid.getPtY(i), res[i]);
+ updater.majAvancement();
}
}
}
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/LayerGridController.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/LayerGridController.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/grid/LayerGridController.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -32,22 +32,22 @@
* @author Frederic Deniger
*/
public class LayerGridController implements ZModelGeometryListener {
-
+
private final MdlCalqueMultiPointEditable parentLayer;
private MdlElementModel elementModel;
private MdlIsoModelDefault isoModel;
private MdlGridData gridData;
private MvIsoLayerQuickPainter painter;
-
+
public LayerGridController(MdlCalqueMultiPointEditable parentLayer) {
this.parentLayer = parentLayer;
parentLayer.modeleDonnees().addModelListener(this);
}
-
+
public CtuluUI getUI() {
return ((FSigEditor) parentLayer.getEditor()).getUi();
}
-
+
@Override
public void geometryAction(Object _source, int _indexGeom, Geometry _geom, int _action) {
if (elementModel != null) {
@@ -87,38 +87,39 @@
painter.setIsAntaliasing(parentLayer.isAntialiasing());
painter.setAlpha(parentLayer.getAlpha());
painter.setLigneModel(parentLayer.getLineModel(0));
+ painter.setRapide(parentLayer.isRapide());
painter.paintDonnees(width, height, _g, _versEcran, _versReel, _clipReel);
-
+
}
-
+
@Override
public void attributeAction(Object _source, int _indexAtt, GISAttributeInterface _att, int _action) {
}
-
+
@Override
public void attributeValueChangeAction(Object _source, int _indexAtt, GISAttributeInterface _att, int _indexGeom, Object _newValue) {
}
-
+
public MdlElementLayer getGridLayer() {
return (MdlElementLayer) parentLayer.getCalqueParNom("cqGrid");
}
/**
- *
- * @return true si un maillage est pr\xE9sent.
+ *
+ * @return true si un maillage est pr\xE9sent.
*/
public boolean isGridCreated() {
return elementModel != null;
}
-
+
public ZCalqueMultiPointEditable getParentLayer() {
return parentLayer;
}
-
+
public MdlGridData getExportGridData() {
return gridData;
}
-
+
public void clearGrid() {
elementModel = null;
gridData = null;
@@ -129,7 +130,7 @@
parentLayer.clearCacheAndRepaint();
}
}
-
+
public void setGridLayer(MdlElementModel grid) {
this.elementModel = grid;
gridData = null;
@@ -146,14 +147,15 @@
((FSigEditor) parentLayer.getEditor()).getPanel().getVueCalque().repaint(0);
((FSigEditor) parentLayer.getEditor()).getPanel().getVueCalque().revalidate();
}
-
+
public void installGridLayer(MdlElementLayer eltLayer, MdlElementModel grid) {
if (eltLayer == null) {
eltLayer = new MdlElementLayer();
eltLayer.setTitle(MdlResource.getS("Maillage"));
eltLayer.setName("cqGrid");
eltLayer.setLineModel(0, new TraceLigneModel(TraceLigne.LISSE, 1f, Color.LIGHT_GRAY));
- eltLayer.setAlpha(128);
+// eltLayer.setAlpha(128);
+ eltLayer.setVisible(false);
parentLayer.add(eltLayer);
}
final int attributeZ = LibUtils.getAttributeZPosition(parentLayer.modeleDonnees().getGeomData());
@@ -168,7 +170,7 @@
eltLayer.setModele(grid);
eltLayer.repaint();
}
-
+
public void setEltPainted(int[] selectedElementIdx, boolean b) {
getGridLayer().modele().setPainted(selectedElementIdx, b);
getGridLayer().clearCacheAndRepaint();
Modified: trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java
===================================================================
--- trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2013-01-15 00:13:48 UTC (rev 8207)
+++ trunk/soft/fudaa-modeleur/src/main/java/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2013-01-15 00:15:11 UTC (rev 8208)
@@ -32,7 +32,7 @@
/**
* Un mod\xE8le de calque pour un calque 2D contenant des lignes.
- *
+ *
* @author Bertrand Marchand
* @version $Id$
*/
@@ -42,11 +42,12 @@
* Construction d'un modele de profil avec pile de commandes.
*/
public MdlModel2dLine(final ZModelGeometryListener _listener) {
- this(_listener,new GISZoneCollectionLigneBrisee(null));
+ this(_listener, new GISZoneCollectionLigneBrisee(null));
}
-
+
/**
* Construction d'un modele de profil avec pile de commandes.
+ *
* @param _listener Un listener du modele.
* @param _zone La zone utilis\xE9e par le mod\xE8le.
*/
@@ -58,55 +59,57 @@
/**
* Interpole entre 2 points, suivant un nombre de points donn\xE9s.
+ *
* @param _coords Les 2 coordonn\xE9es
* @param _dist La distance entre 2 points cons\xE9cutifs.
* @param _useBorderPoints vrai si la ligne int\xE9pol\xE9e doit contenir les coordonn\xE9es fournies.
* @param _cmd Le container de commandes.
* @return true si modif ok.
*/
- public boolean interpolate(Coordinate[] _coords, double _dist, boolean _useBorderPoints, final CtuluCommandContainer _cmd){
- double distTot=
- Math.sqrt((_coords[1].x-_coords[0].x)*(_coords[1].x-_coords[0].x)+(_coords[1].y-_coords[0].y)*(_coords[1].y-_coords[0].y));
- int nbpts=(int)Math.round(distTot/_dist)-1;
+ public boolean interpolate(Coordinate[] _coords, double _dist, boolean _useBorderPoints, final CtuluCommandContainer _cmd) {
+ double distTot =
+ Math.sqrt((_coords[1].x - _coords[0].x) * (_coords[1].x - _coords[0].x) + (_coords[1].y - _coords[0].y) * (_coords[1].y - _coords[0].y));
+ int nbpts = (int) Math.round(distTot / _dist) - 1;
Coordinate[] coords;
if (_useBorderPoints) {
- coords=new Coordinate[_coords.length+nbpts];
- for (int i=1; i<coords.length-1; i++)
- coords[i]=new Coordinate(
- _coords[0].x+(_coords[1].x-_coords[0].x)*i*_dist/distTot,
- _coords[0].y+(_coords[1].y-_coords[0].y)*i*_dist/distTot,
- _coords[0].z+(_coords[1].z-_coords[0].z)*i*_dist/distTot
- );
- coords[0]=(Coordinate)_coords[0].clone();
- coords[coords.length-1]=(Coordinate)_coords[1].clone();
+ coords = new Coordinate[_coords.length + nbpts];
+ for (int i = 1; i < coords.length - 1; i++) {
+ coords[i] = new Coordinate(
+ _coords[0].x + (_coords[1].x - _coords[0].x) * i * _dist / distTot,
+ _coords[0].y + (_coords[1].y - _coords[0].y) * i * _dist / distTot,
+ _coords[0].z + (_coords[1].z - _coords[0].z) * i * _dist / distTot);
+ }
+ coords[0] = (Coordinate) _coords[0].clone();
+ coords[coords.length - 1] = (Coordinate) _coords[1].clone();
+ } else {
+ coords = new Coordinate[nbpts];
+ for (int i = 0; i < coords.length; i++) {
+ coords[i] = new Coordinate(
+ _coords[0].x + (_coords[1].x - _coords[0].x) * (i + 1) * _dist / distTot,
+ _coords[0].y + (_coords[1].y - _coords[0].y) * (i + 1) * _dist / distTot,
+ _coords[0].z + (_coords[1].z - _coords[0].z) * (i + 1) * _dist / distTot);
+ }
}
- else {
- coords=new Coordinate[nbpts];
- for (int i=0; i<coords.length; i++)
- coords[i]=new Coordinate(
- _coords[0].x+(_coords[1].x-_coords[0].x)*(i+1)*_dist/distTot,
- _coords[0].y+(_coords[1].y-_coords[0].y)*(i+1)*_dist/distTot,
- _coords[0].z+(_coords[1].z-_coords[0].z)*(i+1)*_dist/distTot
- );
- }
- if (coords.length>=2) {
- GISPolyligne poly=(GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(coords);
- CtuluCommandComposite cmd=new CtuluCommandComposite();
- int idx=getGeomData().addGeometry(poly, null, cmd);
- if (idx!=-1)
+ if (coords.length >= 2) {
+ GISPolyligne poly = (GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(coords);
+ CtuluCommandComposite cmd = new CtuluCommandComposite();
+ int idx = getGeomData().addGeometry(poly, null, cmd);
+ if (idx != -1) {
setGeomModif(idx, cmd);
- if(_cmd!=null)
+ }
+ if (_cmd != null) {
_cmd.addCmd(cmd.getSimplify());
+ }
return true;
+ } else {
+ return false;
}
- else
- return false;
}
-
+
/**
- * Decime une ligne. La m\xE9thode utilis\xE9e pour d\xE9cimer peut \xEAtre :<p>
- * 0 : Suivant un nombre de points a supprimer entre 2 points conserv\xE9s.<br>
- * 1 : Suivant une distance minimale.
+ * Decime une ligne. La m\xE9thode utilis\xE9e pour d\xE9cimer peut \xEAtre :<p> 0 : Suivant un nombre de points a supprimer entre 2 points conserv\xE9s.<br> 1 :
+ * Suivant une distance minimale.
+ *
* @param _idxGeom La g\xE9om\xE9trie a d\xE9cimer.
* @param _idxdeb L'indice de d\xE9but de d\xE9cimation.
* @param _idxfin L'indice de fin de d\xE9cimation.
@@ -114,53 +117,51 @@
* @param _nbpts Le nombre de points.
* @param _dstmin La distance minimale.
* @param _cmd Le container de commandes.
- * @return true si modif ok.
+ * @return le nombre de points enlev\xE9
*/
- public boolean decimate(int _idxGeom, int _idxdeb,int _idxfin,int _meth,int _nbpts, double _dstmin, CtuluCommandContainer _cmd) {
- TIntArrayList list=new TIntArrayList();
-
+ public int decimate(int _idxGeom, int _idxdeb, int _idxfin, int _meth, int _nbpts, double _dstmin, CtuluCommandContainer _cmd) {
+ TIntArrayList list = new TIntArrayList();
+
// Methode par nombre de points.
- if (_meth==0) {
- int idx=_idxdeb+1+_nbpts;
- for (int i=_idxdeb+1; i<=_idxfin-1; i++) {
- if (i<idx) {
+ if (_meth == 0) {
+ int idx = _idxdeb + 1 + _nbpts;
+ for (int i = _idxdeb + 1; i <= _idxfin - 1; i++) {
+ if (i < idx) {
list.add(i);
+ } else {
+ idx = i + 1 + _nbpts;
}
- else {
- idx=i+1+_nbpts;
- }
}
- }
- // Methode par distance mini.
- else if (_meth==1) {
- LineString geom=(LineString)getGeomData().getGeometry(_idxGeom);
- CoordinateSequence seq=geom.getCoordinateSequence();
- double dst=0;
- for (int i=_idxdeb+1; i<=_idxfin-1; i++) {
- dst+=Math.sqrt((seq.getX(i)-seq.getX(i-1))*(seq.getX(i)-seq.getX(i-1))+
- (seq.getY(i)-seq.getY(i-1))*(seq.getY(i)-seq.getY(i-1)));
- if (dst<_dstmin) {
+ } // Methode par distance mini.
+ else if (_meth == 1) {
+ LineString geom = (LineString) getGeomData().getGeometry(_idxGeom);
+ CoordinateSequence seq = geom.getCoordinateSequence();
+ double dst = 0;
+ for (int i = _idxdeb + 1; i <= _idxfin - 1; i++) {
+ dst += Math.sqrt((seq.getX(i) - seq.getX(i - 1)) * (seq.getX(i) - seq.getX(i - 1))
+ + (seq.getY(i) - seq.getY(i - 1)) * (seq.getY(i) - seq.getY(i - 1)));
+ if (dst < _dstmin) {
list.add(i);
+ } else {
+ dst = 0;
}
- else {
- dst=0;
- }
}
}
-
+
CtuluListSelectionInterface ids = new CtuluListSelection(list.toNativeArray());
- CtuluCommandComposite cmd=new CtuluCommandComposite();
+ CtuluCommandComposite cmd = new CtuluCommandComposite();
getGeomData().removeAtomics(_idxGeom, ids, null, cmd); // L'UI est null, le cas ou moins de 2 points ne peut pas arriver.
setGeomModif(_idxGeom, cmd); // Modification de l'etat de la g\xE9om\xE9trie
- if(_cmd!=null)
+ if (_cmd != null) {
_cmd.addCmd(cmd.getSimplify());
- return true;
+ }
+ return ids.getNbSelectedIndex();
}
-
+
/**
- * Raffine une ligne. La m\xE9thode utilis\xE9e pour raffiner peut \xEAtre :<p>
- * 0 : Suivant un nombre de points a ajouter entre 2 points.<br>
- * 1 : Suivant une distance maximale.
+ * Raffine une ligne. La m\xE9thode utilis\xE9e pour raffiner peut \xEAtre :<p> 0 : Suivant un nombre de points a ajouter entre 2 points.<br> 1 : Suivant une
+ * distance maximale.
+ *
* @param _idxGeom La g\xE9om\xE9trie a raffiner.
* @param _idxdeb L'indice de d\xE9but de raffinement.
* @param _idxfin L'indice de fin de raffinement.
@@ -168,71 +169,85 @@
* @param _nbpts Le nombre de points.
* @param _dstmax La distance maximale.
* @param _cmd Le container de commandes.
- * @return true si modif ok.
+ * @return le nombre de points ajout\xE9s
*/
- public boolean refine(int _idxGeom, int _idxdeb,int _idxfin,int _meth,int _nbpts, double _dstmax, CtuluCommandContainer _cmd) {
- LineString geom=(LineString)getGeomData().getGeometry(_idxGeom);
- CoordinateSequence seq=GISLib.refine(geom.getCoordinateSequence(), _idxdeb, _idxfin, _meth, _nbpts, _dstmax);
-
- GISPolyligne newgeom=(GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(seq);
- CtuluCommandComposite cmd=new CtuluCommandComposite();
+ public int refine(int _idxGeom, int _idxdeb, int _idxfin, int _meth, int _nbpts, double _dstmax, CtuluCommandContainer _cmd) {
+ LineString geom = (LineString) getGeomData().getGeometry(_idxGeom);
+ CoordinateSequence seq = GISLib.refine(geom.getCoordinateSequence(), _idxdeb, _idxfin, _meth, _nbpts, _dstmax);
+
+ GISPolyligne newgeom = (GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(seq);
+ CtuluCommandComposite cmd = new CtuluCommandComposite();
getGeomData().setGeometry(_idxGeom, newgeom, cmd);
setGeomModif(_idxGeom, cmd); // Modification de l'etat de la g\xE9om\xE9trie
- if(_cmd!=null)
+ if (_cmd != null) {
_cmd.addCmd(cmd.getSimplify());
- return true;
+ }
+ return seq.size() - geom.getNumPoints();
}
-
+
/**
- * Sort the points of selected polylignes. This sorting is done on the _icoord.
+ * Sort the points of selected polylignes. This sorting is done on the _icoord.
+ *
* @param _icoord 0: x, 1: y.
*/
public void organizePoints(int _idxGeom, int _icoord, CtuluCommandContainer _cmd) {
- /** This class contain needed data to sort points. */
- class SortableIndex implements Comparable<SortableIndex>{
+ /**
+ * This class contain needed data to sort points.
+ */
+ class SortableIndex implements Comparable<SortableIndex> {
+
public double coord;
private int ind;
+
public SortableIndex(double _coord, int _ind) {
- ind=_ind;
- coord=_coord;
+ ind = _ind;
+ coord = _coord;
}
public int compareTo(SortableIndex o) {
- if (coord<o.coord) return -1;
- else if (coord==o.coord) return 0;
- else return 1;
+ if (coord < o.coord) {
+ return -1;
+ } else if (coord == o.coord) {
+ return 0;
+ } else {
+ return 1;
+ }
}
}
- CtuluCommandComposite cmp=new CtuluCommandComposite(MdlResource.getS("R\xE9organisation de la g\xE9om\xE9trie"));
+ CtuluCommandComposite cmp = new CtuluCommandComposite(MdlResource.getS("R\xE9organisation de la g\xE9om\xE9trie"));
- GISZoneCollection zone=getGeomData();
- CoordinateSequence oldseq=zone.getCoordinateSequence(_idxGeom);
+ GISZoneCollection zone = getGeomData();
+ CoordinateSequence oldseq = zone.getCoordinateSequence(_idxGeom);
// Construction de la structure de tri
- SortableIndex[] points=new SortableIndex[oldseq.size()];
- for(int j=0;j<points.length;j++)
- points[j]=new SortableIndex(oldseq.getOrdinate(j,_icoord), j);
+ SortableIndex[] points = new SortableIndex[oldseq.size()];
+ for (int j = 0; j < points.length; j++) {
+ points[j] = new SortableIndex(oldseq.getOrdinate(j, _icoord), j);
+ }
Arrays.sort(points);
-
+
// Remplacement de la g\xE9om\xE9trie r\xE9ordonn\xE9e.
- Coordinate[] coords=new Coordinate[points.length];
- for(int j=0;j<points.length;j++)
- coords[j]=oldseq.getCoordinateCopy(points[j].ind);
+ Coordinate[] coords = new Coordinate[points.length];
+ for (int j = 0; j < points.length; j++) {
+ coords[j] = oldseq.getCoordinateCopy(points[j].ind);
+ }
zone.setCoordinateSequence(_idxGeom, new GISCoordinateSequenceFactory().create(coords), cmp);
-
+
// R\xE9ordonnancement des attributs atomiques.
- for(int iatt=0;iatt<zone.getNbAttributes();iatt++)
- if(zone.getAttribute(iatt).isAtomicValue()){
- GISAttributeModel oldvalues=(GISAttributeModel) zone.getDataModel(iatt).getObjectValueAt(_idxGeom);
- GISAttributeModel newvalues=(GISAttributeModel)zone.getDataModel(iatt).getAttribute().createDataForGeom(oldvalues, oldvalues.getSize());
- for(int j=0;j<oldvalues.getSize();j++){
- newvalues.setObject(j,oldvalues.getObjectValueAt(points[j].ind), null);
+ for (int iatt = 0; iatt < zone.getNbAttributes(); iatt++) {
+ if (zone.getAttribute(iatt).isAtomicValue()) {
+ GISAttributeModel oldvalues = (GISAttributeModel) zone.getDataModel(iatt).getObjectValueAt(_idxGeom);
+ GISAttributeModel newvalues = (GISAttributeModel) zone.getDataModel(iatt).getAttribute().createDataForGeom(oldvalues, oldvalues.getSize());
+ for (int j = 0; j < oldvalues.getSize(); j++) {
+ newvalues.setObject(j, oldvalues.getObjectValueAt(points[j].ind), null);
}
- zone.setAttributValue(iatt, _idxGeom,newvalues,cmp);
+ zone.setAttributValue(iatt, _idxGeom, newvalues, cmp);
}
-
- if(_cmd!=null)
+ }
+
+ if (_cmd != null) {
_cmd.addCmd(cmp.getSimplify());
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|