special_cases_wrapper.cpp
Go to the documentation of this file.
1 #include <gtwrap/matlab.h>
2 #include <map>
3 
5 
8 
9 typedef std::set<std::shared_ptr<gtsam::NonlinearFactorGraph>*> Collector_gtsamNonlinearFactorGraph;
11 typedef std::set<std::shared_ptr<gtsam::SfmTrack>*> Collector_gtsamSfmTrack;
13 typedef std::set<std::shared_ptr<PinholeCameraCal3Bundler>*> Collector_gtsamPinholeCameraCal3Bundler;
15 typedef std::set<std::shared_ptr<GeneralSFMFactorCal3Bundler>*> Collector_gtsamGeneralSFMFactorCal3Bundler;
17 
18 
20 {
21  mstream mout;
22  std::streambuf *outbuf = std::cout.rdbuf(&mout);
23 
24  bool anyDeleted = false;
25  { for(Collector_gtsamNonlinearFactorGraph::iterator iter = collector_gtsamNonlinearFactorGraph.begin();
27  delete *iter;
29  anyDeleted = true;
30  } }
31  { for(Collector_gtsamSfmTrack::iterator iter = collector_gtsamSfmTrack.begin();
32  iter != collector_gtsamSfmTrack.end(); ) {
33  delete *iter;
35  anyDeleted = true;
36  } }
37  { for(Collector_gtsamPinholeCameraCal3Bundler::iterator iter = collector_gtsamPinholeCameraCal3Bundler.begin();
39  delete *iter;
41  anyDeleted = true;
42  } }
43  { for(Collector_gtsamGeneralSFMFactorCal3Bundler::iterator iter = collector_gtsamGeneralSFMFactorCal3Bundler.begin();
45  delete *iter;
47  anyDeleted = true;
48  } }
49 
50  if(anyDeleted)
51  cout <<
52  "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n"
53  "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n"
54  "module, so that your recompiled module is used instead of the old one." << endl;
55  std::cout.rdbuf(outbuf);
56 }
57 
59  const mxArray *alreadyCreated = mexGetVariablePtr("global", "gtsam_special_cases_rttiRegistry_created");
60  if(!alreadyCreated) {
61  std::map<std::string, std::string> types;
62 
63 
64 
65  mxArray *registry = mexGetVariable("global", "gtsamwrap_rttiRegistry");
66  if(!registry)
67  registry = mxCreateStructMatrix(1, 1, 0, NULL);
68  typedef std::pair<std::string, std::string> StringPair;
69  for(const StringPair& rtti_matlab: types) {
70  int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
71  if(fieldId < 0) {
72  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
73  }
74  mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
75  mxSetFieldByNumber(registry, 0, fieldId, matlabName);
76  }
77  if(mexPutVariable("global", "gtsamwrap_rttiRegistry", registry) != 0) {
78  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
79  }
80  mxDestroyArray(registry);
81 
82  mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
83  if(mexPutVariable("global", "gtsam_special_cases_rttiRegistry_created", newAlreadyCreated) != 0) {
84  mexErrMsgTxt("gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
85  }
86  mxDestroyArray(newAlreadyCreated);
87  }
88 }
89 
90 void gtsamNonlinearFactorGraph_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
91 {
92  mexAtExit(&_deleteAllObjects);
93  typedef std::shared_ptr<gtsam::NonlinearFactorGraph> Shared;
94 
95  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
97 }
98 
99 void gtsamNonlinearFactorGraph_deconstructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
100 {
101  typedef std::shared_ptr<gtsam::NonlinearFactorGraph> Shared;
102  checkArguments("delete_gtsamNonlinearFactorGraph",nargout,nargin,1);
103  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
104  Collector_gtsamNonlinearFactorGraph::iterator item;
105  item = collector_gtsamNonlinearFactorGraph.find(self);
106  if(item != collector_gtsamNonlinearFactorGraph.end()) {
108  }
109  delete self;
110 }
111 
112 void gtsamNonlinearFactorGraph_addPrior_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
113 {
114  checkArguments("addPriorPinholeCameraCal3Bundler",nargout,nargin-1,3);
115  auto obj = unwrap_shared_ptr<gtsam::NonlinearFactorGraph>(in[0], "ptr_gtsamNonlinearFactorGraph");
116  size_t key = unwrap< size_t >(in[1]);
117  gtsam::PinholeCamera<gtsam::Cal3Bundler>& prior = *unwrap_shared_ptr< gtsam::PinholeCamera<gtsam::Cal3Bundler> >(in[2], "ptr_gtsamPinholeCameraCal3Bundler");
118  std::shared_ptr<gtsam::noiseModel::Base> noiseModel = unwrap_shared_ptr< gtsam::noiseModel::Base >(in[3], "ptr_gtsamnoiseModelBase");
119  obj->addPrior<gtsam::PinholeCamera<gtsam::Cal3Bundler>>(key,prior,noiseModel);
120 }
121 
122 void gtsamSfmTrack_collectorInsertAndMakeBase_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
123 {
124  mexAtExit(&_deleteAllObjects);
125  typedef std::shared_ptr<gtsam::SfmTrack> Shared;
126 
127  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
128  collector_gtsamSfmTrack.insert(self);
129 }
130 
131 void gtsamSfmTrack_deconstructor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
132 {
133  typedef std::shared_ptr<gtsam::SfmTrack> Shared;
134  checkArguments("delete_gtsamSfmTrack",nargout,nargin,1);
135  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
136  Collector_gtsamSfmTrack::iterator item;
137  item = collector_gtsamSfmTrack.find(self);
138  if(item != collector_gtsamSfmTrack.end()) {
139  collector_gtsamSfmTrack.erase(item);
140  }
141  delete self;
142 }
143 
144 void gtsamSfmTrack_get_measurements_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
145 {
146  checkArguments("measurements",nargout,nargin-1,0);
147  auto obj = unwrap_shared_ptr<gtsam::SfmTrack>(in[0], "ptr_gtsamSfmTrack");
148  out[0] = wrap_shared_ptr(std::make_shared<std::vector<std::pair<size_t,Point2>>>(obj->measurements),"std.vectorpairsize_tPoint2", false);
149 }
150 
151 void gtsamSfmTrack_set_measurements_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
152 {
153  checkArguments("measurements",nargout,nargin-1,1);
154  auto obj = unwrap_shared_ptr<gtsam::SfmTrack>(in[0], "ptr_gtsamSfmTrack");
155  std::shared_ptr<std::vector<std::pair<size_t,Point2>>> measurements = unwrap_shared_ptr< std::vector<std::pair<size_t,Point2>> >(in[1], "ptr_stdvectorpairsize_tPoint2");
156  obj->measurements = *measurements;
157 }
158 
159 void gtsamPinholeCameraCal3Bundler_collectorInsertAndMakeBase_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
160 {
161  mexAtExit(&_deleteAllObjects);
162  typedef std::shared_ptr<gtsam::PinholeCamera<gtsam::Cal3Bundler>> Shared;
163 
164  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
166 }
167 
168 void gtsamPinholeCameraCal3Bundler_deconstructor_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
169 {
170  typedef std::shared_ptr<gtsam::PinholeCamera<gtsam::Cal3Bundler>> Shared;
171  checkArguments("delete_gtsamPinholeCameraCal3Bundler",nargout,nargin,1);
172  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
173  Collector_gtsamPinholeCameraCal3Bundler::iterator item;
174  item = collector_gtsamPinholeCameraCal3Bundler.find(self);
175  if(item != collector_gtsamPinholeCameraCal3Bundler.end()) {
177  }
178  delete self;
179 }
180 
181 void gtsamGeneralSFMFactorCal3Bundler_collectorInsertAndMakeBase_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
182 {
183  mexAtExit(&_deleteAllObjects);
184  typedef std::shared_ptr<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>, gtsam::Point3>> Shared;
185 
186  Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
188 }
189 
190 void gtsamGeneralSFMFactorCal3Bundler_deconstructor_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
191 {
192  typedef std::shared_ptr<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>, gtsam::Point3>> Shared;
193  checkArguments("delete_gtsamGeneralSFMFactorCal3Bundler",nargout,nargin,1);
194  Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
195  Collector_gtsamGeneralSFMFactorCal3Bundler::iterator item;
199  }
200  delete self;
201 }
202 
203 void gtsamGeneralSFMFactorCal3Bundler_get_verbosity_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
204 {
205  checkArguments("verbosity",nargout,nargin-1,0);
206  auto obj = unwrap_shared_ptr<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>, gtsam::Point3>>(in[0], "ptr_gtsamGeneralSFMFactorCal3Bundler");
207  out[0] = wrap_enum(obj->verbosity,"gtsam.GeneralSFMFactorCal3Bundler.Verbosity");
208 }
209 
210 void gtsamGeneralSFMFactorCal3Bundler_set_verbosity_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
211 {
212  checkArguments("verbosity",nargout,nargin-1,1);
213  auto obj = unwrap_shared_ptr<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>, gtsam::Point3>>(in[0], "ptr_gtsamGeneralSFMFactorCal3Bundler");
214  gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>, gtsam::Point3>::Verbosity verbosity = unwrap_enum<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>, gtsam::Point3>::Verbosity>(in[1]);
215  obj->verbosity = verbosity;
216 }
217 
218 
219 void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
220 {
221  mstream mout;
222  std::streambuf *outbuf = std::cout.rdbuf(&mout);
223 
225 
226  int id = unwrap<int>(in[0]);
227 
228  try {
229  switch(id) {
230  case 0:
232  break;
233  case 1:
234  gtsamNonlinearFactorGraph_deconstructor_1(nargout, out, nargin-1, in+1);
235  break;
236  case 2:
237  gtsamNonlinearFactorGraph_addPrior_2(nargout, out, nargin-1, in+1);
238  break;
239  case 3:
240  gtsamSfmTrack_collectorInsertAndMakeBase_3(nargout, out, nargin-1, in+1);
241  break;
242  case 4:
243  gtsamSfmTrack_deconstructor_4(nargout, out, nargin-1, in+1);
244  break;
245  case 5:
246  gtsamSfmTrack_get_measurements_5(nargout, out, nargin-1, in+1);
247  break;
248  case 6:
249  gtsamSfmTrack_set_measurements_6(nargout, out, nargin-1, in+1);
250  break;
251  case 7:
253  break;
254  case 8:
255  gtsamPinholeCameraCal3Bundler_deconstructor_8(nargout, out, nargin-1, in+1);
256  break;
257  case 9:
259  break;
260  case 10:
261  gtsamGeneralSFMFactorCal3Bundler_deconstructor_10(nargout, out, nargin-1, in+1);
262  break;
263  case 11:
264  gtsamGeneralSFMFactorCal3Bundler_get_verbosity_11(nargout, out, nargin-1, in+1);
265  break;
266  case 12:
267  gtsamGeneralSFMFactorCal3Bundler_set_verbosity_12(nargout, out, nargin-1, in+1);
268  break;
269  }
270  } catch(const std::exception& e) {
271  mexErrMsgTxt(("Exception from gtsam:\n" + std::string(e.what()) + "\n").c_str());
272  }
273 
274  std::cout.rdbuf(outbuf);
275 }
mexFunction
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:219
gtsamSfmTrack_get_measurements_5
void gtsamSfmTrack_get_measurements_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:144
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsamGeneralSFMFactorCal3Bundler_deconstructor_10
void gtsamGeneralSFMFactorCal3Bundler_deconstructor_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:190
gtsamGeneralSFMFactorCal3Bundler_collectorInsertAndMakeBase_9
void gtsamGeneralSFMFactorCal3Bundler_collectorInsertAndMakeBase_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:181
gtsamNonlinearFactorGraph_deconstructor_1
void gtsamNonlinearFactorGraph_deconstructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:99
PinholeCameraCal3Bundler
gtsam::PinholeCamera< gtsam::Cal3Bundler > PinholeCameraCal3Bundler
Definition: special_cases_wrapper.cpp:6
gtsamPinholeCameraCal3Bundler_collectorInsertAndMakeBase_7
void gtsamPinholeCameraCal3Bundler_collectorInsertAndMakeBase_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:159
gtsamSfmTrack_deconstructor_4
void gtsamSfmTrack_deconstructor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:131
gtsamSfmTrack_set_measurements_6
void gtsamSfmTrack_set_measurements_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:151
Collector_gtsamSfmTrack
std::set< std::shared_ptr< gtsam::SfmTrack > * > Collector_gtsamSfmTrack
Definition: special_cases_wrapper.cpp:11
gtsamGeneralSFMFactorCal3Bundler_set_verbosity_12
void gtsamGeneralSFMFactorCal3Bundler_set_verbosity_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:210
collector_gtsamPinholeCameraCal3Bundler
static Collector_gtsamPinholeCameraCal3Bundler collector_gtsamPinholeCameraCal3Bundler
Definition: special_cases_wrapper.cpp:14
checkArguments
void checkArguments(const string &name, int nargout, int nargin, int expected)
Definition: matlab.h:113
mstream
Definition: matlab.h:95
unwrap< size_t >
size_t unwrap< size_t >(const mxArray *array)
Definition: matlab.h:335
unwrap< int >
int unwrap< int >(const mxArray *array)
Definition: matlab.h:328
_special_cases_RTTIRegister
void _special_cases_RTTIRegister()
Definition: special_cases_wrapper.cpp:58
gtsam::PinholeCamera
Definition: PinholeCamera.h:33
gtsamGeneralSFMFactorCal3Bundler_get_verbosity_11
void gtsamGeneralSFMFactorCal3Bundler_get_verbosity_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:203
collector_gtsamSfmTrack
static Collector_gtsamSfmTrack collector_gtsamSfmTrack
Definition: special_cases_wrapper.cpp:12
gtsam::make_shared
gtsam::enable_if_t< needs_eigen_aligned_allocator< T >::value, std::shared_ptr< T > > make_shared(Args &&... args)
Definition: make_shared.h:56
gtsamPinholeCameraCal3Bundler_deconstructor_8
void gtsamPinholeCameraCal3Bundler_deconstructor_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:168
wrap_shared_ptr
mxArray * wrap_shared_ptr(std::shared_ptr< Class > shared_ptr, const std::string &matlabName, bool isVirtual)
Definition: matlab.h:487
Collector_gtsamPinholeCameraCal3Bundler
std::set< std::shared_ptr< PinholeCameraCal3Bundler > * > Collector_gtsamPinholeCameraCal3Bundler
Definition: special_cases_wrapper.cpp:13
wrap_enum
mxArray * wrap_enum(const T x, const std::string &classname)
Wrap the C++ enum to Matlab mxArray.
Definition: matlab.h:236
out
std::ofstream out("Result.txt")
key
const gtsam::Symbol key('X', 0)
gtsamSfmTrack_collectorInsertAndMakeBase_3
void gtsamSfmTrack_collectorInsertAndMakeBase_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:122
GeneralSFMFactorCal3Bundler
gtsam::GeneralSFMFactor< gtsam::PinholeCamera< gtsam::Cal3Bundler >, gtsam::Point3 > GeneralSFMFactorCal3Bundler
Definition: special_cases_wrapper.cpp:7
_deleteAllObjects
void _deleteAllObjects()
Definition: special_cases_wrapper.cpp:19
Collector_gtsamNonlinearFactorGraph
std::set< std::shared_ptr< gtsam::NonlinearFactorGraph > * > Collector_gtsamNonlinearFactorGraph
Definition: special_cases_wrapper.cpp:9
collector_gtsamGeneralSFMFactorCal3Bundler
static Collector_gtsamGeneralSFMFactorCal3Bundler collector_gtsamGeneralSFMFactorCal3Bundler
Definition: special_cases_wrapper.cpp:16
estimation_fixture::measurements
std::vector< double > measurements
Definition: testHybridEstimation.cpp:51
iter
iterator iter(handle obj)
Definition: pytypes.h:2475
gtsam::GeneralSFMFactor
Definition: GeneralSFMFactor.h:59
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
different_sigmas::prior
const auto prior
Definition: testHybridBayesNet.cpp:238
Collector_gtsamGeneralSFMFactorCal3Bundler
std::set< std::shared_ptr< GeneralSFMFactorCal3Bundler > * > Collector_gtsamGeneralSFMFactorCal3Bundler
Definition: special_cases_wrapper.cpp:15
NULL
#define NULL
Definition: ccolamd.c:609
gtsamNonlinearFactorGraph_collectorInsertAndMakeBase_0
void gtsamNonlinearFactorGraph_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:90
collector_gtsamNonlinearFactorGraph
static Collector_gtsamNonlinearFactorGraph collector_gtsamNonlinearFactorGraph
Definition: special_cases_wrapper.cpp:10
Cal3Bundler.h
Calibration used by Bundler.
gtsamNonlinearFactorGraph_addPrior_2
void gtsamNonlinearFactorGraph_addPrior_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Definition: special_cases_wrapper.cpp:112


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:36:22