The simulation is encapsulated into a single C++ object of type smcSim (spinal motor circuit simulation). Rather than mechanically describing the object's design, I will walk through the life of the object.
When the user selects a data file (and it is verified), any current smcSim object pointed to by smcSimMain is destroyed. The destructor makes the call to Discard_ActiveNeurons(ActiveNeurons *) which frees all of the space allocated for the recording data structure. The name of the file is then passed as the single parameter in the call new smcSim(filename). The constructor, by the same name, is invoked.
The constructor initializes the Framing variable with the values of the starting and ending time steps for the recording. These values are currently set statically but the next version, already in development, will allow for the values to be set interactively in a dialog box at the time the file is selected. The OpenFile member function then opens the data file name passed as a parameter. ReadInput member function reads the file and then the object wide member variables are initialized. Initialize_ActiveNeurons initializes the data structures to be used for the recording. Simulate is called to run the actual simulation and store the values in the data structures. Finally Framing.time_step is set to the value Framing.start_frame-1 so the first step displayed will be the first recorded step. The constructor returns and the callback function updates the time step widget with the value in Framing.start_frame. (The value is retrieved with a utility function so the variable may remain private to the object.)
The rest of the member functions of smcSim are public utility functions used to retrieve and set the values of the private member variables with the exception of smcSim::updateTimeStep(). UpdateTimeStep is the only member function to access an external variable. By design it updates the coordinate values for the meshes in treeLeaves (the global data structure that represents the Inventor scene graph) with the values in the private recording data structures of the object.
The data structure developed by Dr. Subramanian holds the results of the entire simulation and is of the following form:
typedef struct active_neurons_type ActiveNeuronsType, *ActiveNeurons; typedef struct firing_cells_type FiringCellsType, *FiringCells; typedef struct fib_fields_type FibFieldsType, *FibFields; typedef unsigned char CellIdType, *CellId; typedef short PopulationId; typedef float Threshold, Potential; struct active_neurons_type { FibFields f; FiringCells firing_cells; }; struct firing_cells_type { PopulationId pop_id; int num_cells; CellId cells; FiringCells next; }; struct fib_fields_type
{ Threshold threshold[NCPOPS][NCLS]; Potential potential[NCPOPS][NCLS]; }; typedef struct firing_pop_type { int num_firings, pop_id, time_step, cell_ids[NCLS]; } Firing_Pop_Type, *FiringPop; extern Firing_Pop_Type firing_pop;
Where activeNeurons is an array as long as the simulation.