#### File: _coder_MLS_getDeform_api.c
        1   /*
        2    * _coder_MLS_getDeform_api.c
        3    *
        4    * Code generation for function '_coder_MLS_getDeform_api'
        5    *
        6    */
        7
        8   /* Include files */
        9   #include "rt_nonfinite.h"
       10   #include "MLS_getDeform.h"
       11   #include "_coder_MLS_getDeform_api.h"
       12   #include "MLS_getDeform_emxutil.h"
       13   #include "MLS_getDeform_mexutil.h"
       14   #include "MLS_getDeform_data.h"
       15
       16   /* Variable Definitions */
       17   static emlrtRTEInfo g_emlrtRTEI = { 1, /* lineNo */
       18     1,                                   /* colNo */
       19     "_coder_MLS_getDeform_api",          /* fName */
       20     ""                                   /* pName */
       21   };
       22
       23   /* Function Declarations */
       24   static const mxArray *b_emlrt_marshallOut(const emlrtStack *sp, const struct0_T
       25     u);
       26   static void c_emlrt_marshallIn(const emlrtStack *sp, const mxArray
       27     *control_points, const char_T *identifier, emxArray_real_T *y);
       28   static const mxArray *c_emlrt_marshallOut(const emxArray_real_T *u);
       29   static void d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       30     emlrtMsgIdentifier *parentId, emxArray_real_T *y);
       31   static void e_emlrt_marshallIn(const emlrtStack *sp, const mxArray *type, const
       32     char_T *identifier, emxArray_char_T *y);
       33   static const mxArray *emlrt_marshallOut(const emxArray_real_T *u);
       34   static void f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       35     emlrtMsgIdentifier *parentId, emxArray_char_T *y);
       36   static void g_emlrt_marshallIn(const emlrtStack *sp, const mxArray *precomputed,
       37     const char_T *identifier, struct0_T *y);
       38   static void h_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       39     emlrtMsgIdentifier *parentId, struct0_T *y);
       40   static void i_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       41     emlrtMsgIdentifier *parentId, emxArray_real_T *y);
       42   static void j_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       43     emlrtMsgIdentifier *parentId, emxArray_real_T *y);
       44   static void k_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       45     emlrtMsgIdentifier *parentId, emxArray_real_T *y);
       46   static real_T (*l_emlrt_marshallIn(const emlrtStack *sp, const mxArray
       47     *size_of_img, const char_T *identifier))[2];
       48   static real_T (*m_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
       49     emlrtMsgIdentifier *parentId))[2];
       50   static void o_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
       51     emlrtMsgIdentifier *msgId, emxArray_real_T *ret);
       52   static void p_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
       53     emlrtMsgIdentifier *msgId, emxArray_char_T *ret);
       54   static void q_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
       55     emlrtMsgIdentifier *msgId, emxArray_real_T *ret);
       56   static void r_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
       57     emlrtMsgIdentifier *msgId, emxArray_real_T *ret);
       58   static void s_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
       59     emlrtMsgIdentifier *msgId, emxArray_real_T *ret);
       60   static real_T (*t_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
       61     const emlrtMsgIdentifier *msgId))[2];
       62
       63   /* Function Definitions */
       64   static const mxArray *b_emlrt_marshallOut(const emlrtStack *sp, const struct0_T
       65     u)
       66   {
       67     const mxArray *y;
       68     emxArray_real_T *b_u;
       69     static const char * sv0[6] = { "w_i", "sum_w_i", "p_ast", "Similarity",
       70       "Affine", "Rigid" };
       71
       72     int32_T i2;
       73     int32_T loop_ub;
       74     const mxArray *b_y;
       75     const mxArray *m3;
       76     real_T *pData;
       77     emxArray_real_T *c_u;
       78     int32_T i;
       79     emlrtHeapReferenceStackEnterFcnR2012b(sp);
       80     emxInit_real_T2(sp, &b_u, 1, (emlrtRTEInfo *)NULL, true);
       81     y = NULL;
       82     emlrtAssign(&y, emlrtCreateStructMatrix(1, 1, 6, sv0));
       83     emlrtSetFieldR2017b(y, 0, "w_i", c_emlrt_marshallOut(u.w_i), 0);
       84     i2 = b_u->size[0];
       85     b_u->size[0] = u.sum_w_i->size[0];
       86     emxEnsureCapacity_real_T1(sp, b_u, i2, (emlrtRTEInfo *)NULL);
       87     loop_ub = u.sum_w_i->size[0];
       88     for (i2 = 0; i2 < loop_ub; i2++) {
       89       b_u->data[i2] = u.sum_w_i->data[i2];
       90     }
       91
       92     b_y = NULL;
       93     m3 = emlrtCreateNumericArray(1, *(int32_T (*)[3])b_u->size, mxDOUBLE_CLASS,
       94       mxREAL);
       95     pData = (real_T *)emlrtMxGetPr(m3);
       96     i2 = 0;
       97     loop_ub = 0;
       98     emxFree_real_T(&b_u);
       99     while (loop_ub < u.sum_w_i->size[0]) {
      100       pData[i2] = u.sum_w_i->data[loop_ub];
      101       i2++;
      102       loop_ub++;
      103     }
      104
      105     emxInit_real_T1(sp, &c_u, 2, (emlrtRTEInfo *)NULL, true);
      106     emlrtAssign(&b_y, m3);
      107     emlrtSetFieldR2017b(y, 0, "sum_w_i", b_y, 1);
      108     i2 = c_u->size[0] * c_u->size[1];
      109     c_u->size[0] = u.p_ast->size[0];
      110     c_u->size[1] = 2;
      111     emxEnsureCapacity_real_T(sp, c_u, i2, (emlrtRTEInfo *)NULL);
      112     loop_ub = u.p_ast->size[0] * u.p_ast->size[1];
      113     for (i2 = 0; i2 < loop_ub; i2++) {
      114       c_u->data[i2] = u.p_ast->data[i2];
      115     }
      116
      117     b_y = NULL;
      118     m3 = emlrtCreateNumericArray(2, *(int32_T (*)[3])c_u->size, mxDOUBLE_CLASS,
      119       mxREAL);
      120     pData = (real_T *)emlrtMxGetPr(m3);
      121     i2 = 0;
      122     emxFree_real_T(&c_u);
      123     for (loop_ub = 0; loop_ub < 2; loop_ub++) {
      124       for (i = 0; i < u.p_ast->size[0]; i++) {
      125         pData[i2] = u.p_ast->data[i + u.p_ast->size[0] * loop_ub];
      126         i2++;
      127       }
      128     }
      129
      130     emlrtAssign(&b_y, m3);
      131     emlrtSetFieldR2017b(y, 0, "p_ast", b_y, 2);
      132     emlrtSetFieldR2017b(y, 0, "Similarity", c_emlrt_marshallOut(u.Similarity), 3);
      133     emlrtSetFieldR2017b(y, 0, "Affine", c_emlrt_marshallOut(u.Affine), 4);
      134     emlrtSetFieldR2017b(y, 0, "Rigid", c_emlrt_marshallOut(u.Rigid), 5);
      135     emlrtHeapReferenceStackLeaveFcnR2012b(sp);
      136     return y;
      137   }
      138
      139   static void c_emlrt_marshallIn(const emlrtStack *sp, const mxArray
      140     *control_points, const char_T *identifier, emxArray_real_T *y)
      141   {
      142     emlrtMsgIdentifier thisId;
      143     thisId.fIdentifier = (const char *)identifier;
      144     thisId.fParent = NULL;
      145     thisId.bParentIsCell = false;
      146     d_emlrt_marshallIn(sp, emlrtAlias(control_points), &thisId, y);
      147     emlrtDestroyArray(&control_points);
      148   }
      149
      150   static const mxArray *c_emlrt_marshallOut(const emxArray_real_T *u)
      151   {
      152     const mxArray *y;
      153     const mxArray *m4;
      154     real_T *pData;
      155     int32_T i3;
      156     int32_T i;
      157     int32_T b_i;
      158     y = NULL;
      159     m4 = emlrtCreateNumericArray(2, *(int32_T (*)[3])u->size, mxDOUBLE_CLASS,
      160       mxREAL);
      161     pData = (real_T *)emlrtMxGetPr(m4);
      162     i3 = 0;
      163     for (i = 0; i < u->size[1]; i++) {
      164       for (b_i = 0; b_i < u->size[0]; b_i++) {
      165         pData[i3] = u->data[b_i + u->size[0] * i];
      166         i3++;
      167       }
      168     }
      169
      170     emlrtAssign(&y, m4);
      171     return y;
      172   }
      173
      174   static void d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
      175     emlrtMsgIdentifier *parentId, emxArray_real_T *y)
      176   {
      177     o_emlrt_marshallIn(sp, emlrtAlias(u), parentId, y);
      178     emlrtDestroyArray(&u);
      179   }
      180
      181   static void e_emlrt_marshallIn(const emlrtStack *sp, const mxArray *type, const
      182     char_T *identifier, emxArray_char_T *y)
      183   {
      184     emlrtMsgIdentifier thisId;
      185     thisId.fIdentifier = (const char *)identifier;
      186     thisId.fParent = NULL;
      187     thisId.bParentIsCell = false;
      188     f_emlrt_marshallIn(sp, emlrtAlias(type), &thisId, y);
      189     emlrtDestroyArray(&type);
      190   }
      191
      192   static const mxArray *emlrt_marshallOut(const emxArray_real_T *u)
      193   {
      194     const mxArray *y;
      195     const mxArray *m2;
      196     static const int32_T iv3[3] = { 0, 0, 0 };
      197
      198     y = NULL;
      199     m2 = emlrtCreateNumericArray(3, iv3, mxDOUBLE_CLASS, mxREAL);
      200     emlrtMxSetData((mxArray *)m2, (void *)&u->data[0]);
      201     emlrtSetDimensions((mxArray *)m2, u->size, 3);
      202     emlrtAssign(&y, m2);
      203     return y;
      204   }
      205
      206   static void f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
      207     emlrtMsgIdentifier *parentId, emxArray_char_T *y)
      208   {
      209     p_emlrt_marshallIn(sp, emlrtAlias(u), parentId, y);
      210     emlrtDestroyArray(&u);
      211   }
      212
      213   static void g_emlrt_marshallIn(const emlrtStack *sp, const mxArray *precomputed,
      214     const char_T *identifier, struct0_T *y)
      215   {
      216     emlrtMsgIdentifier thisId;
      217     thisId.fIdentifier = (const char *)identifier;
      218     thisId.fParent = NULL;
      219     thisId.bParentIsCell = false;
      220     h_emlrt_marshallIn(sp, emlrtAlias(precomputed), &thisId, y);
      221     emlrtDestroyArray(&precomputed);
      222   }
      223
      224   static void h_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
      225     emlrtMsgIdentifier *parentId, struct0_T *y)
      226   {
      227     emlrtMsgIdentifier thisId;
      228     static const char * fieldNames[6] = { "w_i", "sum_w_i", "p_ast", "Similarity",
      229       "Affine", "Rigid" };
      230
      231     static const int32_T dims = 0;
      232     thisId.fParent = parentId;
      233     thisId.bParentIsCell = false;
      234     emlrtCheckStructR2012b(sp, parentId, u, 6, fieldNames, 0U, &dims);
      235     thisId.fIdentifier = "w_i";
      236     i_emlrt_marshallIn(sp, emlrtAlias(emlrtGetFieldR2017b(sp, u, 0, 0, "w_i")),
      237                        &thisId, y->w_i);
      238     thisId.fIdentifier = "sum_w_i";
      239     j_emlrt_marshallIn(sp, emlrtAlias(emlrtGetFieldR2017b(sp, u, 0, 1, "sum_w_i")),
      240                        &thisId, y->sum_w_i);
      241     thisId.fIdentifier = "p_ast";
      242     k_emlrt_marshallIn(sp, emlrtAlias(emlrtGetFieldR2017b(sp, u, 0, 2, "p_ast")),
      243                        &thisId, y->p_ast);
      244     thisId.fIdentifier = "Similarity";
      245     i_emlrt_marshallIn(sp, emlrtAlias(emlrtGetFieldR2017b(sp, u, 0, 3,
      246       "Similarity")), &thisId, y->Similarity);
      247     thisId.fIdentifier = "Affine";
      248     i_emlrt_marshallIn(sp, emlrtAlias(emlrtGetFieldR2017b(sp, u, 0, 4, "Affine")),
      249                        &thisId, y->Affine);
      250     thisId.fIdentifier = "Rigid";
      251     i_emlrt_marshallIn(sp, emlrtAlias(emlrtGetFieldR2017b(sp, u, 0, 5, "Rigid")),
      252                        &thisId, y->Rigid);
      253     emlrtDestroyArray(&u);
      254   }
      255
      256   static void i_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
      257     emlrtMsgIdentifier *parentId, emxArray_real_T *y)
      258   {
      259     q_emlrt_marshallIn(sp, emlrtAlias(u), parentId, y);
      260     emlrtDestroyArray(&u);
      261   }
      262
      263   static void j_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
      264     emlrtMsgIdentifier *parentId, emxArray_real_T *y)
      265   {
      266     r_emlrt_marshallIn(sp, emlrtAlias(u), parentId, y);
      267     emlrtDestroyArray(&u);
      268   }
      269
      270   static void k_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
      271     emlrtMsgIdentifier *parentId, emxArray_real_T *y)
      272   {
      273     s_emlrt_marshallIn(sp, emlrtAlias(u), parentId, y);
      274     emlrtDestroyArray(&u);
      275   }
      276
      277   static real_T (*l_emlrt_marshallIn(const emlrtStack *sp, const mxArray
      278     *size_of_img, const char_T *identifier))[2]
      279   {
      280     real_T (*y)[2];
      281     emlrtMsgIdentifier thisId;
      282     thisId.fIdentifier = (const char *)identifier;
      283     thisId.fParent = NULL;
      284     thisId.bParentIsCell = false;
      285     y = m_emlrt_marshallIn(sp, emlrtAlias(size_of_img), &thisId);
      286     emlrtDestroyArray(&size_of_img);
      287     return y;
      288   }
      289     static real_T (*m_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u,
      290     const emlrtMsgIdentifier *parentId))[2]
      291   {
      292     real_T (*y)[2];
      293     y = t_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
      294     emlrtDestroyArray(&u);
      295     return y;
      296   }
      297
      298   static void o_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
      299     emlrtMsgIdentifier *msgId, emxArray_real_T *ret)
      300   {
      301     static const int32_T dims[2] = { -1, 2 };
      302
      303     const boolean_T bv0[2] = { true, false };
      304
      305     int32_T iv4[2];
      306     emlrtCheckVsBuiltInR2012b(sp, msgId, src, "double", false, 2U, dims, &bv0[0],
      307       iv4);
      308     ret->size[0] = iv4[0];
      309     ret->size[1] = iv4[1];
      310     ret->allocatedSize = ret->size[0] * ret->size[1];
      311     ret->data = (real_T *)emlrtMxGetData(src);
      312     ret->canFreeData = false;
      313     emlrtDestroyArray(&src);
      314   }
      315
      316   static void p_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
      317     emlrtMsgIdentifier *msgId, emxArray_char_T *ret)
      318   {
      319     static const int32_T dims[2] = { 1, -1 };
      320
      321     const boolean_T bv1[2] = { false, true };
      322
      323     int32_T iv5[2];
      324     int32_T i4;
      325     emlrtCheckVsBuiltInR2012b(sp, msgId, src, "char", false, 2U, dims, &bv1[0],
      326       iv5);
      327     i4 = ret->size[0] * ret->size[1];
      328     ret->size[0] = iv5[0];
      329     ret->size[1] = iv5[1];
      330     emxEnsureCapacity_char_T(sp, ret, i4, (emlrtRTEInfo *)NULL);
      331     emlrtImportArrayR2015b(sp, src, ret->data, 1, false);
      332     emlrtDestroyArray(&src);
      333   }
      334
      335   static void q_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
      336     emlrtMsgIdentifier *msgId, emxArray_real_T *ret)
      337   {
      338     static const int32_T dims[2] = { -1, -1 };
      339
      340     const boolean_T bv2[2] = { true, true };
      341
      342     int32_T iv6[2];
      343     int32_T i5;
      344     emlrtCheckVsBuiltInR2012b(sp, msgId, src, "double", false, 2U, dims, &bv2[0],
      345       iv6);
      346     i5 = ret->size[0] * ret->size[1];
      347     ret->size[0] = iv6[0];
      348     ret->size[1] = iv6[1];
      349     emxEnsureCapacity_real_T(sp, ret, i5, (emlrtRTEInfo *)NULL);
      350     emlrtImportArrayR2015b(sp, src, ret->data, 8, false);
      351     emlrtDestroyArray(&src);
      352   }
      353
      354   static void r_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
      355     emlrtMsgIdentifier *msgId, emxArray_real_T *ret)
      356   {
      357     static const int32_T dims[1] = { -1 };
      358
      359     const boolean_T bv3[1] = { true };
      360
      361     int32_T iv7[1];
      362     int32_T i6;
      363     emlrtCheckVsBuiltInR2012b(sp, msgId, src, "double", false, 1U, dims, &bv3[0],
      364       iv7);
      365     i6 = ret->size[0];
      366     ret->size[0] = iv7[0];
      367     emxEnsureCapacity_real_T1(sp, ret, i6, (emlrtRTEInfo *)NULL);
      368     emlrtImportArrayR2015b(sp, src, ret->data, 8, false);
      369     emlrtDestroyArray(&src);
      370   }
      371
      372   static void s_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
      373     emlrtMsgIdentifier *msgId, emxArray_real_T *ret)
      374   {
      375     static const int32_T dims[2] = { -1, 2 };
      376
      377     const boolean_T bv4[2] = { true, false };
      378
      379     int32_T iv8[2];
      380     int32_T i7;
      381     emlrtCheckVsBuiltInR2012b(sp, msgId, src, "double", false, 2U, dims, &bv4[0],
      382       iv8);
      383     i7 = ret->size[0] * ret->size[1];
      384     ret->size[0] = iv8[0];
      385     ret->size[1] = iv8[1];
      386     emxEnsureCapacity_real_T(sp, ret, i7, (emlrtRTEInfo *)NULL);
      387     emlrtImportArrayR2015b(sp, src, ret->data, 8, false);
      388     emlrtDestroyArray(&src);
      389   }
      390
      391   static real_T (*t_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
      392     const emlrtMsgIdentifier *msgId))[2]
      393   {
      394     real_T (*ret)[2];
      395     static const int32_T dims[2] = { 1, 2 };
      396
      397     emlrtCheckBuiltInR2012b(sp, msgId, src, "double", false, 2U, dims);
      398     ret = (real_T (*)[2])emlrtMxGetData(src);
      399     emlrtDestroyArray(&src);
      400     return ret;
      401   }
      402     void MLS_getDeform_api(const mxArray * const prhs[7], const mxArray *plhs[2])
      403   {
      404     emxArray_real_T *control_points;
      405     emxArray_real_T *c_deformed_position_of_control_;
      406     emxArray_real_T *points_of_evaluation;
      407     emxArray_char_T *type;
      408     struct0_T precomputed;
      409     emxArray_real_T *f;
      410     struct0_T pre;
      411     real_T alpha;
      412     real_T (*size_of_img)[2];
      413     emlrtStack st = { NULL,              /* site */
      414       NULL,                              /* tls */
      415       NULL                               /* prev */
      416     };
      417
      418     st.tls = emlrtRootTLSGlobal;
      419     emlrtHeapReferenceStackEnterFcnR2012b(&st);
      420     emxInit_real_T1(&st, &control_points, 2, &g_emlrtRTEI, true);
      421     emxInit_real_T1(&st, &c_deformed_position_of_control_, 2, &g_emlrtRTEI, true);
      422     emxInit_real_T1(&st, &points_of_evaluation, 2, &g_emlrtRTEI, true);
      423     emxInit_char_T(&st, &type, 2, &g_emlrtRTEI, true);
      424     emxInitStruct_struct0_T(&st, &precomputed, &g_emlrtRTEI, true);
      425     emxInit_real_T(&st, &f, 3, &g_emlrtRTEI, true);
      426     emxInitStruct_struct0_T(&st, &pre, &g_emlrtRTEI, true);
      427
      428     /* Marshall function inputs */
      429     c_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "control_points", control_points);
      430     c_emlrt_marshallIn(&st, emlrtAlias(prhs[1]),
      431                        "deformed_position_of_control_points",
      432                        c_deformed_position_of_control_);
      433     c_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "points_of_evaluation",
      434                        points_of_evaluation);
      435     alpha = emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "alpha");
      436     e_emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "type", type);
      437     g_emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "precomputed", &precomputed);
      438     size_of_img = l_emlrt_marshallIn(&st, emlrtAlias(prhs[6]), "size_of_img");
      439
      440     /* Invoke the target function */
      441     MLS_getDeform(&st, control_points, c_deformed_position_of_control_,
      442                   points_of_evaluation, alpha, type, &precomputed, *size_of_img, f,
      443                   &pre);
      444
      445     /* Marshall function outputs */
      446     plhs[0] = emlrt_marshallOut(f);
      447     plhs[1] = b_emlrt_marshallOut(&st, pre);
      448     emxFreeStruct_struct0_T(&pre);
      449     f->canFreeData = false;
      450     emxFree_real_T(&f);
      451     emxFreeStruct_struct0_T(&precomputed);
      452     emxFree_char_T(&type);
      453     points_of_evaluation->canFreeData = false;
      454     emxFree_real_T(&points_of_evaluation);
      455     c_deformed_position_of_control_->canFreeData = false;
      456     emxFree_real_T(&c_deformed_position_of_control_);
      457     control_points->canFreeData = false;
      458     emxFree_real_T(&control_points);
      459     emlrtHeapReferenceStackLeaveFcnR2012b(&st);
      460   }
      461
      462   /* End of code generation (_coder_MLS_getDeform_api.c) */
      463