forked from openigtlink/MatlabIGTL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathigtlclose.cpp
87 lines (60 loc) · 2.18 KB
/
igtlclose.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*=========================================================================
Program: Matlab Open IGT Link Interface -- igtlsend
Module: $RCSfile: $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) Insight Software Consortium. All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
//
// igtlclose(SD);
//
// SD : (integer) Socket descriptor (-1 if failed to connect)
//
#include "mex.h"
#include <math.h>
#include "igtlOSUtil.h"
#include "igtlImageMessage.h"
#include "igtlMexClientSocket.h"
using namespace std;
//#define pi (3.141592653589793)
#define ARG_ID_SD 0 // socket descriptor
#define ARG_ID_NUM 1 // total number of arguments
#define MAX_STRING_LEN 256
//extern void _main();
// -----------------------------------------------------------------
// Function declarations.
double& createMatlabScalar (mxArray*& ptr);
// -----------------------------------------------------------------
// Function definitions.
void mexFunction (int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]) {
// ---------------------------------------------------------------
// Check numbers of arguments and outputs
if (nrhs != ARG_ID_NUM)
{
mexErrMsgTxt("Incorrect number of input arguments");
}
//if (nlhs != 1)
// {
// mexErrMsgTxt("Incorrect number of output arguments");
// }
// ---------------------------------------------------------------
// Check types of arguments
if (!mxIsNumeric(prhs[ARG_ID_SD]))
{
mexErrMsgTxt("PORT argument must be integer.");
}
// ---------------------------------------------------------------
// Set variable
int sd = (int)*mxGetPr(prhs[ARG_ID_SD]);
// ---------------------------------------------------------------
// Set up OpenIGTLink Connection
igtl::MexClientSocket::Pointer socket;
socket = igtl::MexClientSocket::New();
int r = socket->SetDescriptor(sd);
socket->CloseSocket();
}