Made tests succeed, added templated Vector templates

release/4.3a0
dellaert 2016-02-07 20:34:16 -08:00
parent 699943d632
commit 5b581a36c9
8 changed files with 206 additions and 22 deletions

View File

@ -79,6 +79,14 @@ class_<MyTemplateMatrix>("MyTemplateMatrix")
.def("templatedMethod", &MyTemplateMatrix::templatedMethod);
;
class_<MyVector3>("MyVector3")
.def("MyVector3", &MyVector3::MyVector3);
;
class_<MyVector12>("MyVector12")
.def("MyVector12", &MyVector12::MyVector12);
;
class_<MyFactorPosePoint2>("MyFactorPosePoint2")
.def("MyFactorPosePoint2", &MyFactorPosePoint2::MyFactorPosePoint2);
;

View File

@ -12,9 +12,9 @@ classdef MyFactorPosePoint2 < handle
function obj = MyFactorPosePoint2(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
geometry_wrapper(76, my_ptr);
geometry_wrapper(82, my_ptr);
elseif nargin == 4 && isa(varargin{1},'numeric') && isa(varargin{2},'numeric') && isa(varargin{3},'double') && isa(varargin{4},'gtsam.noiseModel.Base')
my_ptr = geometry_wrapper(77, varargin{1}, varargin{2}, varargin{3}, varargin{4});
my_ptr = geometry_wrapper(83, varargin{1}, varargin{2}, varargin{3}, varargin{4});
else
error('Arguments do not match any overload of MyFactorPosePoint2 constructor');
end
@ -22,7 +22,7 @@ classdef MyFactorPosePoint2 < handle
end
function delete(obj)
geometry_wrapper(78, obj.ptr_MyFactorPosePoint2);
geometry_wrapper(84, obj.ptr_MyFactorPosePoint2);
end
function display(obj), obj.print(''); end

View File

@ -0,0 +1,36 @@
%class MyVector12, see Doxygen page for details
%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
%
%-------Constructors-------
%MyVector12()
%
classdef MyVector12 < handle
properties
ptr_MyVector12 = 0
end
methods
function obj = MyVector12(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
geometry_wrapper(79, my_ptr);
elseif nargin == 0
my_ptr = geometry_wrapper(80);
else
error('Arguments do not match any overload of MyVector12 constructor');
end
obj.ptr_MyVector12 = my_ptr;
end
function delete(obj)
geometry_wrapper(81, obj.ptr_MyVector12);
end
function display(obj), obj.print(''); end
%DISPLAY Calls print on the object
function disp(obj), obj.display; end
%DISP Calls print on the object
end
methods(Static = true)
end
end

View File

@ -0,0 +1,36 @@
%class MyVector3, see Doxygen page for details
%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
%
%-------Constructors-------
%MyVector3()
%
classdef MyVector3 < handle
properties
ptr_MyVector3 = 0
end
methods
function obj = MyVector3(varargin)
if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682)
my_ptr = varargin{2};
geometry_wrapper(76, my_ptr);
elseif nargin == 0
my_ptr = geometry_wrapper(77);
else
error('Arguments do not match any overload of MyVector3 constructor');
end
obj.ptr_MyVector3 = my_ptr;
end
function delete(obj)
geometry_wrapper(78, obj.ptr_MyVector3);
end
function display(obj), obj.print(''); end
%DISPLAY Calls print on the object
function disp(obj), obj.display; end
%DISP Calls print on the object
end
methods(Static = true)
end
end

View File

@ -1,6 +1,6 @@
function varargout = aGlobalFunction(varargin)
if length(varargin) == 0
varargout{1} = geometry_wrapper(79, varargin{:});
varargout{1} = geometry_wrapper(85, varargin{:});
else
error('Arguments do not match any overload of function aGlobalFunction');
end

View File

@ -10,6 +10,8 @@
typedef MyTemplate<gtsam::Point2> MyTemplatePoint2;
typedef MyTemplate<Matrix> MyTemplateMatrix;
typedef MyVector<3> MyVector3;
typedef MyVector<12> MyVector12;
typedef MyFactor<gtsam::Pose2, Matrix> MyFactorPosePoint2;
BOOST_CLASS_EXPORT_GUID(gtsam::Point2, "gtsamPoint2");
@ -27,6 +29,10 @@ typedef std::set<boost::shared_ptr<MyTemplatePoint2>*> Collector_MyTemplatePoint
static Collector_MyTemplatePoint2 collector_MyTemplatePoint2;
typedef std::set<boost::shared_ptr<MyTemplateMatrix>*> Collector_MyTemplateMatrix;
static Collector_MyTemplateMatrix collector_MyTemplateMatrix;
typedef std::set<boost::shared_ptr<MyVector3>*> Collector_MyVector3;
static Collector_MyVector3 collector_MyVector3;
typedef std::set<boost::shared_ptr<MyVector12>*> Collector_MyVector12;
static Collector_MyVector12 collector_MyVector12;
typedef std::set<boost::shared_ptr<MyFactorPosePoint2>*> Collector_MyFactorPosePoint2;
static Collector_MyFactorPosePoint2 collector_MyFactorPosePoint2;
@ -72,6 +78,18 @@ void _deleteAllObjects()
collector_MyTemplateMatrix.erase(iter++);
anyDeleted = true;
} }
{ for(Collector_MyVector3::iterator iter = collector_MyVector3.begin();
iter != collector_MyVector3.end(); ) {
delete *iter;
collector_MyVector3.erase(iter++);
anyDeleted = true;
} }
{ for(Collector_MyVector12::iterator iter = collector_MyVector12.begin();
iter != collector_MyVector12.end(); ) {
delete *iter;
collector_MyVector12.erase(iter++);
anyDeleted = true;
} }
{ for(Collector_MyFactorPosePoint2::iterator iter = collector_MyFactorPosePoint2.begin();
iter != collector_MyFactorPosePoint2.end(); ) {
delete *iter;
@ -914,7 +932,73 @@ void MyTemplateMatrix_templatedMethod_75(int nargout, mxArray *out[], int nargin
out[0] = wrap< Vector >(obj->templatedMethod<Vector>(t));
}
void MyFactorPosePoint2_collectorInsertAndMakeBase_76(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyVector3_collectorInsertAndMakeBase_76(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector3> Shared;
Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
collector_MyVector3.insert(self);
}
void MyVector3_constructor_77(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector3> Shared;
Shared *self = new Shared(new MyVector3());
collector_MyVector3.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void MyVector3_deconstructor_78(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MyVector3> Shared;
checkArguments("delete_MyVector3",nargout,nargin,1);
Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
Collector_MyVector3::iterator item;
item = collector_MyVector3.find(self);
if(item != collector_MyVector3.end()) {
delete self;
collector_MyVector3.erase(item);
}
}
void MyVector12_collectorInsertAndMakeBase_79(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector12> Shared;
Shared *self = *reinterpret_cast<Shared**> (mxGetData(in[0]));
collector_MyVector12.insert(self);
}
void MyVector12_constructor_80(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyVector12> Shared;
Shared *self = new Shared(new MyVector12());
collector_MyVector12.insert(self);
out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL);
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void MyVector12_deconstructor_81(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MyVector12> Shared;
checkArguments("delete_MyVector12",nargout,nargin,1);
Shared *self = *reinterpret_cast<Shared**>(mxGetData(in[0]));
Collector_MyVector12::iterator item;
item = collector_MyVector12.find(self);
if(item != collector_MyVector12.end()) {
delete self;
collector_MyVector12.erase(item);
}
}
void MyFactorPosePoint2_collectorInsertAndMakeBase_82(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyFactorPosePoint2> Shared;
@ -923,7 +1007,7 @@ void MyFactorPosePoint2_collectorInsertAndMakeBase_76(int nargout, mxArray *out[
collector_MyFactorPosePoint2.insert(self);
}
void MyFactorPosePoint2_constructor_77(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_constructor_83(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
mexAtExit(&_deleteAllObjects);
typedef boost::shared_ptr<MyFactorPosePoint2> Shared;
@ -938,7 +1022,7 @@ void MyFactorPosePoint2_constructor_77(int nargout, mxArray *out[], int nargin,
*reinterpret_cast<Shared**> (mxGetData(out[0])) = self;
}
void MyFactorPosePoint2_deconstructor_78(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void MyFactorPosePoint2_deconstructor_84(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
typedef boost::shared_ptr<MyFactorPosePoint2> Shared;
checkArguments("delete_MyFactorPosePoint2",nargout,nargin,1);
@ -951,18 +1035,18 @@ void MyFactorPosePoint2_deconstructor_78(int nargout, mxArray *out[], int nargin
}
}
void aGlobalFunction_79(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void aGlobalFunction_85(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("aGlobalFunction",nargout,nargin,0);
out[0] = wrap< Vector >(aGlobalFunction());
}
void overloadedGlobalFunction_80(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void overloadedGlobalFunction_86(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("overloadedGlobalFunction",nargout,nargin,1);
int a = unwrap< int >(in[0]);
out[0] = wrap< Vector >(overloadedGlobalFunction(a));
}
void overloadedGlobalFunction_81(int nargout, mxArray *out[], int nargin, const mxArray *in[])
void overloadedGlobalFunction_87(int nargout, mxArray *out[], int nargin, const mxArray *in[])
{
checkArguments("overloadedGlobalFunction",nargout,nargin,2);
int a = unwrap< int >(in[0]);
@ -1210,22 +1294,40 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])
MyTemplateMatrix_templatedMethod_75(nargout, out, nargin-1, in+1);
break;
case 76:
MyFactorPosePoint2_collectorInsertAndMakeBase_76(nargout, out, nargin-1, in+1);
MyVector3_collectorInsertAndMakeBase_76(nargout, out, nargin-1, in+1);
break;
case 77:
MyFactorPosePoint2_constructor_77(nargout, out, nargin-1, in+1);
MyVector3_constructor_77(nargout, out, nargin-1, in+1);
break;
case 78:
MyFactorPosePoint2_deconstructor_78(nargout, out, nargin-1, in+1);
MyVector3_deconstructor_78(nargout, out, nargin-1, in+1);
break;
case 79:
aGlobalFunction_79(nargout, out, nargin-1, in+1);
MyVector12_collectorInsertAndMakeBase_79(nargout, out, nargin-1, in+1);
break;
case 80:
overloadedGlobalFunction_80(nargout, out, nargin-1, in+1);
MyVector12_constructor_80(nargout, out, nargin-1, in+1);
break;
case 81:
overloadedGlobalFunction_81(nargout, out, nargin-1, in+1);
MyVector12_deconstructor_81(nargout, out, nargin-1, in+1);
break;
case 82:
MyFactorPosePoint2_collectorInsertAndMakeBase_82(nargout, out, nargin-1, in+1);
break;
case 83:
MyFactorPosePoint2_constructor_83(nargout, out, nargin-1, in+1);
break;
case 84:
MyFactorPosePoint2_deconstructor_84(nargout, out, nargin-1, in+1);
break;
case 85:
aGlobalFunction_85(nargout, out, nargin-1, in+1);
break;
case 86:
overloadedGlobalFunction_86(nargout, out, nargin-1, in+1);
break;
case 87:
overloadedGlobalFunction_87(nargout, out, nargin-1, in+1);
break;
}
} catch(const std::exception& e) {

View File

@ -1,8 +1,8 @@
function varargout = overloadedGlobalFunction(varargin)
if length(varargin) == 1 && isa(varargin{1},'numeric')
varargout{1} = geometry_wrapper(80, varargin{:});
varargout{1} = geometry_wrapper(86, varargin{:});
elseif length(varargin) == 2 && isa(varargin{1},'numeric') && isa(varargin{2},'double')
varargout{1} = geometry_wrapper(81, varargin{:});
varargout{1} = geometry_wrapper(87, varargin{:});
else
error('Arguments do not match any overload of function overloadedGlobalFunction');
end

View File

@ -449,6 +449,8 @@ TEST( wrap, matlab_code_geometry ) {
EXPECT(files_equal(epath + "+gtsam/Point3.m" , apath + "+gtsam/Point3.m" ));
EXPECT(files_equal(epath + "Test.m" , apath + "Test.m" ));
EXPECT(files_equal(epath + "MyBase.m" , apath + "MyBase.m" ));
EXPECT(files_equal(epath + "MyVector3.m" , apath + "MyVector3.m" ));
EXPECT(files_equal(epath + "MyVector12.m" , apath + "MyVector12.m" ));
EXPECT(files_equal(epath + "MyTemplatePoint2.m" , apath + "MyTemplatePoint2.m" ));
EXPECT(files_equal(epath + "MyTemplateMatrix.m" , apath + "MyTemplateMatrix.m" ));
EXPECT(files_equal(epath + "MyFactorPosePoint2.m" , apath + "MyFactorPosePoint2.m" ));