[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
3d space problem
From: |
Laurence Clark |
Subject: |
3d space problem |
Date: |
Thu, 03 Feb 2000 18:28:52 +0000 |
Hi,
I am currently building a stochastic model of bacterial chemotaxis using
Swarm. So far I have successfully implemented a 2d space (based on the
Heatbugs example) where the molecules involved can collide and react with
each other, and I now want to scale this up to a 3d model. Since most of
the reactions take place around the cell membrane, a 50 x 50 x 3 space is
all that's required. I have tried to implement this space with a list of 3
pointers to 50x50 Grid2d objects. The code compiles successfully, but
core-dumps when run. Below is
my modified code for displaying the 3 grids, and attached is a .zip file
containing the entire source code. Can anyone help?
Best wishes, Laurence Clark
----------------------------------------------------------------------
-buildObjects {
int inc;
id <Grid2d> currentSpace;
id <ZoomRaster> spaceRaster;
id <Object2dDisplay> enzymeDisplay;
[super buildObjects];
netModelSwarm = [NetModelSwarm create: self];
// Now create probe objects on the model and ourselves. This gives a
// simple user interface to let the user change parameters.
CREATE_ARCHIVED_PROBE_DISPLAY (netModelSwarm);
CREATE_ARCHIVED_PROBE_DISPLAY (self);
// Instruct the control panel to wait for a button event: we halt here
// until someone hits a control panel button so the user can get a
// chance to fill in parameters before the simulation runs
[controlPanel setStateStopped];
// OK - the user has specified all the parameters for the simulation.
// Now we're ready to start.
// First, let the model swarm build its objects.
[netModelSwarm buildObjects];
// Now get down to building our own display objects.
// First, create a colormap: this is a global resource, the information
// here is used by lots of different objects.
colormap = [Colormap create: self];
// Colour 0 is set to green, to display receptor objects
[colormap setColor: 0 ToName: "green"];
// Colour 1 is set to red, to display CheY objects
[colormap setColor: 1 ToName: "red"];
// Colour 2 is set to blue, to display CheZ objects
[colormap setColor: 2 ToName: "blue"];
// Colour 3 is set to yellow, to display CheR objects
[colormap setColor: 3 ToName: "yellow"];
// Colour 4 is set to white, to display CheB objects
[colormap setColor: 4 ToName: "white"];
// Colour 5 is set to light blue, to display aspartate objects
[colormap setColor: 5 ToName: "cyan"];
// Colour 6 is set to purple, to display aspartate objects
[colormap setColor: 6 ToName: "magenta"];
// Next, create a 2d window for display, set its size, zoom factor, title.
space = [netModelSwarm getSpace];
spaceX = [[space atOffset:0] getSizeX];
spaceY = [[space atOffset:0] getSizeY];
spaceZ = [space getCount];
spaceRasterList = [List create: [self getZone]];
enzymeDisplayList = [List create: [self getZone]];
for (inc=0; inc<spaceZ; inc++) {
currentSpace = [space atOffset:inc];
spaceRaster = [ZoomRaster createBegin: self];
SET_WINDOW_GEOMETRY_RECORD_NAME (spaceRaster);
spaceRaster = [spaceRaster createEnd];
[spaceRaster enableDestroyNotification: self
notificationMethod: @selector (_spaceRasterDeath_:)];
[spaceRaster setColormap: colormap];
[spaceRaster setZoomFactor: 4];
[spaceRaster setWidth: spaceX Height: spaceY];
[spaceRaster setWindowTitle: "Cell Space"];
[spaceRaster pack]; // draw the window.
[spaceRasterList addLast:spaceRaster];
// And also create an Object2dDisplay: this object draws heatbugs on
// the spaceRaster widget for us, and also receives probes.
enzymeDisplay =
[Object2dDisplay create: self
setDisplayWidget: spaceRaster
setDiscrete2dToDisplay: currentSpace
setDisplayMessage: M(drawSelfOn:)];
[enzymeDisplay setObjectCollection: [netModelSwarm getObjectList]];
[enzymeDisplayList addLast:enzymeDisplay];
// Also, tell the space raster to send mouse clicks to the enzymeDisplay
// this allows the user to right-click on the display to probe the enzymes.
[spaceRaster setButton: ButtonRight
Client: enzymeDisplay
Message: M(makeProbeAtX:Y:)];
}
return self;
}
- _update_ {
int inc;
for (inc=0; inc<[spaceRasterList getCount]; inc++) {
if ([spaceRasterList atOffset:inc]) {
[[enzymeDisplayList atOffset:inc] display];
[[spaceRasterList atOffset:inc] drawSelf]; }}
return self; }
chemotaxis.zip
Description: Zip archive
- 3d space problem,
Laurence Clark <=