1 #include <gtwrap/matlab.h>
22 std::streambuf *outbuf = std::cout.rdbuf(&mout);
24 bool anyDeleted =
false;
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);
59 const mxArray *alreadyCreated = mexGetVariablePtr(
"global",
"gtsam_special_cases_rttiRegistry_created");
61 std::map<std::string, std::string> types;
65 mxArray *registry = mexGetVariable(
"global",
"gtsamwrap_rttiRegistry");
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());
72 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
74 mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
75 mxSetFieldByNumber(registry, 0, fieldId, matlabName);
77 if(mexPutVariable(
"global",
"gtsamwrap_rttiRegistry", registry) != 0) {
78 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
80 mxDestroyArray(registry);
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");
86 mxDestroyArray(newAlreadyCreated);
93 typedef std::shared_ptr<gtsam::NonlinearFactorGraph> Shared;
95 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
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;
114 checkArguments(
"addPriorPinholeCameraCal3Bundler",nargout,nargin-1,3);
115 auto obj = unwrap_shared_ptr<gtsam::NonlinearFactorGraph>(in[0],
"ptr_gtsamNonlinearFactorGraph");
118 std::shared_ptr<gtsam::noiseModel::Base> noiseModel = unwrap_shared_ptr< gtsam::noiseModel::Base >(in[3],
"ptr_gtsamnoiseModelBase");
125 typedef std::shared_ptr<gtsam::SfmTrack> Shared;
127 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
133 typedef std::shared_ptr<gtsam::SfmTrack> Shared;
135 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
136 Collector_gtsamSfmTrack::iterator item;
147 auto obj = unwrap_shared_ptr<gtsam::SfmTrack>(in[0],
"ptr_gtsamSfmTrack");
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");
162 typedef std::shared_ptr<gtsam::PinholeCamera<gtsam::Cal3Bundler>> Shared;
164 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
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;
184 typedef std::shared_ptr<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>,
gtsam::Point3>> Shared;
186 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
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;
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");
213 auto obj = unwrap_shared_ptr<gtsam::GeneralSFMFactor<gtsam::PinholeCamera<gtsam::Cal3Bundler>,
gtsam::Point3>>(in[0],
"ptr_gtsamGeneralSFMFactorCal3Bundler");
215 obj->verbosity = verbosity;
222 std::streambuf *outbuf = std::cout.rdbuf(&mout);
270 }
catch(
const std::exception&
e) {
271 mexErrMsgTxt((
"Exception from gtsam:\n" + std::string(
e.what()) +
"\n").c_str());
274 std::cout.rdbuf(outbuf);