Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add param so we can run a prev simulation starting from a specific ti… #137

Open
wants to merge 12 commits into
base: development
Choose a base branch
from
Open
8 changes: 8 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ bool load_to = false;
bool skip_display_particles = false;
bool skip_display_membranes = false;
bool skip_display_connections = false;
int start_timestep = 0;
int stop_timestep = 0;
std::string version = "0.0.6";

int usage() {
Expand Down Expand Up @@ -140,6 +142,12 @@ int main(int argc, char **argv) {
if (std::string("-skip_display_connections").compare(argv[i]) == 0) {
skip_display_connections = true;
}
if (!std::string(argv[i]).compare(0, std::string("-start_timestep=").size(), std::string("-start_timestep="))) {
start_timestep = atoi(std::string(argv[i]).substr(std::string("-start_timestep=").size()).c_str());
}
if (!std::string(argv[i]).compare(0, std::string("-stop_timestep=").size(), std::string("-stop_timestep="))) {
stop_timestep = atoi(std::string(argv[i]).substr(std::string("-stop_timestep=").size()).c_str());
}
if (std::string("-test").compare(argv[i]) == 0) { // run tests
run_tests = true;
}
Expand Down
11 changes: 11 additions & 0 deletions src/owWorldSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ extern bool load_to;
extern bool skip_display_particles;
extern bool skip_display_membranes;
extern bool skip_display_connections;
extern int start_timestep;
extern int stop_timestep;

int old_x = 0, old_y = 0; // Used for mouse event
float camera_trans[] = {0, 0, -8.0};
Expand Down Expand Up @@ -200,6 +202,15 @@ void display(void) {
helper->refreshTime();
}

if (iteration < start_timestep) {
return;
}
if (stop_timestep > 0 && iteration >= stop_timestep) {
std::cout << "Simulation has reached the time limit..." << std::endl;
cleanupSimulation();
exit(EXIT_SUCCESS);
}

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawScene();
glPointSize(1.3f * sqrt(sc / 0.025f));
Expand Down