예제 #1
0
static void make_confirm_menu(void)
{
    Menu* ms;

    ms = &root.confirm_menu;

    ms->title = NULL;
    ms->numoptions = 2;
    ms->origin.x = 0;
    ms->origin.y = 0;
    ms->type = normal_menu;
    ms->option = (MenuItem*)simm_malloc(ms->numoptions*sizeof(MenuItem));
    if (ms->option == NULL)
        error(exit_program,tool_message);

    ms->option[0].active = yes;
    ms->option[1].active = yes;
    ms->option[0].visible = yes;
    ms->option[1].visible = yes;
    mstrcpy(&ms->option[0].name,confirmstr[0]);
    mstrcpy(&ms->option[1].name,confirmstr[1]);

    SET_BOX(ms->option[0].box,30,100,30,ms->option[0].box.y1+MENU_ITEM_HEIGHT);
    SET_BOX(ms->option[1].box,160,230,30,ms->option[1].box.y1+MENU_ITEM_HEIGHT);
}
예제 #2
0
/* INIT_GENCOORDS: this function sets some of the initial values in the gencoord
 * structs. It must be called after all the joints have been read in because it
 * mallocs an array of size numjoints for each gencoord.
 */
ReturnCode init_gencoords(ModelStruct* ms)
{
    int i;

    for (i=0; i<ms->numgencoords; i++)
    {
        if (ms->gencoord[i]->default_value >= ms->gencoord[i]->range.start &&
                ms->gencoord[i]->default_value <= ms->gencoord[i]->range.end)
            ms->gencoord[i]->value = ms->gencoord[i]->default_value;
        else if (ms->gencoord[i]->range.start > 0.0 ||
                 ms->gencoord[i]->range.end < 0.0)
            ms->gencoord[i]->value = ms->gencoord[i]->range.start;
        else
            ms->gencoord[i]->value = 0.0;

        ms->gencoord[i]->velocity = 0.0;

#if ! ENGINE
        storeDoubleInForm(&ms->gencform.option[i], ms->gencoord[i]->value, 3);
#endif

        ms->gencoord[i]->numjoints = 0;
        ms->gencoord[i]->jointnum = (int*)simm_malloc(ms->numjoints*sizeof(int));
        if (ms->gencoord[i]->jointnum == NULL)
            return code_bad;
    }

    return code_fine;
}
예제 #3
0
ReturnCode initplot(int plotnum)
{
    gPlot[plotnum]->plotnum = plotnum;
    gPlot[plotnum]->numcurves = 0;
    gPlot[plotnum]->zoomed_yet = no;
    gPlot[plotnum]->numpoints = 0;
    gPlot[plotnum]->xname_len = 0;
    gPlot[plotnum]->yname_len = 0;
    gPlot[plotnum]->title_len = 256;
    gPlot[plotnum]->title = (char*)simm_malloc(gPlot[plotnum]->title_len);
    gPlot[plotnum]->xname = NULL;
    gPlot[plotnum]->yname = NULL;
    gPlot[plotnum]->cursor_modelPtr = NULL;
    gPlot[plotnum]->cursor_motion = NULL;
    gPlot[plotnum]->show_cursor = yes;
    gPlot[plotnum]->show_events = yes;
    gPlot[plotnum]->needs_bounding = no;
    gPlot[plotnum]->num_file_events = 0;
    gPlot[plotnum]->file_event = NULL;

    if (gPlot[plotnum]->title == NULL)
        return code_bad;

    NULLIFY_STRING(gPlot[plotnum]->title);

    return code_fine;
}
예제 #4
0
ReturnCode make_dynparams_form(ModelStruct* ms)
{
   int i, name_len, num_options;
   Form* form;

   if (ms->default_muscle)
      num_options = ms->default_muscle->num_dynamic_params + 1; // one extra for muscle model
   else
      num_options = 1; // one extra for muscle model

   form = &ms->dynparamsform;
   form->numoptions = num_options;
   form->selected_item = -1;
   form->cursor_position = 0;
   form->highlight_start = 0;
   form->title = NULL;

   ms->longest_dynparam_name = 0;

   form->option = (FormItem*)simm_malloc(form->numoptions*sizeof(FormItem));
   if (form->option == NULL)
      return code_bad;

   ms->dynparamsSize = 0;
   for (i=0; i<form->numoptions; i++)
   {
      form->option[i].justify = yes;
      form->option[i].active = yes;
      form->option[i].visible = yes;
      form->option[i].editable = yes;
      form->option[i].use_alternate_colors = no;
      form->option[i].data = NULL;
      if (i == num_options - 1)
      {
         form->option[i].decimal_places = 0;
         mstrcpy(&form->option[i].name, "muscle_model");
      }
      else
      {
         form->option[i].decimal_places = 3;
         mstrcpy(&form->option[i].name, ms->default_muscle->dynamic_param_names[i]);
      }
      name_len = glueGetStringWidth(root.gfont.defaultfont, form->option[i].name);
      if (name_len > ms->longest_dynparam_name)
	      ms->longest_dynparam_name = name_len;
      SET_BOX1221(form->option[i].box, 0, 90,-FORM_FIELD_YSPACING*i,
		  form->option[i].box.y2-FORM_FIELD_HEIGHT);
      ms->dynparamsSize = form->option[i].box.y2 - FORM_FIELD_HEIGHT;
   }

   ms->longest_dynparam_name -= 30;

   return code_fine;
}
예제 #5
0
ReturnCode initMusclePath(dpMusclePathStruct *musclepoints)
{
    musclepoints->num_orig_points = 0;
    musclepoints->mp_orig_array_size = MUSCLEPOINT_ARRAY_INCREMENT;
    musclepoints->mp_orig = (dpMusclePoint *)simm_malloc(musclepoints->mp_orig_array_size * sizeof(dpMusclePoint));
    if (musclepoints->mp_orig == NULL)
        return code_bad;

    musclepoints->num_points = 0;
    musclepoints->mp_array_size = 0;
    musclepoints->mp = NULL;

    return code_fine;
}
예제 #6
0
/* INIT_MUSCLE: this routine initializes much of the muscle structure. Before
 * a given muscle is read-in from an input file, each of the pointers to its
 * muscle-specific parameters is set to point into the default-muscle structure.
 * Thus if a certain parameter is not specified for a muscle (e.g. force-length
 * curve), the default-muscle's parameter is used. This cuts down significantly
 * on the amount of information that must be supplied in a muscle file since
 * most muscles share the same active_force_len_func, tendon_force_len_func,
 * passive_force_len_func, and force_vel_func.
 */
