geometry_wrapper.cpp
Go to the documentation of this file.
1 #include <gtwrap/matlab.h>
2 #include <map>
3 
4 #include <boost/archive/text_iarchive.hpp>
5 #include <boost/archive/text_oarchive.hpp>
6 #include <boost/serialization/export.hpp>
7 
10 
11 
14 
15 typedef std::set<std::shared_ptr<gtsam::Point2>*> Collector_gtsamPoint2;
17 typedef std::set<std::shared_ptr<gtsam::Point3>*> Collector_gtsamPoint3;
19 
20 
22 {
23  mstream mout;
24  std::streambuf *outbuf = std::cout.rdbuf(&mout);
25 
26  bool anyDeleted = false;
27  { for(Collector_gtsamPoint2::iterator iter = collector_gtsamPoint2.begin();
28  iter != collector_gtsamPoint2.end(); ) {
29  delete *iter;
30  collector_gtsamPoint2.erase(iter++);
31  anyDeleted = true;
32  } }
33  { for(Collector_gtsamPoint3::iterator iter = collector_gtsamPoint3.begin();
34  iter != collector_gtsamPoint3.end(); ) {
35  delete *iter;
36  collector_gtsamPoint3.erase(iter++);
37  anyDeleted = true;
38  } }
39 
40  if(anyDeleted)
41  cout <<
42  "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n"
43  "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n"
44  "module, so that your recompiled module is used instead of the old one." << endl;
45  std::cout.rdbuf(outbuf);
46 }
47 
49  const mxArray *alreadyCreated = mexGetVariablePtr("global", "gtsam_geometry_rttiRegistry_created");
50  if(!alreadyCreated) {
51  std::map<std::string, std::string> types;
52 
53 
54 
55  mxArray *registry = mexGetVariable("global", "gtsamwrap_rttiRegistry");
56  if(!registry)
57  registry = mxCreateStructMatrix(1, 1, 0, NULL);
58  typedef std::pair<std::string, std::string> StringPair;
59  for(const StringPair& rtti_matlab: types) {
60  int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
61  if(fieldId < 0) {
62  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
63  }
64  mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
65  mxSetFieldByNumber(registry, 0, fieldId, matlabName);
66  }
67  if(mexPutVariable("global", "gtsamwrap_rttiRegistry", registry) != 0) {
68  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
69  }
70  mxDestroyArray(registry);
71 
72  mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
73  if(mexPutVariable("global", "gtsam_geometry_rttiRegistry_created", newAlreadyCreated) != 0) {
74  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
75  }
76  mxDestroyArray(newAlreadyCreated);
77  }
78 }
79 
80 void gtsamPoint2_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
81 {
82  mexAtExit(&_deleteAllObjects);
83  typedef std::shared_ptr<gtsam::Point2> Shared;
84 
85  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
86  collector_gtsamPoint2.insert(self);
87 }
88 
89 void gtsamPoint2_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
90 {
91  mexAtExit(&_deleteAllObjects);
92  typedef std::shared_ptr<gtsam::Point2> Shared;
93 
94  Shared *self = new Shared(new gtsam::Point2());
95  collector_gtsamPoint2.insert(self);
96  out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
97  *reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
98 }
99 
100 void gtsamPoint2_constructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
101 {
102  mexAtExit(&_deleteAllObjects);
103  typedef std::shared_ptr<gtsam::Point2> Shared;
104 
105  double x = unwrap< double >(in[0]);
106  double y = unwrap< double >(in[1]);
107  Shared *self = new Shared(new gtsam::Point2(x,y));
108  collector_gtsamPoint2.insert(self);
109  out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
110  *reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
111 }
112 
113 void gtsamPoint2_deconstructor_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
114 {
115  typedef std::shared_ptr<gtsam::Point2> Shared;
116  checkArguments("delete_gtsamPoint2",nargout,nargin,1);
117  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
118  Collector_gtsamPoint2::iterator item;
119  item = collector_gtsamPoint2.find(self);
120  if(item != collector_gtsamPoint2.end()) {
121  collector_gtsamPoint2.erase(item);
122  }
123  delete self;
124 }
125 
126 void gtsamPoint2_argChar_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
127 {
128  checkArguments("argChar",nargout,nargin-1,1);
129  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
130  char a = unwrap< char >(in[1]);
131  obj->argChar(a);
132 }
133 
134 void gtsamPoint2_argChar_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
135 {
136  checkArguments("argChar",nargout,nargin-1,1);
137  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
138  std::shared_ptr<char> a = unwrap_shared_ptr< char >(in[1], "ptr_char");
139  obj->argChar(a);
140 }
141 
142 void gtsamPoint2_argChar_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
143 {
144  checkArguments("argChar",nargout,nargin-1,1);
145  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
146  char a = unwrap< char >(in[1]);
147  obj->argChar(a);
148 }
149 
150 void gtsamPoint2_argChar_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
151 {
152  checkArguments("argChar",nargout,nargin-1,1);
153  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
154  char* a = unwrap_ptr< char >(in[1], "ptr_char");
155  obj->argChar(a);
156 }
157 
158 void gtsamPoint2_argChar_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
159 {
160  checkArguments("argChar",nargout,nargin-1,1);
161  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
162  std::shared_ptr<char> a = unwrap_shared_ptr< char >(in[1], "ptr_char");
163  obj->argChar(a);
164 }
165 
166 void gtsamPoint2_argChar_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
167 {
168  checkArguments("argChar",nargout,nargin-1,1);
169  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
170  char a = unwrap< char >(in[1]);
171  obj->argChar(a);
172 }
173 
174 void gtsamPoint2_argChar_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
175 {
176  checkArguments("argChar",nargout,nargin-1,1);
177  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
178  char* a = unwrap_ptr< char >(in[1], "ptr_char");
179  obj->argChar(a);
180 }
181 
182 void gtsamPoint2_argUChar_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
183 {
184  checkArguments("argUChar",nargout,nargin-1,1);
185  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
186  unsigned char a = unwrap< unsigned char >(in[1]);
187  obj->argUChar(a);
188 }
189 
190 void gtsamPoint2_dim_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
191 {
192  checkArguments("dim",nargout,nargin-1,0);
193  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
194  out[0] = wrap< int >(obj->dim());
195 }
196 
197 void gtsamPoint2_eigenArguments_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
198 {
199  checkArguments("eigenArguments",nargout,nargin-1,2);
200  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
201  Vector v = unwrap< Vector >(in[1]);
202  Matrix m = unwrap< Matrix >(in[2]);
203  obj->eigenArguments(v,m);
204 }
205 
206 void gtsamPoint2_returnChar_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
207 {
208  checkArguments("returnChar",nargout,nargin-1,0);
209  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
210  out[0] = wrap< char >(obj->returnChar());
211 }
212 
213 void gtsamPoint2_vectorConfusion_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
214 {
215  checkArguments("vectorConfusion",nargout,nargin-1,0);
216  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
217  out[0] = wrap_shared_ptr(std::make_shared<VectorNotEigen>(obj->vectorConfusion()),"VectorNotEigen", false);
218 }
219 
220 void gtsamPoint2_x_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
221 {
222  checkArguments("x",nargout,nargin-1,0);
223  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
224  out[0] = wrap< double >(obj->x());
225 }
226 
227 void gtsamPoint2_y_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
228 {
229  checkArguments("y",nargout,nargin-1,0);
230  auto obj = unwrap_shared_ptr<gtsam::Point2>(in[0], "ptr_gtsamPoint2");
231  out[0] = wrap< double >(obj->y());
232 }
233 
234 void gtsamPoint3_collectorInsertAndMakeBase_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
235 {
236  mexAtExit(&_deleteAllObjects);
237  typedef std::shared_ptr<gtsam::Point3> Shared;
238 
239  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
240  collector_gtsamPoint3.insert(self);
241 }
242 
243 void gtsamPoint3_constructor_19(int nargout, mxArray *out[], int nargin, const mxArray *in[])
244 {
245  mexAtExit(&_deleteAllObjects);
246  typedef std::shared_ptr<gtsam::Point3> Shared;
247 
248  double x = unwrap< double >(in[0]);
249  double y = unwrap< double >(in[1]);
250  double z = unwrap< double >(in[2]);
251  Shared *self = new Shared(new gtsam::Point3(x,y,z));
252  collector_gtsamPoint3.insert(self);
253  out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
254  *reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
255 }
256 
257 void gtsamPoint3_deconstructor_20(int nargout, mxArray *out[], int nargin, const mxArray *in[])
258 {
259  typedef std::shared_ptr<gtsam::Point3> Shared;
260  checkArguments("delete_gtsamPoint3",nargout,nargin,1);
261  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
262  Collector_gtsamPoint3::iterator item;
263  item = collector_gtsamPoint3.find(self);
264  if(item != collector_gtsamPoint3.end()) {
265  collector_gtsamPoint3.erase(item);
266  }
267  delete self;
268 }
269 
270 void gtsamPoint3_norm_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
271 {
272  checkArguments("norm",nargout,nargin-1,0);
273  auto obj = unwrap_shared_ptr<gtsam::Point3>(in[0], "ptr_gtsamPoint3");
274  out[0] = wrap< double >(obj->norm());
275 }
276 
277 void gtsamPoint3_string_serialize_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
278 {
279  typedef std::shared_ptr<gtsam::Point3> Shared;
280  checkArguments("string_serialize",nargout,nargin-1,0);
281  Shared obj = unwrap_shared_ptr<gtsam::Point3>(in[0], "ptr_gtsamPoint3");
282  ostringstream out_archive_stream;
283  boost::archive::text_oarchive out_archive(out_archive_stream);
284  out_archive << *obj;
285  out[0] = wrap< string >(out_archive_stream.str());
286 }
287 void gtsamPoint3_StaticFunctionRet_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
288 {
289  checkArguments("gtsam::Point3.StaticFunctionRet",nargout,nargin,1);
290  double z = unwrap< double >(in[0]);
291  out[0] = wrap< Point3 >(gtsam::Point3::StaticFunctionRet(z));
292 }
293 
294 void gtsamPoint3_staticFunction_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
295 {
296  checkArguments("gtsam::Point3.staticFunction",nargout,nargin,0);
297  out[0] = wrap< double >(gtsam::Point3::staticFunction());
298 }
299 
300 void gtsamPoint3_string_deserialize_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
301 {
302  typedef std::shared_ptr<gtsam::Point3> Shared;
303  checkArguments("gtsamPoint3.string_deserialize",nargout,nargin,1);
304  string serialized = unwrap< string >(in[0]);
305  istringstream in_archive_stream(serialized);
306  boost::archive::text_iarchive in_archive(in_archive_stream);
307  Shared output(new gtsam::Point3());
308  in_archive >> *output;
309  out[0] = wrap_shared_ptr(output,"gtsam.Point3", false);
310 }
311 
312 void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
313 {
314  mstream mout;
315  std::streambuf *outbuf = std::cout.rdbuf(&mout);
316 
318 
319  int id = unwrap<int>(in[0]);
320 
321  try {
322  switch(id) {
323  case 0:
324  gtsamPoint2_collectorInsertAndMakeBase_0(nargout, out, nargin-1, in+1);
325  break;
326  case 1:
327  gtsamPoint2_constructor_1(nargout, out, nargin-1, in+1);
328  break;
329  case 2:
330  gtsamPoint2_constructor_2(nargout, out, nargin-1, in+1);
331  break;
332  case 3:
333  gtsamPoint2_deconstructor_3(nargout, out, nargin-1, in+1);
334  break;
335  case 4:
336  gtsamPoint2_argChar_4(nargout, out, nargin-1, in+1);
337  break;
338  case 5:
339  gtsamPoint2_argChar_5(nargout, out, nargin-1, in+1);
340  break;
341  case 6:
342  gtsamPoint2_argChar_6(nargout, out, nargin-1, in+1);
343  break;
344  case 7:
345  gtsamPoint2_argChar_7(nargout, out, nargin-1, in+1);
346  break;
347  case 8:
348  gtsamPoint2_argChar_8(nargout, out, nargin-1, in+1);
349  break;
350  case 9:
351  gtsamPoint2_argChar_9(nargout, out, nargin-1, in+1);
352  break;
353  case 10:
354  gtsamPoint2_argChar_10(nargout, out, nargin-1, in+1);
355  break;
356  case 11:
357  gtsamPoint2_argUChar_11(nargout, out, nargin-1, in+1);
358  break;
359  case 12:
360  gtsamPoint2_dim_12(nargout, out, nargin-1, in+1);
361  break;
362  case 13:
363  gtsamPoint2_eigenArguments_13(nargout, out, nargin-1, in+1);
364  break;
365  case 14:
366  gtsamPoint2_returnChar_14(nargout, out, nargin-1, in+1);
367  break;
368  case 15:
369  gtsamPoint2_vectorConfusion_15(nargout, out, nargin-1, in+1);
370  break;
371  case 16:
372  gtsamPoint2_x_16(nargout, out, nargin-1, in+1);
373  break;
374  case 17:
375  gtsamPoint2_y_17(nargout, out, nargin-1, in+1);
376  break;
377  case 18:
378  gtsamPoint3_collectorInsertAndMakeBase_18(nargout, out, nargin-1, in+1);
379  break;
380  case 19:
381  gtsamPoint3_constructor_19(nargout, out, nargin-1, in+1);
382  break;
383  case 20:
384  gtsamPoint3_deconstructor_20(nargout, out, nargin-1, in+1);
385  break;
386  case 21:
387  gtsamPoint3_norm_21(nargout, out, nargin-1, in+1);
388  break;
389  case 22:
390  gtsamPoint3_string_serialize_22(nargout, out, nargin-1, in+1);
391  break;
392  case 23:
393  gtsamPoint3_StaticFunctionRet_23(nargout, out, nargin-1, in+1);
394  break;
395  case 24:
396  gtsamPoint3_staticFunction_24(nargout, out, nargin-1, in+1);
397  break;
398  case 25:
399  gtsamPoint3_string_deserialize_25(nargout, out, nargin-1, in+1);
400  break;
401  }
402  } catch(const std::exception& e) {
403  mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
404  }
405 
406  std::cout.rdbuf(outbuf);
407 }
int unwrap< int >(const mxArray *array)
Definition: matlab.h:328
Matrix3f m
mxArray * wrap_shared_ptr(std::shared_ptr< Class > shared_ptr, const std::string &matlabName, bool isVirtual)
Definition: matlab.h:487
void _geometry_RTTIRegister()
void gtsamPoint2_x_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Scalar * y
std::ofstream out("Result.txt")
void gtsamPoint3_collectorInsertAndMakeBase_18(int nargout, mxArray *out[], int nargin, const mxArray *in[])
char unwrap< char >(const mxArray *array)
Definition: matlab.h:314
void checkArguments(const string &name, int nargout, int nargin, int expected)
Definition: matlab.h:113
BOOST_CLASS_EXPORT_GUID(gtsam::Point2, "gtsamPoint2")
Vector2 Point2
Definition: Point2.h:32
void gtsamPoint2_eigenArguments_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint2_deconstructor_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
string unwrap< string >(const mxArray *array)
Definition: matlab.h:283
iterator iter(handle obj)
Definition: pytypes.h:2273
void gtsamPoint2_argChar_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
unsigned char unwrap< unsigned char >(const mxArray *array)
Definition: matlab.h:321
void gtsamPoint2_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint3_deconstructor_20(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint2_argChar_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint2_argChar_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint2_argChar_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void _deleteAllObjects()
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint3_constructor_19(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint2_y_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
double unwrap< double >(const mxArray *array)
Definition: matlab.h:342
std::set< std::shared_ptr< gtsam::Point3 > * > Collector_gtsamPoint3
void gtsamPoint2_argChar_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint3_StaticFunctionRet_23(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Array< int, Dynamic, 1 > v
void gtsamPoint2_constructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
mxArray * wrap< char >(const char &value)
Definition: matlab.h:140
void gtsamPoint3_string_deserialize_25(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Array< double, 1, 3 > e(1./3., 0.5, 2.)
std::set< std::shared_ptr< gtsam::Point2 > * > Collector_gtsamPoint2
#define NULL
Definition: ccolamd.c:609
void gtsamPoint2_dim_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamPoint3_staticFunction_24(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_gtsamPoint3 collector_gtsamPoint3
mxArray * wrap< int >(const int &value)
Definition: matlab.h:172
void gtsamPoint3_norm_21(int nargout, mxArray *out[], int nargin, const mxArray *in[])
mxArray * wrap< double >(const double &value)
Definition: matlab.h:180
void gtsamPoint2_argChar_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
#define mxUINT32OR64_CLASS
Definition: matlab.h:58
void gtsamPoint3_string_serialize_22(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_gtsamPoint2 collector_gtsamPoint2
void gtsamPoint2_argUChar_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
mxArray * wrap< string >(const string &value)
Definition: matlab.h:134
3D Point
void gtsamPoint2_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
void gtsamPoint2_argChar_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Vector3 Point3
Definition: Point3.h:38
void gtsamPoint2_returnChar_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
2D Point
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: matlab.h:95
void gtsamPoint2_vectorConfusion_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:18