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");
120 out[0] =
wrap_enum(obj->getColor(),
"Color");
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");
150 out[0] =
wrap_enum(obj->type,
"Pet.Kind");
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);
int unwrap< int >(const mxArray *array)
void gtsamMCU_deconstructor_11(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::ofstream out("Result.txt")
void checkArguments(const string &name, int nargout, int nargin, int expected)
std::set< std::shared_ptr< Pet > * > Collector_Pet
void gtsamOptimizerGaussNewtonParams_collectorInsertAndMakeBase_12(int nargout, mxArray *out[], int nargin, const mxArray *in[])
string unwrap< string >(const mxArray *array)
iterator iter(handle obj)
void Pet_deconstructor_2(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamOptimizerGaussNewtonParams_deconstructor_14(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Pet_get_name_5(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Pet_set_type_8(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_Pet collector_Pet
void _enum_RTTIRegister()
void gtsamOptimizerGaussNewtonParams_constructor_13(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamOptimizerGaussNewtonParams_getVerbosity_16(int nargout, mxArray *out[], int nargin, const mxArray *in[])
gtsam::Optimizer< gtsam::GaussNewtonParams > OptimizerGaussNewtonParams
void Pet_constructor_1(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamOptimizerGaussNewtonParams_setVerbosity_17(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< std::shared_ptr< OptimizerGaussNewtonParams > * > Collector_gtsamOptimizerGaussNewtonParams
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define mxUINT32OR64_CLASS
void Pet_set_name_6(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Pet_getColor_3(int nargout, mxArray *out[], int nargin, const mxArray *in[])
mxArray * wrap< string >(const string &value)
void Pet_get_type_7(int nargout, mxArray *out[], int nargin, const mxArray *in[])
static Collector_gtsamOptimizerGaussNewtonParams collector_gtsamOptimizerGaussNewtonParams
mxArray * wrap_enum(const T x, const std::string &classname)
Wrap the C++ enum to Matlab mxArray.
void Pet_collectorInsertAndMakeBase_0(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamOptimizerGaussNewtonParams_getVerbosity_15(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void Pet_setColor_4(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void gtsamMCU_collectorInsertAndMakeBase_9(int nargout, mxArray *out[], int nargin, const mxArray *in[])
Annotation for function names.
static Collector_gtsamMCU collector_gtsamMCU
void gtsamMCU_constructor_10(int nargout, mxArray *out[], int nargin, const mxArray *in[])
std::set< std::shared_ptr< gtsam::MCU > * > Collector_gtsamMCU