ReturnCode init_muscle(ModelStruct* model, dpMuscleStruct* muscle, dpMuscleStruct* default_muscle)
{
    int i;

    memset(muscle, 0, sizeof(dpMuscleStruct));

    muscle->display = default_muscle->display;
    muscle->output = yes;
    muscle->selected = no;
    muscle->numgroups = default_muscle->numgroups;
    muscle->group = default_muscle->group;
    muscle->max_isometric_force = default_muscle->max_isometric_force;
    muscle->pennation_angle = default_muscle->pennation_angle;
    muscle->optimal_fiber_length = default_muscle->optimal_fiber_length;
    muscle->resting_tendon_length = default_muscle->resting_tendon_length;
    muscle->min_thickness = default_muscle->min_thickness;
    muscle->max_thickness = default_muscle->max_thickness;
    muscle->min_material = default_muscle->min_material;
    muscle->max_material = default_muscle->max_material;
    muscle->max_contraction_vel = default_muscle->max_contraction_vel;
    muscle->force_vel_func = default_muscle->force_vel_func;

    if (init_dynamic_param_array(muscle, default_muscle) == code_bad)
        return code_bad;

    muscle->muscle_model_index = default_muscle->muscle_model_index;
    muscle->excitation_func = default_muscle->excitation_func;
    muscle->excitation_abscissa = default_muscle->excitation_abscissa;

    muscle->nummomentarms = model->numgencoords;
    muscle->momentarms = (double *)simm_malloc(muscle->nummomentarms*sizeof(double));
    if (muscle->momentarms == NULL)
        return code_bad;

    for (i=0; i<muscle->nummomentarms; i++)
        muscle->momentarms[i] = 0.0;
    muscle->dynamic_activation = 1.0;
    muscle->tendon_force_len_func = default_muscle->tendon_force_len_func;
    muscle->active_force_len_func = default_muscle->active_force_len_func;
    muscle->passive_force_len_func = default_muscle->passive_force_len_func;

    muscle->wrap_calced = no;

    return code_fine;
}
예제 #7
0
void init_segments(void)
{

   sdm.num_body_segments = 16;

   sdm.body_segment = (BodyStruct*)simm_malloc(sdm.num_body_segments*sizeof(BodyStruct));

   mstrcpy(&sdm.body_segment[0].name,"ground");
   sdm.body_segment[0].mass = 0.000000;
   sdm.body_segment[0].inertia[0][0] = 0.000000;
   sdm.body_segment[0].inertia[0][1] = 0.000000;
   sdm.body_segment[0].inertia[0][2] = 0.000000;
   sdm.body_segment[0].inertia[1][0] = 0.000000;
   sdm.body_segment[0].inertia[1][1] = 0.000000;
   sdm.body_segment[0].inertia[1][2] = 0.000000;
   sdm.body_segment[0].inertia[2][0] = 0.000000;
   sdm.body_segment[0].inertia[2][1] = 0.000000;
   sdm.body_segment[0].inertia[2][2] = 0.000000;
   sdm.body_segment[0].mass_center[0] = 0.000000;
   sdm.body_segment[0].mass_center[1] = 0.000000;
   sdm.body_segment[0].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[1].name,"pelvis");
   sdm.body_segment[1].mass = 51.100000;
   sdm.body_segment[1].inertia[0][0] = 1.396000;
   sdm.body_segment[1].inertia[0][1] = 0.000000;
   sdm.body_segment[1].inertia[0][2] = 0.000000;
   sdm.body_segment[1].inertia[1][0] = 0.000000;
   sdm.body_segment[1].inertia[1][1] = 0.715300;
   sdm.body_segment[1].inertia[1][2] = 0.000000;
   sdm.body_segment[1].inertia[2][0] = 0.000000;
   sdm.body_segment[1].inertia[2][1] = 0.000000;
   sdm.body_segment[1].inertia[2][2] = 2.580000;
   sdm.body_segment[1].mass_center[0] = -0.070700;
   sdm.body_segment[1].mass_center[1] = 0.263900;
   sdm.body_segment[1].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[2].name,"femur_r");
   sdm.body_segment[2].mass = 7.760000;
   sdm.body_segment[2].inertia[0][0] = 0.137000;
   sdm.body_segment[2].inertia[0][1] = 0.000000;
   sdm.body_segment[2].inertia[0][2] = 0.000000;
   sdm.body_segment[2].inertia[1][0] = 0.000000;
   sdm.body_segment[2].inertia[1][1] = 0.031600;
   sdm.body_segment[2].inertia[1][2] = 0.000000;
   sdm.body_segment[2].inertia[2][0] = 0.000000;
   sdm.body_segment[2].inertia[2][1] = 0.000000;
   sdm.body_segment[2].inertia[2][2] = 0.137000;
   sdm.body_segment[2].mass_center[0] = 0.000000;
   sdm.body_segment[2].mass_center[1] = -0.170000;
   sdm.body_segment[2].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[3].name,"tibia_r");
   sdm.body_segment[3].mass = 3.030000;
   sdm.body_segment[3].inertia[0][0] = 0.044400;
   sdm.body_segment[3].inertia[0][1] = 0.000000;
   sdm.body_segment[3].inertia[0][2] = 0.000000;
   sdm.body_segment[3].inertia[1][0] = 0.000000;
   sdm.body_segment[3].inertia[1][1] = 0.003830;
   sdm.body_segment[3].inertia[1][2] = 0.000000;
   sdm.body_segment[3].inertia[2][0] = 0.000000;
   sdm.body_segment[3].inertia[2][1] = 0.000000;
   sdm.body_segment[3].inertia[2][2] = 0.044500;
   sdm.body_segment[3].mass_center[0] = 0.000000;
   sdm.body_segment[3].mass_center[1] = -0.186700;
   sdm.body_segment[3].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[4].name,"patella_r");
   sdm.body_segment[4].mass = 0.100000;
   sdm.body_segment[4].inertia[0][0] = 0.001000;
   sdm.body_segment[4].inertia[0][1] = 0.000000;
   sdm.body_segment[4].inertia[0][2] = 0.000000;
   sdm.body_segment[4].inertia[1][0] = 0.000000;
   sdm.body_segment[4].inertia[1][1] = 0.001000;
   sdm.body_segment[4].inertia[1][2] = 0.000000;
   sdm.body_segment[4].inertia[2][0] = 0.000000;
   sdm.body_segment[4].inertia[2][1] = 0.000000;
   sdm.body_segment[4].inertia[2][2] = 0.001000;
   sdm.body_segment[4].mass_center[0] = 0.000000;
   sdm.body_segment[4].mass_center[1] = 0.000000;
   sdm.body_segment[4].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[5].name,"talus_r");
   sdm.body_segment[5].mass = 0.100000;
   sdm.body_segment[5].inertia[0][0] = 0.001000;
   sdm.body_segment[5].inertia[0][1] = 0.000000;
   sdm.body_segment[5].inertia[0][2] = 0.000000;
   sdm.body_segment[5].inertia[1][0] = 0.000000;
   sdm.body_segment[5].inertia[1][1] = 0.001000;
   sdm.body_segment[5].inertia[1][2] = 0.000000;
   sdm.body_segment[5].inertia[2][0] = 0.000000;
   sdm.body_segment[5].inertia[2][1] = 0.000000;
   sdm.body_segment[5].inertia[2][2] = 0.001000;
   sdm.body_segment[5].mass_center[0] = 0.000000;
   sdm.body_segment[5].mass_center[1] = 0.000000;
   sdm.body_segment[5].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[6].name,"calcn_r");
   sdm.body_segment[6].mass = 0.418300;
   sdm.body_segment[6].inertia[0][0] = 0.001000;
   sdm.body_segment[6].inertia[0][1] = 0.000000;
   sdm.body_segment[6].inertia[0][2] = 0.000000;
   sdm.body_segment[6].inertia[1][0] = 0.000000;
   sdm.body_segment[6].inertia[1][1] = 0.001000;
   sdm.body_segment[6].inertia[1][2] = 0.000000;
   sdm.body_segment[6].inertia[2][0] = 0.000000;
   sdm.body_segment[6].inertia[2][1] = 0.000000;
   sdm.body_segment[6].inertia[2][2] = 0.001000;
   sdm.body_segment[6].mass_center[0] = 0.025000;
   sdm.body_segment[6].mass_center[1] = 0.015000;
   sdm.body_segment[6].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[7].name,"midfoot_r");
   sdm.body_segment[7].mass = 0.400000;
   sdm.body_segment[7].inertia[0][0] = 0.001000;
   sdm.body_segment[7].inertia[0][1] = 0.000000;
   sdm.body_segment[7].inertia[0][2] = 0.000000;
   sdm.body_segment[7].inertia[1][0] = 0.000000;
   sdm.body_segment[7].inertia[1][1] = 0.001000;
   sdm.body_segment[7].inertia[1][2] = 0.000000;
   sdm.body_segment[7].inertia[2][0] = 0.000000;
   sdm.body_segment[7].inertia[2][1] = 0.000000;
   sdm.body_segment[7].inertia[2][2] = 0.001000;
   sdm.body_segment[7].mass_center[0] = 0.025000;
   sdm.body_segment[7].mass_center[1] = 0.015000;
   sdm.body_segment[7].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[8].name,"toes_r");
   sdm.body_segment[8].mass = 0.205800;
   sdm.body_segment[8].inertia[0][0] = 0.001000;
   sdm.body_segment[8].inertia[0][1] = 0.000000;
   sdm.body_segment[8].inertia[0][2] = 0.000000;
   sdm.body_segment[8].inertia[1][0] = 0.000000;
   sdm.body_segment[8].inertia[1][1] = 0.001000;
   sdm.body_segment[8].inertia[1][2] = 0.000000;
   sdm.body_segment[8].inertia[2][0] = 0.000000;
   sdm.body_segment[8].inertia[2][1] = 0.000000;
   sdm.body_segment[8].inertia[2][2] = 0.001000;
   sdm.body_segment[8].mass_center[0] = 0.034600;
   sdm.body_segment[8].mass_center[1] = 0.006000;
   sdm.body_segment[8].mass_center[2] = -0.017500;

   mstrcpy(&sdm.body_segment[9].name,"femur_l");
   sdm.body_segment[9].mass = 7.760000;
   sdm.body_segment[9].inertia[0][0] = 0.137000;
   sdm.body_segment[9].inertia[0][1] = 0.000000;
   sdm.body_segment[9].inertia[0][2] = 0.000000;
   sdm.body_segment[9].inertia[1][0] = 0.000000;
   sdm.body_segment[9].inertia[1][1] = 0.031600;
   sdm.body_segment[9].inertia[1][2] = 0.000000;
   sdm.body_segment[9].inertia[2][0] = 0.000000;
   sdm.body_segment[9].inertia[2][1] = 0.000000;
   sdm.body_segment[9].inertia[2][2] = 0.137000;
   sdm.body_segment[9].mass_center[0] = 0.000000;
   sdm.body_segment[9].mass_center[1] = -0.170000;
   sdm.body_segment[9].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[10].name,"tibia_l");
   sdm.body_segment[10].mass = 3.030000;
   sdm.body_segment[10].inertia[0][0] = 0.044400;
   sdm.body_segment[10].inertia[0][1] = 0.000000;
   sdm.body_segment[10].inertia[0][2] = 0.000000;
   sdm.body_segment[10].inertia[1][0] = 0.000000;
   sdm.body_segment[10].inertia[1][1] = 0.003830;
   sdm.body_segment[10].inertia[1][2] = 0.000000;
   sdm.body_segment[10].inertia[2][0] = 0.000000;
   sdm.body_segment[10].inertia[2][1] = 0.000000;
   sdm.body_segment[10].inertia[2][2] = 0.044500;
   sdm.body_segment[10].mass_center[0] = 0.000000;
   sdm.body_segment[10].mass_center[1] = -0.186700;
   sdm.body_segment[10].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[11].name,"patella_l");
   sdm.body_segment[11].mass = 0.100000;
   sdm.body_segment[11].inertia[0][0] = 0.001000;
   sdm.body_segment[11].inertia[0][1] = 0.000000;
   sdm.body_segment[11].inertia[0][2] = 0.000000;
   sdm.body_segment[11].inertia[1][0] = 0.000000;
   sdm.body_segment[11].inertia[1][1] = 0.001000;
   sdm.body_segment[11].inertia[1][2] = 0.000000;
   sdm.body_segment[11].inertia[2][0] = 0.000000;
   sdm.body_segment[11].inertia[2][1] = 0.000000;
   sdm.body_segment[11].inertia[2][2] = 0.001000;
   sdm.body_segment[11].mass_center[0] = 0.000000;
   sdm.body_segment[11].mass_center[1] = 0.000000;
   sdm.body_segment[11].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[12].name,"talus_l");
   sdm.body_segment[12].mass = 0.100000;
   sdm.body_segment[12].inertia[0][0] = 0.001000;
   sdm.body_segment[12].inertia[0][1] = 0.000000;
   sdm.body_segment[12].inertia[0][2] = 0.000000;
   sdm.body_segment[12].inertia[1][0] = 0.000000;
   sdm.body_segment[12].inertia[1][1] = 0.001000;
   sdm.body_segment[12].inertia[1][2] = 0.000000;
   sdm.body_segment[12].inertia[2][0] = 0.000000;
   sdm.body_segment[12].inertia[2][1] = 0.000000;
   sdm.body_segment[12].inertia[2][2] = 0.001000;
   sdm.body_segment[12].mass_center[0] = 0.000000;
   sdm.body_segment[12].mass_center[1] = 0.000000;
   sdm.body_segment[12].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[13].name,"calcn_l");
   sdm.body_segment[13].mass = 0.418300;
   sdm.body_segment[13].inertia[0][0] = 0.001000;
   sdm.body_segment[13].inertia[0][1] = 0.000000;
   sdm.body_segment[13].inertia[0][2] = 0.000000;
   sdm.body_segment[13].inertia[1][0] = 0.000000;
   sdm.body_segment[13].inertia[1][1] = 0.001000;
   sdm.body_segment[13].inertia[1][2] = 0.000000;
   sdm.body_segment[13].inertia[2][0] = 0.000000;
   sdm.body_segment[13].inertia[2][1] = 0.000000;
   sdm.body_segment[13].inertia[2][2] = 0.001000;
   sdm.body_segment[13].mass_center[0] = 0.025000;
   sdm.body_segment[13].mass_center[1] = 0.015000;
   sdm.body_segment[13].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[14].name,"midfoot_l");
   sdm.body_segment[14].mass = 0.400000;
   sdm.body_segment[14].inertia[0][0] = 0.001000;
   sdm.body_segment[14].inertia[0][1] = 0.000000;
   sdm.body_segment[14].inertia[0][2] = 0.000000;
   sdm.body_segment[14].inertia[1][0] = 0.000000;
   sdm.body_segment[14].inertia[1][1] = 0.001000;
   sdm.body_segment[14].inertia[1][2] = 0.000000;
   sdm.body_segment[14].inertia[2][0] = 0.000000;
   sdm.body_segment[14].inertia[2][1] = 0.000000;
   sdm.body_segment[14].inertia[2][2] = 0.001000;
   sdm.body_segment[14].mass_center[0] = 0.025000;
   sdm.body_segment[14].mass_center[1] = 0.015000;
   sdm.body_segment[14].mass_center[2] = 0.000000;

   mstrcpy(&sdm.body_segment[15].name,"toes_l");
   sdm.body_segment[15].mass = 0.205800;
   sdm.body_segment[15].inertia[0][0] = 0.001000;
   sdm.body_segment[15].inertia[0][1] = 0.000000;
   sdm.body_segment[15].inertia[0][2] = 0.000000;
   sdm.body_segment[15].inertia[1][0] = 0.000000;
   sdm.body_segment[15].inertia[1][1] = 0.001000;
   sdm.body_segment[15].inertia[1][2] = 0.000000;
   sdm.body_segment[15].inertia[2][0] = 0.000000;
   sdm.body_segment[15].inertia[2][1] = 0.000000;
   sdm.body_segment[15].inertia[2][2] = 0.001000;
   sdm.body_segment[15].mass_center[0] = 0.034600;
   sdm.body_segment[15].mass_center[1] = 0.006000;
   sdm.body_segment[15].mass_center[2] = 0.017500;

}
예제 #8
0
void init_qs(void)
{

   int i;

   sdm.nq = 25;
   sdm.nu = 25;

   sdm.q = (QStruct*)simm_malloc(sdm.nq*sizeof(QStruct));
   sdm.num_closed_loops = 0;

   mstrcpy(&sdm.q[leg_tx].name,"leg_tx");
   sdm.q[leg_tx].type = unconstrained_q;
   sdm.q[leg_tx].joint = ground_pelvis;
   sdm.q[leg_tx].axis = 0;
   sdm.q[leg_tx].conversion = 1.00000;
   sdm.q[leg_tx].initial_value = 0.00000;
   sdm.q[leg_tx].range_start = -2.00000;
   sdm.q[leg_tx].range_end = 4.00000;
   sdm.q[leg_tx].restraint_func = NULL;
   sdm.q[leg_tx].min_restraint_func = NULL;
   sdm.q[leg_tx].max_restraint_func = NULL;

   mstrcpy(&sdm.q[leg_ty].name,"leg_ty");
   sdm.q[leg_ty].type = unconstrained_q;
   sdm.q[leg_ty].joint = ground_pelvis;
   sdm.q[leg_ty].axis = 1;
   sdm.q[leg_ty].conversion = 1.00000;
   sdm.q[leg_ty].initial_value = 0.91356;
   sdm.q[leg_ty].range_start = 0.00000;
   sdm.q[leg_ty].range_end = 2.00000;
   sdm.q[leg_ty].restraint_func = NULL;
   sdm.q[leg_ty].min_restraint_func = NULL;
   sdm.q[leg_ty].max_restraint_func = NULL;

   mstrcpy(&sdm.q[pelvis_rotation].name,"pelvis_rotation");
   sdm.q[pelvis_rotation].type = unconstrained_q;
   sdm.q[pelvis_rotation].joint = ground_pelvis;
   sdm.q[pelvis_rotation].axis = 2;
   sdm.q[pelvis_rotation].conversion = 57.29578;
   sdm.q[pelvis_rotation].initial_value = -0.72068;
   sdm.q[pelvis_rotation].range_start = -90.00000;
   sdm.q[pelvis_rotation].range_end = 90.00000;
   sdm.q[pelvis_rotation].restraint_func = NULL;
   sdm.q[pelvis_rotation].min_restraint_func = &q_restraint_func[0];
   sdm.q[pelvis_rotation].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[hip_angle_r].name,"hip_angle_r");
   sdm.q[hip_angle_r].type = unconstrained_q;
   sdm.q[hip_angle_r].joint = hip_r;
   sdm.q[hip_angle_r].axis = 0;
   sdm.q[hip_angle_r].conversion = 57.29578;
   sdm.q[hip_angle_r].initial_value = 30.67604;
   sdm.q[hip_angle_r].range_start = -40.00000;
   sdm.q[hip_angle_r].range_end = 120.00000;
   sdm.q[hip_angle_r].restraint_func = NULL;
   sdm.q[hip_angle_r].min_restraint_func = &q_restraint_func[0];
   sdm.q[hip_angle_r].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[knee_r_tx].name,"knee_r_tx");
   sdm.q[knee_r_tx].type = constrained_q;
   sdm.q[knee_r_tx].joint = knee_r;
   sdm.q[knee_r_tx].axis = 0;
   sdm.q[knee_r_tx].conversion = 1.00000;
   sdm.q[knee_r_tx].initial_value = -0.00453;
   sdm.q[knee_r_tx].range_start = -99999.9;
   sdm.q[knee_r_tx].range_end = 99999.9;
   sdm.q[knee_r_tx].restraint_func = NULL;
   sdm.q[knee_r_tx].min_restraint_func = NULL;
   sdm.q[knee_r_tx].max_restraint_func = NULL;

   mstrcpy(&sdm.q[knee_r_ty].name,"knee_r_ty");
   sdm.q[knee_r_ty].type = constrained_q;
   sdm.q[knee_r_ty].joint = knee_r;
   sdm.q[knee_r_ty].axis = 1;
   sdm.q[knee_r_ty].conversion = 1.00000;
   sdm.q[knee_r_ty].initial_value = -0.39618;
   sdm.q[knee_r_ty].range_start = -99999.9;
   sdm.q[knee_r_ty].range_end = 99999.9;
   sdm.q[knee_r_ty].restraint_func = NULL;
   sdm.q[knee_r_ty].min_restraint_func = NULL;
   sdm.q[knee_r_ty].max_restraint_func = NULL;

   mstrcpy(&sdm.q[knee_angle_r].name,"knee_angle_r");
   sdm.q[knee_angle_r].type = unconstrained_q;
   sdm.q[knee_angle_r].joint = knee_r;
   sdm.q[knee_angle_r].axis = 2;
   sdm.q[knee_angle_r].conversion = 57.29578;
   sdm.q[knee_angle_r].initial_value = -4.21151;
   sdm.q[knee_angle_r].range_start = -120.00000;
   sdm.q[knee_angle_r].range_end = 5.00000;
   sdm.q[knee_angle_r].restraint_func = NULL;
   sdm.q[knee_angle_r].min_restraint_func = &q_restraint_func[0];
   sdm.q[knee_angle_r].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[tib_pat_r_tx].name,"tib_pat_r_tx");
   sdm.q[tib_pat_r_tx].type = constrained_q;
   sdm.q[tib_pat_r_tx].joint = tib_pat_r;
   sdm.q[tib_pat_r_tx].axis = 0;
   sdm.q[tib_pat_r_tx].conversion = 1.00000;
   sdm.q[tib_pat_r_tx].initial_value = 0.04921;
   sdm.q[tib_pat_r_tx].range_start = -99999.9;
   sdm.q[tib_pat_r_tx].range_end = 99999.9;
   sdm.q[tib_pat_r_tx].restraint_func = NULL;
   sdm.q[tib_pat_r_tx].min_restraint_func = NULL;
   sdm.q[tib_pat_r_tx].max_restraint_func = NULL;

   mstrcpy(&sdm.q[tib_pat_r_ty].name,"tib_pat_r_ty");
   sdm.q[tib_pat_r_ty].type = constrained_q;
   sdm.q[tib_pat_r_ty].joint = tib_pat_r;
   sdm.q[tib_pat_r_ty].axis = 1;
   sdm.q[tib_pat_r_ty].conversion = 1.00000;
   sdm.q[tib_pat_r_ty].initial_value = -0.02256;
   sdm.q[tib_pat_r_ty].range_start = -99999.9;
   sdm.q[tib_pat_r_ty].range_end = 99999.9;
   sdm.q[tib_pat_r_ty].restraint_func = NULL;
   sdm.q[tib_pat_r_ty].min_restraint_func = NULL;
   sdm.q[tib_pat_r_ty].max_restraint_func = NULL;

   mstrcpy(&sdm.q[tib_pat_r_r3].name,"tib_pat_r_r3");
   sdm.q[tib_pat_r_r3].type = constrained_q;
   sdm.q[tib_pat_r_r3].joint = tib_pat_r;
   sdm.q[tib_pat_r_r3].axis = 2;
   sdm.q[tib_pat_r_r3].conversion = 57.29578;
   sdm.q[tib_pat_r_r3].initial_value = 4.52253;
   sdm.q[tib_pat_r_r3].range_start = -99999.9;
   sdm.q[tib_pat_r_r3].range_end = 99999.9;
   sdm.q[tib_pat_r_r3].restraint_func = NULL;
   sdm.q[tib_pat_r_r3].min_restraint_func = NULL;
   sdm.q[tib_pat_r_r3].max_restraint_func = NULL;

   mstrcpy(&sdm.q[ankle_angle_r].name,"ankle_angle_r");
   sdm.q[ankle_angle_r].type = unconstrained_q;
   sdm.q[ankle_angle_r].joint = ankle_r;
   sdm.q[ankle_angle_r].axis = 0;
   sdm.q[ankle_angle_r].conversion = 57.29578;
   sdm.q[ankle_angle_r].initial_value = 1.73984;
   sdm.q[ankle_angle_r].range_start = -40.00000;
   sdm.q[ankle_angle_r].range_end = 40.00000;
   sdm.q[ankle_angle_r].restraint_func = NULL;
   sdm.q[ankle_angle_r].min_restraint_func = &q_restraint_func[0];
   sdm.q[ankle_angle_r].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[prescribed11].name,"prescribed11");
   sdm.q[prescribed11].type = prescribed_q;
   sdm.q[prescribed11].joint = subtalar_r;
   sdm.q[prescribed11].axis = 0;
   sdm.q[prescribed11].conversion = 57.29578;
   sdm.q[prescribed11].initial_value = 0.00000;
   sdm.q[prescribed11].range_start = -99999.9;
   sdm.q[prescribed11].range_end = 99999.9;
   sdm.q[prescribed11].restraint_func = NULL;
   sdm.q[prescribed11].min_restraint_func = NULL;
   sdm.q[prescribed11].max_restraint_func = NULL;

   mstrcpy(&sdm.q[midfoot_angle_r].name,"midfoot_angle_r");
   sdm.q[midfoot_angle_r].type = unconstrained_q;
   sdm.q[midfoot_angle_r].joint = midfoot_r;
   sdm.q[midfoot_angle_r].axis = 0;
   sdm.q[midfoot_angle_r].conversion = 57.29578;
   sdm.q[midfoot_angle_r].initial_value = 0.00000;
   sdm.q[midfoot_angle_r].range_start = -60.00000;
   sdm.q[midfoot_angle_r].range_end = 60.00000;
   sdm.q[midfoot_angle_r].restraint_func = NULL;
   sdm.q[midfoot_angle_r].min_restraint_func = &q_restraint_func[0];
   sdm.q[midfoot_angle_r].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[mtp_angle_r].name,"mtp_angle_r");
   sdm.q[mtp_angle_r].type = unconstrained_q;
   sdm.q[mtp_angle_r].joint = mtp_r;
   sdm.q[mtp_angle_r].axis = 0;
   sdm.q[mtp_angle_r].conversion = 57.29578;
   sdm.q[mtp_angle_r].initial_value = 0.00000;
   sdm.q[mtp_angle_r].range_start = -60.00000;
   sdm.q[mtp_angle_r].range_end = 60.00000;
   sdm.q[mtp_angle_r].restraint_func = NULL;
   sdm.q[mtp_angle_r].min_restraint_func = &q_restraint_func[0];
   sdm.q[mtp_angle_r].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[hip_angle_l].name,"hip_angle_l");
   sdm.q[hip_angle_l].type = unconstrained_q;
   sdm.q[hip_angle_l].joint = hip_l;
   sdm.q[hip_angle_l].axis = 0;
   sdm.q[hip_angle_l].conversion = 57.29578;
   sdm.q[hip_angle_l].initial_value = -20.39872;
   sdm.q[hip_angle_l].range_start = -40.00000;
   sdm.q[hip_angle_l].range_end = 120.00000;
   sdm.q[hip_angle_l].restraint_func = NULL;
   sdm.q[hip_angle_l].min_restraint_func = &q_restraint_func[0];
   sdm.q[hip_angle_l].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[knee_l_tx].name,"knee_l_tx");
   sdm.q[knee_l_tx].type = constrained_q;
   sdm.q[knee_l_tx].joint = knee_l;
   sdm.q[knee_l_tx].axis = 0;
   sdm.q[knee_l_tx].conversion = 1.00000;
   sdm.q[knee_l_tx].initial_value = -0.00260;
   sdm.q[knee_l_tx].range_start = -99999.9;
   sdm.q[knee_l_tx].range_end = 99999.9;
   sdm.q[knee_l_tx].restraint_func = NULL;
   sdm.q[knee_l_tx].min_restraint_func = NULL;
   sdm.q[knee_l_tx].max_restraint_func = NULL;

   mstrcpy(&sdm.q[knee_l_ty].name,"knee_l_ty");
   sdm.q[knee_l_ty].type = constrained_q;
   sdm.q[knee_l_ty].joint = knee_l;
   sdm.q[knee_l_ty].axis = 1;
   sdm.q[knee_l_ty].conversion = 1.00000;
   sdm.q[knee_l_ty].initial_value = -0.39678;
   sdm.q[knee_l_ty].range_start = -99999.9;
   sdm.q[knee_l_ty].range_end = 99999.9;
   sdm.q[knee_l_ty].restraint_func = NULL;
   sdm.q[knee_l_ty].min_restraint_func = NULL;
   sdm.q[knee_l_ty].max_restraint_func = NULL;

   mstrcpy(&sdm.q[knee_angle_l].name,"knee_angle_l");
   sdm.q[knee_angle_l].type = unconstrained_q;
   sdm.q[knee_angle_l].joint = knee_l;
   sdm.q[knee_angle_l].axis = 2;
   sdm.q[knee_angle_l].conversion = 57.29578;
   sdm.q[knee_angle_l].initial_value = -12.10386;
   sdm.q[knee_angle_l].range_start = -120.00000;
   sdm.q[knee_angle_l].range_end = 5.00000;
   sdm.q[knee_angle_l].restraint_func = NULL;
   sdm.q[knee_angle_l].min_restraint_func = &q_restraint_func[0];
   sdm.q[knee_angle_l].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[tib_pat_l_tx].name,"tib_pat_l_tx");
   sdm.q[tib_pat_l_tx].type = constrained_q;
   sdm.q[tib_pat_l_tx].joint = tib_pat_l;
   sdm.q[tib_pat_l_tx].axis = 0;
   sdm.q[tib_pat_l_tx].conversion = 1.00000;
   sdm.q[tib_pat_l_tx].initial_value = 0.04809;
   sdm.q[tib_pat_l_tx].range_start = -99999.9;
   sdm.q[tib_pat_l_tx].range_end = 99999.9;
   sdm.q[tib_pat_l_tx].restraint_func = NULL;
   sdm.q[tib_pat_l_tx].min_restraint_func = NULL;
   sdm.q[tib_pat_l_tx].max_restraint_func = NULL;

   mstrcpy(&sdm.q[tib_pat_l_ty].name,"tib_pat_l_ty");
   sdm.q[tib_pat_l_ty].type = constrained_q;
   sdm.q[tib_pat_l_ty].joint = tib_pat_l;
   sdm.q[tib_pat_l_ty].axis = 1;
   sdm.q[tib_pat_l_ty].conversion = 1.00000;
   sdm.q[tib_pat_l_ty].initial_value = -0.02221;
   sdm.q[tib_pat_l_ty].range_start = -99999.9;
   sdm.q[tib_pat_l_ty].range_end = 99999.9;
   sdm.q[tib_pat_l_ty].restraint_func = NULL;
   sdm.q[tib_pat_l_ty].min_restraint_func = NULL;
   sdm.q[tib_pat_l_ty].max_restraint_func = NULL;

   mstrcpy(&sdm.q[tib_pat_l_r3].name,"tib_pat_l_r3");
   sdm.q[tib_pat_l_r3].type = constrained_q;
   sdm.q[tib_pat_l_r3].joint = tib_pat_l;
   sdm.q[tib_pat_l_r3].axis = 2;
   sdm.q[tib_pat_l_r3].conversion = 57.29578;
   sdm.q[tib_pat_l_r3].initial_value = 10.40390;
   sdm.q[tib_pat_l_r3].range_start = -99999.9;
   sdm.q[tib_pat_l_r3].range_end = 99999.9;
   sdm.q[tib_pat_l_r3].restraint_func = NULL;
   sdm.q[tib_pat_l_r3].min_restraint_func = NULL;
   sdm.q[tib_pat_l_r3].max_restraint_func = NULL;

   mstrcpy(&sdm.q[ankle_angle_l].name,"ankle_angle_l");
   sdm.q[ankle_angle_l].type = unconstrained_q;
   sdm.q[ankle_angle_l].joint = ankle_l;
   sdm.q[ankle_angle_l].axis = 0;
   sdm.q[ankle_angle_l].conversion = 57.29578;
   sdm.q[ankle_angle_l].initial_value = -0.90216;
   sdm.q[ankle_angle_l].range_start = -40.00000;
   sdm.q[ankle_angle_l].range_end = 40.00000;
   sdm.q[ankle_angle_l].restraint_func = NULL;
   sdm.q[ankle_angle_l].min_restraint_func = &q_restraint_func[0];
   sdm.q[ankle_angle_l].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[prescribed22].name,"prescribed22");
   sdm.q[prescribed22].type = prescribed_q;
   sdm.q[prescribed22].joint = subtalar_l;
   sdm.q[prescribed22].axis = 0;
   sdm.q[prescribed22].conversion = 57.29578;
   sdm.q[prescribed22].initial_value = 0.00000;
   sdm.q[prescribed22].range_start = -99999.9;
   sdm.q[prescribed22].range_end = 99999.9;
   sdm.q[prescribed22].restraint_func = NULL;
   sdm.q[prescribed22].min_restraint_func = NULL;
   sdm.q[prescribed22].max_restraint_func = NULL;

   mstrcpy(&sdm.q[midfoot_angle_l].name,"midfoot_angle_l");
   sdm.q[midfoot_angle_l].type = unconstrained_q;
   sdm.q[midfoot_angle_l].joint = midfoot_l;
   sdm.q[midfoot_angle_l].axis = 0;
   sdm.q[midfoot_angle_l].conversion = 57.29578;
   sdm.q[midfoot_angle_l].initial_value = 0.00000;
   sdm.q[midfoot_angle_l].range_start = -60.00000;
   sdm.q[midfoot_angle_l].range_end = 60.00000;
   sdm.q[midfoot_angle_l].restraint_func = NULL;
   sdm.q[midfoot_angle_l].min_restraint_func = &q_restraint_func[0];
   sdm.q[midfoot_angle_l].max_restraint_func = &q_restraint_func[0];

   mstrcpy(&sdm.q[mtp_angle_l].name,"mtp_angle_l");
   sdm.q[mtp_angle_l].type = unconstrained_q;
   sdm.q[mtp_angle_l].joint = mtp_l;
   sdm.q[mtp_angle_l].axis = 0;
   sdm.q[mtp_angle_l].conversion = 57.29578;
   sdm.q[mtp_angle_l].initial_value = 30.00000;
   sdm.q[mtp_angle_l].range_start = -60.00000;
   sdm.q[mtp_angle_l].range_end = 60.00000;
   sdm.q[mtp_angle_l].restraint_func = NULL;
   sdm.q[mtp_angle_l].min_restraint_func = &q_restraint_func[0];
   sdm.q[mtp_angle_l].max_restraint_func = &q_restraint_func[0];

   for (i=0, sdm.num_gencoords=0; i<sdm.nq; i++)
      if (sdm.q[i].type == unconstrained_q)
         sdm.num_gencoords++;

}
예제 #9
0
void initialize(void)
{
    int i;
    const char* p;

    add_preprocessor_option(yes, "-I%s", get_preference("RESOURCES_FOLDER"));

    root.numwindows = 0;
    root.messages.line = NULL;

    root.gldesc.max_screen_x = glutGet(GLUT_SCREEN_WIDTH);
    if (root.gldesc.max_screen_x <= 0)
        root.gldesc.max_screen_x = 1024;
    root.gldesc.max_screen_y = glutGet(GLUT_SCREEN_HEIGHT);
    if (root.gldesc.max_screen_y <= 0)
        root.gldesc.max_screen_y = 768;

    root.gldesc.max_screen_x -= 10;
    root.gldesc.max_screen_y -= 30;

    if (is_preference_on(get_preference("MULTIPLE_SCREENS")) == no)
        glueSetConstrainedWindows(yes);
    else
        glueSetConstrainedWindows(no);

    if (is_preference_on(get_preference("MULTIPLE_SCREENS")) == no)
        open_main_window();

    init_global_lighting();

    if (make_selectors() == code_bad)
        error(exit_program,tool_message);

    /* Initialize some root structure variables */
    root.nummodels = 0;
    root.numplots = 0;
    root.numtools = 0;
    root.currentwindow = NO_WINDOW;
    root.modelcount = 0;
    root.confirm_window_open = no;

    root.gfont.defaultfont = SIMM_DEFAULT_FONT;
    root.gfont.largefont   = SIMM_LARGE_FONT;
    root.gfont.smallfont   = SIMM_SMALL_FONT;
    root.gfont.italics     = SIMM_ITALIC_FONT;
    root.gfont.bold        = SIMM_BOLD_FONT;

    /* Set all the plot pointers to NULL */
    for (i=0; i<PLOTBUFFER; i++)
        gPlot[i] = NULL;

    /* Set all the model pointers to NULL */
    for (i=0; i<MODELBUFFER; i++)
        gModel[i] = NULL;

    /* Set all the tool structures to unused */
    for (i=0; i<TOOLBUFFER; i++)
    {
        tool[i].used = no;
        tool[i].name = NULL;
    }

    /* Make the [initially empty] model menu */
    root.modelmenu = -1;
    root.plotmenu = -1;

    root.gravityMenu = glueCreateMenu("Gravity");
    glueAddMenuEntryWithValue(root.gravityMenu, " +X", smX);
    glueAddMenuEntryWithValue(root.gravityMenu, " -X", smNegX);
    glueAddMenuEntryWithValue(root.gravityMenu, " +Y", smY);
    glueAddMenuEntryWithValue(root.gravityMenu, " -Y", smNegY);
    glueAddMenuEntryWithValue(root.gravityMenu, " +Z", smZ);
    glueAddMenuEntryWithValue(root.gravityMenu, " -Z", smNegZ);
    glueAddMenuEntryWithValue(root.gravityMenu, "none", smNoAlign);

    /* Init the command list */
    root.num_commands = 0;
    for (i=0; i<COMMAND_BUFFER; i++)
        root.command[i] = NULL;

    updatemodelmenu();

    /* Call routines to make the color map */
    init_color_database();

    /* Make the confirm-action menu */
    make_confirm_menu();

    /* Malloc the SIMM event queue */
    root.simm_event_queue = (SimmEvent*)simm_malloc(EVENT_QUEUE_SIZE*sizeof(SimmEvent));
    if (root.simm_event_queue == NULL)
        error(exit_program,tool_message);

    root.event_queue_length = EVENT_QUEUE_SIZE;
    root.events_in_queue = 0;
}
예제 #10
0
ReturnCode init_model_display(ModelStruct* ms)
{
    int i;

    ms->dis.motion_speed = DEFAULT_MOTION_SPEED;
    ms->dis.default_view = 0; // the default camera will be cam0 unless overridden by user
    ms->dis.show_highlighted_polygon = no;
    ms->dis.show_selected_coords = no;
    ms->dis.show_all_muscpts = no;
    ms->dis.show_shadow = no;
    ms->dis.applied_motion = NULL;
    ms->dis.current_motion = NULL;
    ms->dis.hpoly.segmentnum = -1;
    ms->dis.hpoly.bonenum = -1;
    ms->dis.hpoly.polynum = -1;
    ms->dis.continuous_motion = no;
    ms->dis.display_motion_info = yes;

    ms->dis.devs = (int*)simm_malloc(ms->numgencoords*2*sizeof(int));
    ms->dis.dev_values = (int*)simm_malloc(ms->numgencoords*2*sizeof(int));
    if (ms->dis.devs == NULL || ms->dis.dev_values == NULL)
        return code_bad;

    for (i=0; i<ms->numgencoords; i++)
    {
        ms->dis.devs[i*2] = ms->gencoord[i]->keys[0];
        ms->dis.devs[i*2+1] = ms->gencoord[i]->keys[1];
    }
    ms->dis.numdevs = ms->numgencoords*2;

    ms->dis.nummuscleson = ms->nummuscles;
    ms->dis.muscle_array_size = ms->muscle_array_size;
    if (ms->dis.muscle_array_size > 0)
    {
        ms->dis.muscleson = (int*)simm_malloc(ms->dis.muscle_array_size*sizeof(int));
        if (ms->dis.muscleson == NULL)
            return code_bad;
    }

    ms->dis.muscle_cylinder_id = -1;

    for (i=0; i<ms->dis.muscle_array_size; i++)
    {
        if (i < ms->nummuscles)
            ms->dis.muscleson[i] = ms->muscle[i]->display;
        else
            ms->dis.muscleson[i] = 0;
    }

    for (i=0; i<COLUMNBUFFER; i++)
        ms->dis.menucolumns[i] = EMPTY;

    for (i=0; i<ms->numgroups; i++)
    {
        ms->dis.mgroup[i].state = off;
        ms->dis.mgroup[i].xo = -1;
        ms->dis.mgroup[i].yo = -1;
    }

    ms->dis.view_menu = 0;
    ms->dis.maindrawmodemenu = 0;
    ms->dis.allsegsdrawmodemenu = 0;
    ms->dis.allligsdrawmodemenu = 0;
    ms->dis.allworlddrawmodemenu = 0;
    ms->dis.alldrawmodemenu = 0;
    ms->dis.eachsegdrawmodemenu = 0;

#if ! ENGINE
    ms->dis.display_motion_info = is_preference_on(get_preference("DISPLAY_MOTION_INFO"));
#endif

    return code_fine;
}
예제 #11
0
/* INITMODEL: this guy initializes much of the model structure.
 */
