1 #include <gtwrap/matlab.h>
19 std::streambuf *outbuf = std::cout.rdbuf(&mout);
21 bool anyDeleted =
false;
43 "WARNING: Wrap modules with variables in the workspace have been reloaded due to\n"
44 "calling destructors, call 'clear all' again if you plan to now recompile a wrap\n"
45 "module, so that your recompiled module is used instead of the old one." << endl;
46 std::cout.rdbuf(outbuf);
50 const mxArray *alreadyCreated = mexGetVariablePtr(
"global",
"gtsam_enum_rttiRegistry_created");
52 std::map<std::string, std::string> types;
56 mxArray *registry = mexGetVariable(
"global",
"gtsamwrap_rttiRegistry");
58 registry = mxCreateStructMatrix(1, 1, 0,
NULL);
59 typedef std::pair<std::string, std::string> StringPair;
60 for(
const StringPair& rtti_matlab: types) {
61 int fieldId = mxAddField(registry, rtti_matlab.first.c_str());
63 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
65 mxArray *matlabName = mxCreateString(rtti_matlab.second.c_str());
66 mxSetFieldByNumber(registry, 0, fieldId, matlabName);
68 if(mexPutVariable(
"global",
"gtsamwrap_rttiRegistry", registry) != 0) {
69 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
71 mxDestroyArray(registry);
73 mxArray *newAlreadyCreated = mxCreateNumericMatrix(0, 0, mxINT8_CLASS, mxREAL);
74 if(mexPutVariable(
"global",
"gtsam_enum_rttiRegistry_created", newAlreadyCreated) != 0) {
75 mexErrMsgTxt(
"gtsam wrap: Error indexing RTTI types, inheritance will not work correctly");
77 mxDestroyArray(newAlreadyCreated);
84 typedef std::shared_ptr<Pet> Shared;
86 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
93 typedef std::shared_ptr<Pet> Shared;
95 string&
name = *unwrap_shared_ptr< string >(in[0],
"ptr_string");
96 Pet::Kind
type = unwrap_enum<Pet::Kind>(in[1]);
97 Shared *
self =
new Shared(
new Pet(
name,
type));
100 *
reinterpret_cast<Shared**
> (mxGetData(
out[0])) =
self;
105 typedef std::shared_ptr<Pet> Shared;
107 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
108 Collector_Pet::iterator item;
119 auto obj = unwrap_shared_ptr<Pet>(in[0],
"ptr_Pet");
126 auto obj = unwrap_shared_ptr<Pet>(in[0],
"ptr_Pet");
127 Color color = unwrap_enum<Color>(in[1]);
128 obj->setColor(color);
134 auto obj = unwrap_shared_ptr<Pet>(in[0],
"ptr_Pet");
141 auto obj = unwrap_shared_ptr<Pet>(in[0],
"ptr_Pet");
149 auto obj = unwrap_shared_ptr<Pet>(in[0],
"ptr_Pet");
156 auto obj = unwrap_shared_ptr<Pet>(in[0],
"ptr_Pet");
157 Pet::Kind
type = unwrap_enum<Pet::Kind>(in[1]);
164 typedef std::shared_ptr<gtsam::MCU> Shared;
166 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
173 typedef std::shared_ptr<gtsam::MCU> Shared;
175 Shared *
self =
new Shared(
new gtsam::MCU());
178 *
reinterpret_cast<Shared**
> (mxGetData(
out[0])) =
self;
183 typedef std::shared_ptr<gtsam::MCU> Shared;
185 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
186 Collector_gtsamMCU::iterator item;
197 typedef std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>> Shared;
199 Shared *
self = *
reinterpret_cast<Shared**
> (mxGetData(in[0]));
206 typedef std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>> Shared;
208 Optimizer<gtsam::GaussNewtonParams>::Verbosity verbosity = unwrap_enum<Optimizer<gtsam::GaussNewtonParams>::Verbosity>(in[0]);
209 Shared *
self =
new Shared(
new gtsam::Optimizer<gtsam::GaussNewtonParams>(verbosity));
212 *
reinterpret_cast<Shared**
> (mxGetData(
out[0])) =
self;
217 typedef std::shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>> Shared;
218 checkArguments(
"delete_gtsamOptimizerGaussNewtonParams",nargout,nargin,1);
219 Shared *
self = *
reinterpret_cast<Shared**
>(mxGetData(in[0]));
220 Collector_gtsamOptimizerGaussNewtonParams::iterator item;
231 auto obj = unwrap_shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>(in[0],
"ptr_gtsamOptimizerGaussNewtonParams");
232 out[0] =
wrap_enum(obj->getVerbosity(),
"gtsam.OptimizerGaussNewtonParams.Verbosity");
238 auto obj = unwrap_shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>(in[0],
"ptr_gtsamOptimizerGaussNewtonParams");
239 out[0] =
wrap_enum(obj->getVerbosity(),
"gtsam.VerbosityLM");
245 auto obj = unwrap_shared_ptr<gtsam::Optimizer<gtsam::GaussNewtonParams>>(in[0],
"ptr_gtsamOptimizerGaussNewtonParams");
246 Optimizer<gtsam::GaussNewtonParams>::Verbosity
value = unwrap_enum<Optimizer<gtsam::GaussNewtonParams>::Verbosity>(in[1]);
247 obj->setVerbosity(
value);
254 std::streambuf *outbuf = std::cout.rdbuf(&mout);
317 }
catch(
const std::exception&
e) {
318 mexErrMsgTxt((
"Exception from gtsam:\n" + std::string(
e.what()) +
"\n").c_str());
321 std::cout.rdbuf(outbuf);