Subversion Repositories seema-scanner

Rev

Rev 1 | Rev 28 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 3
Line 5... Line 5...
5
#define printf mexPrintf
5
#define printf mexPrintf
6
 
6
 
7
 
7
 
8
// The class that we are interfacing to
8
// The class that we are interfacing to
9
#include "Projector.h"
9
#include "Projector.h"
-
 
10
#include "ProjectorOpenGL.h"
-
 
11
#include "OpenGLContext.h"
10
 
12
 
11
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
13
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
12
{	
14
{	
13
    // Get the command string
15
    // Get the command string
14
    char cmd[64];
16
    char cmd[64];
Line 18... Line 20...
18
    // Static methods
20
    // Static methods
19
    // DisplayInfo
21
    // DisplayInfo
20
    if (!strcmp("GetScreenInfo", cmd)) {
22
    if (!strcmp("GetScreenInfo", cmd)) {
21
        // Call the method
23
        // Call the method
22
        std::vector<ScreenInfo> screenInfo;
24
        std::vector<ScreenInfo> screenInfo;
23
        screenInfo = Projector::GetScreenInfo();
25
        screenInfo = OpenGLContext::GetScreenInfo();
24
        const char* fieldNames[] = {"screenNum","resX","resY"};
26
        const char* fieldNames[] = {"screenNum","resX","resY"};
25
        plhs[0] = mxCreateStructMatrix(1, screenInfo.size(), 3, fieldNames);
27
        plhs[0] = mxCreateStructMatrix(1, screenInfo.size(), 3, fieldNames);
26
        for (unsigned int i=0; i<screenInfo.size(); i++) {
28
        for (unsigned int i=0; i<screenInfo.size(); i++) {
27
            mxSetFieldByNumber(plhs[0], i, 0, mxCreateDoubleScalar(i));
29
            mxSetFieldByNumber(plhs[0], i, 0, mxCreateDoubleScalar(i));
28
            mxSetFieldByNumber(plhs[0], i, 1, mxCreateDoubleScalar(screenInfo[i].resX));
30
            mxSetFieldByNumber(plhs[0], i, 1, mxCreateDoubleScalar(screenInfo[i].resX));
Line 38... Line 40...
38
            mexErrMsgTxt("New: One output expected.");
40
            mexErrMsgTxt("New: One output expected.");
39
        if (nrhs < 2)
41
        if (nrhs < 2)
40
            mexErrMsgTxt("New: Expected screen number argument.");
42
            mexErrMsgTxt("New: Expected screen number argument.");
41
        unsigned int screenNum = (unsigned int)mxGetScalar(prhs[1]);
43
        unsigned int screenNum = (unsigned int)mxGetScalar(prhs[1]);
42
        // Return a handle to a new C++ instance
44
        // Return a handle to a new C++ instance
43
        plhs[0] = convertPtr2Mat<Projector>(new Projector(screenNum));
45
        plhs[0] = convertPtr2Mat<ProjectorOpenGL>(new ProjectorOpenGL(screenNum));
44
        return;
46
        return;
45
    }
47
    }
46
    
48
    
47
    // Check if there is a second input, which should be the class instance handle
49
    // Check if there is a second input, which should be the class instance handle
48
    if (nrhs < 2)
50
    if (nrhs < 2)
Line 72... Line 74...
72
        unsigned int width = (unsigned int)mxGetScalar(prhs[3]);
74
        unsigned int width = (unsigned int)mxGetScalar(prhs[3]);
73
        unsigned int height = (unsigned int)mxGetScalar(prhs[4]);
75
        unsigned int height = (unsigned int)mxGetScalar(prhs[4]);
74
        Projector_instance->displayTexture(tex, width, height);
76
        Projector_instance->displayTexture(tex, width, height);
75
        return;
77
        return;
76
    }
78
    }
77
    // SetGamma
-
 
78
    if (!strcmp("SetGamma", cmd)) {
-
 
79
        // Check parameters
-
 
80
        if (nlhs < 0 || nrhs < 2)
-
 
81
            mexErrMsgTxt("SetGamma: Unexpected arguments.");
-
 
82
        // Call the method
-
 
83
        float gamma = (float)mxGetScalar(prhs[2]);
-
 
84
        Projector_instance->setGamma(gamma);
-
 
85
        return;
-
 
86
    }
-
 
87
   // DisplayWhite
79
   // DisplayWhite
88
   if (!strcmp("displayWhite", cmd)) {
80
   if (!strcmp("displayWhite", cmd)) {
89
       // Check parameters
81
       // Check parameters
90
       if (nlhs < 0 || nrhs < 1)
82
       if (nlhs < 0 || nrhs < 1)
91
           mexErrMsgTxt("Test: Unexpected arguments.");
83
           mexErrMsgTxt("Test: Unexpected arguments.");