ReturnCode init_model(ModelStruct* ms)
{
    int i;
    const char *p;
    // ms->modelnum is preset; store it here so you can restore it after memset().
    int model_number = ms->modelnum;

    memset(ms, 0, sizeof(ModelStruct));

    ms->modelnum = model_number;
    ms->is_demo_model = no;
    ms->useIK = yes;
    ms->defaultGCApproved = yes;
    ms->defaultLoopsOK = yes;
    ms->defaultConstraintsOK = yes;
    ms->constraintsOK = yes;
    ms->loopsOK = yes;
    ms->muscle_array_size = MUSCLE_ARRAY_INCREMENT;
    ms->ligament_array_size = MUSCLE_ARRAY_INCREMENT;
    ms->muscgroup_array_size = MUSCGROUP_ARRAY_INCREMENT;
    ms->world_array_size = INIT_WORLD_ARRAY_SIZE;
    ms->genc_array_size = GENC_ARRAY_INCREMENT;
    ms->segment_array_size = SEGMENT_ARRAY_INCREMENT;
    ms->joint_array_size = JOINT_ARRAY_INCREMENT;
    ms->func_array_size = FUNC_ARRAY_INCREMENT;
    ms->specified_min_thickness = yes;
    ms->specified_max_thickness = yes;
    ms->dynamics_ready = no;
    ms->max_diagonal_needs_recalc = yes;
    ms->GEFuncOK = no;
    ms->marker_visibility = yes;
    ms->marker_radius = DEFAULT_MARKER_RADIUS;
    ms->loop_tolerance = DEFAULT_LOOP_TOLERANCE;
    ms->loop_weight = DEFAULT_LOOP_WEIGHT;
    ms->solver.accuracy = DEFAULT_SOLVER_ACCURACY;
    ms->solver.method = smLevenbergMarquart;
    ms->solver.max_iterations = 100;
    ms->solver.joint_limits = smYes;
    ms->solver.orient_body = smNo;
    ms->solver.fg_contact = smNo;
    ms->global_show_masscenter = no;
    ms->global_show_inertia = no;

    ms->gravity = smNegY;

    ms->functionMenu = 0;

    ms->motion_array_size = MOTION_ARRAY_INCREMENT;
    ms->motion = (MotionSequence**)simm_malloc(ms->motion_array_size * sizeof(MotionSequence*));
    if (ms->motion == NULL)
    {
        error(none,"Not enough memory to add another model.");
        return code_bad;
    }
    else
    {
        for (i = 0; i < ms->motion_array_size; i++)
            ms->motion[i] = NULL;
    }


    for (i=0; i<100; i++)
        ms->motionfilename[i] = NULL;
    ms->num_motion_files = 0;

    ms->joint = (JointStruct*)simm_malloc(ms->joint_array_size*sizeof(JointStruct));
    ms->segment = (SegmentStruct*)simm_malloc(ms->segment_array_size*sizeof(SegmentStruct));
    ms->muscgroup = (MuscleGroup*)simm_malloc(ms->muscgroup_array_size*sizeof(MuscleGroup));
    ms->seggroup = NULL;
    ms->gencgroup = NULL;
    ms->gencoord = (GeneralizedCoord**)simm_calloc(ms->genc_array_size, sizeof(GeneralizedCoord*));

    ms->muscle = (dpMuscleStruct**)simm_calloc(ms->muscle_array_size, sizeof(dpMuscleStruct*));

    ms->ligament = (LigamentStruct*)simm_malloc(ms->ligament_array_size*sizeof(LigamentStruct));

    ms->function = (dpFunction**)simm_calloc(ms->func_array_size, sizeof(dpFunction*));

    ms->save.function = (dpFunction**)simm_calloc(ms->func_array_size, sizeof(dpFunction*));

    ms->worldobj = (WorldObject*)simm_malloc(ms->world_array_size*sizeof(WorldObject));

    if (ms->joint == NULL || ms->segment == NULL || ms->muscgroup == NULL ||
            ms->gencoord == NULL || ms->function == NULL ||
            ms->save.function == NULL || ms->worldobj == NULL)
    {
        error(none,"Not enough memory to add another model.");
        return code_bad;
    }

    ms->num_wrap_objects = 0;
    ms->wrap_object_array_size = WRAP_OBJECT_ARRAY_INCREMENT;
    ms->wrapobj = (dpWrapObject**)simm_malloc(ms->wrap_object_array_size*sizeof(dpWrapObject*));
    if (ms->wrapobj == NULL)
    {
        error(none,"Not enough memory to add another wrap object.");
        return code_bad;
    }

//   ms->constraint_tolerance = DEFAULT_CONSTRAINT_TOLERANCE;
    ms->num_constraint_objects = 0;
    ms->constraint_object_array_size = CONSTRAINT_OBJECT_ARRAY_INCREMENT;
    ms->constraintobj = (ConstraintObject*)simm_malloc(ms->constraint_object_array_size*sizeof(ConstraintObject));
    if (ms->constraintobj == NULL)
    {
        error(none,"Not enough memory to add another constraint.");
        return code_bad;
    }

    ms->num_deformities = 0;
    ms->deformity_array_size = DEFORMITY_ARRAY_INCREMENT;
    ms->deformity = (Deformity*) simm_malloc(ms->deformity_array_size * sizeof(Deformity));
    if (ms->deformity == NULL)
    {
        error(none,"Not enough memory to add another deformity object.");
        return code_bad;
    }

    init_materials(ms);

    ms->num_motion_objects = 0;
    ms->motion_objects = NULL;

#if ! ENGINE || OPENSMAC
    add_default_motion_objects(ms);
#endif

    /* This part of the display structure must be initialized here because
     * it can be changed when reading in the joints file, which happens before
     * the display structure is initialized.
     */
    ms->dis.num_file_views = 0;
//   ms->dis.muscle_array_size = 0;//dkb = MUSCLE_ARRAY_INCREMENT;
    ms->dis.muscle_array_size = MUSCLE_ARRAY_INCREMENT;

    ms->dis.fast_muscle_drawing = no;

#if ! ENGINE
    ms->dis.fast_muscle_drawing = is_preference_on(get_preference("FASTER_MUSCLE_DRAWING"));

#if INCLUDE_MSL_LENGTH_COLOR
    ms->dis.muscle_color_factor = 0.0;
#endif

    for (i=0; i<MAXSAVEDVIEWS; i++)
    {
        ms->dis.view_used[i] = no;
        ms->dis.view_name[i] = NULL;
    }

    for (i=0; i<3; i++)
    {
        ms->dis.background_color[i] = 0.2f;
        ms->dis.vertex_label_color[i] = 0.0f;
        ms->dis.rotation_axes_color[i] = 1.0f;
        ms->dis.crosshairs_color[i] = 1.0f;
    }
    ms->dis.rotation_axes_color[2] = 0.0f;
    ms->dis.vertex_label_color[0] = 1.0f;

    ms->dis.background_color_spec = no;
    ms->dis.vertex_label_color_spec = no;
    ms->dis.rotation_axes_color_spec = no;
    ms->dis.crosshairs_color_spec = no;

    ms->modelLock = glutNewMutex();
    ms->realtimeState = rtNotConnected;

#endif /* ENGINE */

    ms->gencoordmenu = -1;
    ms->gencoordmenu2 = -1;
    ms->gencoord_group_menu = -1;
    ms->xvarmenu = -1;
    ms->momentgencmenu = -1;
    ms->momentarmgencmenu = -1;
    ms->momentarmnumgencmenu = -1;
    ms->maxmomentgencmenu = -1;

    return code_fine;
}
예제 #12
0
void make_message_port(void)
{
    IntBox bbox;
    HelpStruct* hp;
    int windex;
    WindowParams mwin;
    WinUnion wun;
    SBoolean iconified;

    hp = &root.messages;

    hp->lines_per_page = 10;
    hp->window_width = 750;
    hp->window_height = 10*HELP_WINDOW_TEXT_Y_SPACING + 4;

    hp->line = (TextLine*)simm_malloc(100*sizeof(TextLine));
    if (hp->line == NULL)
        error(exit_program,tool_message);

    hp->num_lines_malloced = 100;
    hp->num_lines = 0;
    hp->starting_line = 0;
    hp->background_color = HELP_WINDOW_BACKGROUND;

    bbox.x2 = hp->window_width;
    bbox.x1 = bbox.x2 - 20;
    bbox.y2 = hp->window_height;
    bbox.y1 = 0;

    make_slider(&hp->sl,vertical_slider,bbox,0,(double)(hp->num_lines)*20.0,
                (double)(hp->lines_per_page)*20.0,(double)(hp->num_lines)*20.0,4.0,NULL,NULL);
    glueSetWindowPlacement(GLUT_NORMAL_WINDOW, GLUE_SOUTHWEST,
                           hp->window_width, hp->window_height,
                           0, 0, NULL);

#if defined WIN32 && SIMM_DEMO_VERSION
    iconified = is_in_demo_mode();
#else
    iconified = no;
#endif
    mwin.id = hp->window_id = glueOpenWindow("simmmess",iconified,GLUE_TOOL_WINDOW);

    glueSetWindowMinSize(500,100);
    mstrcpy(&mwin.name,"SIMM Messages");
    glutSetIconTitle("Messages");
    glutSetWindowTitle(mwin.name);

    wun.tool = NULL;

    windex = add_window(&mwin,&wun,NOTYPE,ZERO,no,draw_message_window,
                        update_message_window,messages_input);
    if (windex == -1)
        error(exit_program,tool_message);

    glutSetWindowData(mwin.id, windex);

    if (expirationMessage)
    {
        error(none, expirationMessage);

        FREE_IFNOTNULL(expirationMessage);
    }
}
예제 #13
0
ReturnCode makegencform(ModelStruct* ms)
{

   int i, name_len;
   Form* form;
   CheckBoxPanel* check;

   form = &ms->gencform;
   form->numoptions = ms->numgencoords;
   form->selected_item = -1;
   form->cursor_position = 0;
   form->highlight_start = 0;
   form->title = NULL;

   ms->longest_genc_name = 0;

   form->option = (FormItem*)simm_malloc(form->numoptions*sizeof(FormItem));
   if (form->option == NULL)
      return code_bad;

   for (i=0; i<form->numoptions; i++)
   {
      form->option[i].justify = yes;
      form->option[i].active = yes;
      form->option[i].visible = yes;
      form->option[i].editable = yes;
      form->option[i].use_alternate_colors = no;
      form->option[i].decimal_places = 3;
      form->option[i].data = NULL;
      mstrcpy(&form->option[i].name, ms->gencoord[i]->name);
      name_len = glueGetStringWidth(root.gfont.defaultfont, ms->gencoord[i]->name);
      if (name_len > ms->longest_genc_name)
         ms->longest_genc_name = name_len;
      SET_BOX1221(form->option[i].box,0,75,-FORM_FIELD_YSPACING*i,
         form->option[i].box.y2-FORM_FIELD_HEIGHT);
   }

   /* make the gencoord checkbox panel */
   check = &ms->gc_chpanel;
   check->title = "C";
   check->type = normal_checkbox;
   check->numoptions = ms->numgencoords;
   check->checkbox = (CheckBox*)simm_malloc(check->numoptions*sizeof(CheckBox));
   if (check->checkbox == NULL)
      error(exit_program,tool_message);

   for (i=0; i<check->numoptions; i++)
   {
      check->checkbox[i].just = right;
      check->checkbox[i].active = yes;
      check->checkbox[i].visible = yes;
      if (ms->gencoord[i]->clamped == no)
	 check->checkbox[i].state = off;
      else
	 check->checkbox[i].state = on;
      check->checkbox[i].name = NULL;
      check->checkbox[i].box.x1 = form->option[i].box.x1;
      check->checkbox[i].box.x2 = check->checkbox[i].box.x1 + CHECKBOX_XSIZE*2/3;
      check->checkbox[i].box.y1 = form->option[i].box.y1;
      check->checkbox[i].box.y2 = check->checkbox[i].box.y1 + CHECKBOX_YSIZE*2/3;
      check->checkbox[i].use_alternate_colors = no;
   }

   /* make the gencoord lock checkbox panel */
   check = &ms->gc_lockPanel;
   check->title = "L"; //NULL;
   check->type = normal_checkbox;
   check->numoptions = ms->numgencoords;
   check->checkbox = (CheckBox*)simm_malloc(check->numoptions*sizeof(CheckBox));
   if (check->checkbox == NULL)
      error(exit_program,tool_message);

   for (i=0; i<check->numoptions; i++)
   {
      check->checkbox[i].just = right;
      check->checkbox[i].active = yes;
      check->checkbox[i].visible = yes;
      if (ms->gencoord[i]->locked == no)
	      check->checkbox[i].state = off;
      else
	      check->checkbox[i].state = on;
      check->checkbox[i].name = NULL;
      check->checkbox[i].box.x1 = form->option[i].box.x1;
      check->checkbox[i].box.x2 = check->checkbox[i].box.x1 + CHECKBOX_XSIZE*2/3;
      check->checkbox[i].box.y1 = form->option[i].box.y1;
      check->checkbox[i].box.y2 = check->checkbox[i].box.y1 + CHECKBOX_YSIZE*2/3;
   }

   return code_fine;

}