Commit 8cb3920b authored by gsavin's avatar gsavin

Prepare greedy forces

parent 45b2834c
/*
* Copyright 2006 - 2011
* Julien Baudry <julien.baudry@graphstream-project.org>
* Copyright 2006 - 2012
* Antoine Dutot <antoine.dutot@graphstream-project.org>
* Yoann Pigné <yoann.pigne@graphstream-project.org>
* Guilhelm Savin <guilhelm.savin@graphstream-project.org>
*
* This file is part of GraphStream <http://graphstream-project.org>.
* This file is part of gs-boids <http://graphstream-project.org>.
*
* GraphStream is a library whose purpose is to handle static or dynamic
* graph, create them from scratch, file or any source and display them.
* gs-boids is a library whose purpose is to provide a boid behavior to a set of
* particles.
*
* This program is free software distributed under the terms of two licenses, the
* CeCILL-C license that fits European law, and the GNU Lesser General Public
......@@ -30,11 +28,35 @@
*/
package org.graphstream.boids;
public interface BoidsForcesFactory {
/**
* Object used to create and compute forces of boids.
*
*/
public interface BoidForcesFactory {
/**
* Create a new forces object for a boid.
*
* @param b
* the boid
* @return a new forces object associate with the boid
*/
BoidForces createNewForces(Boid b);
/**
* Compute forces for all boids.
*/
void step();
/**
* Resize the space.
*
* @param minx
* @param miny
* @param minz
* @param maxx
* @param maxy
* @param maxz
*/
void resize(double minx, double miny, double minz, double maxx,
double maxy, double maxz);
}
......@@ -117,7 +117,7 @@ public class BoidGraph extends AdjacencyListGraph {
*/
protected Random random;
protected BoidsForcesFactory forcesFactory;
protected BoidForcesFactory forcesFactory;
/**
* New context.
......
/*
* Copyright 2006 - 2012
* Antoine Dutot <antoine.dutot@graphstream-project.org>
* Guilhelm Savin <guilhelm.savin@graphstream-project.org>
*
* This file is part of gs-boids <http://graphstream-project.org>.
*
* gs-boids is a library whose purpose is to provide a boid behavior to a set of
* particles.
*
* This program is free software distributed under the terms of two licenses, the
* CeCILL-C license that fits European law, and the GNU Lesser General Public
* License. You can use, modify and/ or redistribute the software under the terms
* of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
* URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
*/
package org.graphstream.boids.forces.greedy;
import org.graphstream.boids.Boid;
import org.graphstream.boids.BoidForces;
import org.miv.pherd.geom.Point3;
public class GreedyForces extends BoidForces {
public void compute() {
// TODO Auto-generated method stub
}
public Point3 getPosition() {
// TODO Auto-generated method stub
return null;
}
public boolean isVisible(Boid boid, Point3 other) {
// TODO Auto-generated method stub
return false;
}
public void setPosition(double x, double y, double z) {
// TODO Auto-generated method stub
}
}
/*
* Copyright 2006 - 2012
* Antoine Dutot <antoine.dutot@graphstream-project.org>
* Guilhelm Savin <guilhelm.savin@graphstream-project.org>
*
* This file is part of gs-boids <http://graphstream-project.org>.
*
* gs-boids is a library whose purpose is to provide a boid behavior to a set of
* particles.
*
* This program is free software distributed under the terms of two licenses, the
* CeCILL-C license that fits European law, and the GNU Lesser General Public
* License. You can use, modify and/ or redistribute the software under the terms
* of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
* URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
*/
package org.graphstream.boids.forces.greedy;
import org.graphstream.boids.Boid;
import org.graphstream.boids.BoidForces;
import org.graphstream.boids.BoidForcesFactory;
public class GreedyForcesFactory implements BoidForcesFactory {
public BoidForces createNewForces(Boid b) {
// TODO Auto-generated method stub
return null;
}
public void resize(double minx, double miny, double minz, double maxx,
double maxy, double maxz) {
// TODO Auto-generated method stub
}
public void step() {
// TODO Auto-generated method stub
}
}
/*
* Copyright 2006 - 2012
* Antoine Dutot <antoine.dutot@graphstream-project.org>
* Guilhelm Savin <guilhelm.savin@graphstream-project.org>
*
* This file is part of gs-boids <http://graphstream-project.org>.
*
* gs-boids is a library whose purpose is to provide a boid behavior to a set of
* particles.
*
* This program is free software distributed under the terms of two licenses, the
* CeCILL-C license that fits European law, and the GNU Lesser General Public
* License. You can use, modify and/ or redistribute the software under the terms
* of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
* URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
*/
package org.graphstream.boids.forces.ntree;
import java.util.HashSet;
......@@ -33,14 +61,29 @@ public class NTreeForces extends BoidForces {
this.p = p;
}
/*
* (non-Javadoc)
*
* @see org.graphstream.boids.BoidForces#getPosition()
*/
public Point3 getPosition() {
return p.getPosition();
}
/*
* (non-Javadoc)
*
* @see org.graphstream.boids.BoidForces#setPosition(double, double, double)
*/
public void setPosition(double x, double y, double z) {
p.setPosition(x, y, z);
}
/*
* (non-Javadoc)
*
* @see org.graphstream.boids.BoidForces#compute()
*/
public void compute() {
Cell startCell = p.getCell().getTree().getRootCell();
......
/*
* Copyright 2006 - 2011
* Julien Baudry <julien.baudry@graphstream-project.org>
* Copyright 2006 - 2012
* Antoine Dutot <antoine.dutot@graphstream-project.org>
* Yoann Pigné <yoann.pigne@graphstream-project.org>
* Guilhelm Savin <guilhelm.savin@graphstream-project.org>
*
* This file is part of GraphStream <http://graphstream-project.org>.
* This file is part of gs-boids <http://graphstream-project.org>.
*
* GraphStream is a library whose purpose is to handle static or dynamic
* graph, create them from scratch, file or any source and display them.
* gs-boids is a library whose purpose is to provide a boid behavior to a set of
* particles.
*
* This program is free software distributed under the terms of two licenses, the
* CeCILL-C license that fits European law, and the GNU Lesser General Public
......@@ -34,7 +32,7 @@ import org.graphstream.boids.Boid;
import org.graphstream.boids.BoidForces;
import org.graphstream.boids.BoidGraph;
import org.graphstream.boids.BoidSpecies;
import org.graphstream.boids.BoidsForcesFactory;
import org.graphstream.boids.BoidForcesFactory;
import org.graphstream.stream.ElementSink;
import org.miv.pherd.Particle;
import org.miv.pherd.ParticleBox;
......@@ -43,7 +41,7 @@ import org.miv.pherd.ntree.Anchor;
import org.miv.pherd.ntree.CellSpace;
import org.miv.pherd.ntree.OctreeCellSpace;
public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
public class NTreeForcesFactory implements BoidForcesFactory, ElementSink {
protected CellSpace space;
/**
......@@ -62,21 +60,39 @@ public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
this.pbox = new ParticleBox(maxParticlesPerCell, space,
new BoidCellData());
this.ctx = ctx;
ctx.addElementSink(this);
}
/*
* (non-Javadoc)
*
* @see
* org.graphstream.boids.BoidForcesFactory#createNewForces(org.graphstream
* .boids.Boid)
*/
public BoidForces createNewForces(Boid b) {
BoidParticle p = new BoidParticle(b);
NTreeForces f = new NTreeForces(p);
return f;
}
/*
* (non-Javadoc)
*
* @see org.graphstream.boids.BoidForcesFactory#step()
*/
public void step() {
pbox.step();
}
/*
* (non-Javadoc)
*
* @see org.graphstream.boids.BoidForcesFactory#resize(double, double,
* double, double, double, double)
*/
public void resize(double minx, double miny, double minz, double maxx,
double maxy, double maxz) {
Anchor lo = new Anchor(minx, miny, minz);
......@@ -126,6 +142,11 @@ public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
.getRandom().nextDouble(), 0);
}
/*
* (non-Javadoc)
*
* @see org.miv.pherd.Particle#move(int)
*/
@Override
public void move(int time) {
BoidSpecies species = b.getSpecies();
......@@ -163,10 +184,20 @@ public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
moved = true;
}
/*
* (non-Javadoc)
*
* @see org.miv.pherd.Particle#inserted()
*/
@Override
public void inserted() {
}
/*
* (non-Javadoc)
*
* @see org.miv.pherd.Particle#removed()
*/
@Override
public void removed() {
}
......@@ -222,14 +253,18 @@ public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
/*
* (non-Javadoc)
* @see org.graphstream.stream.ElementSink#edgeRemoved(java.lang.String, long, java.lang.String)
*
* @see org.graphstream.stream.ElementSink#edgeRemoved(java.lang.String,
* long, java.lang.String)
*/
public void edgeRemoved(String sourceId, long timeId, String edgeId) {
}
/*
* (non-Javadoc)
* @see org.graphstream.stream.ElementSink#graphCleared(java.lang.String, long)
*
* @see org.graphstream.stream.ElementSink#graphCleared(java.lang.String,
* long)
*/
public void graphCleared(String sourceId, long timeId) {
pbox.removeAllParticles();
......@@ -237,16 +272,20 @@ public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
/*
* (non-Javadoc)
* @see org.graphstream.stream.ElementSink#nodeAdded(java.lang.String, long, java.lang.String)
*
* @see org.graphstream.stream.ElementSink#nodeAdded(java.lang.String, long,
* java.lang.String)
*/
public void nodeAdded(String sourceId, long timeId, String nodeId) {
Boid b = ctx.getNode(nodeId);
pbox.addParticle(((NTreeForces) b.getForces()).p);
}
/*
* (non-Javadoc)
* @see org.graphstream.stream.ElementSink#nodeRemoved(java.lang.String, long, java.lang.String)
*
* @see org.graphstream.stream.ElementSink#nodeRemoved(java.lang.String,
* long, java.lang.String)
*/
public void nodeRemoved(String sourceId, long timeId, String nodeId) {
Boid b = ctx.getNode(nodeId);
......@@ -255,7 +294,9 @@ public class NTreeForcesFactory implements BoidsForcesFactory, ElementSink {
/*
* (non-Javadoc)
* @see org.graphstream.stream.ElementSink#stepBegins(java.lang.String, long, double)
*
* @see org.graphstream.stream.ElementSink#stepBegins(java.lang.String,
* long, double)
*/
public void stepBegins(String sourceId, long timeId, double step) {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment