I have a class header file myclass.h
#ifndef MYCLASS_H
#define MYCLASS_H
#include <iostream>
#include <math.h>
#include <vector>
#include <vtkSmartPointer.h>
#include <vtkMatrix4x4.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv/cv.h>
class myclass
{
public:
double compute(vtkMatrix4x4 *transMat, std::vector<Point3f>* sourcePoints);
};
#endif // MYCLASS_H
And my myclass.cpp is:
#include <myclass.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <vtkSmartPointer.h>
#include <vtkMatrix4x4.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv/cv.h>
using namespace std;
double myclass::compute(vtkMatrix4x4 *transMat, std::vector<Point3f>* sourcePoints)
{
double x;
......code for computing x......
................................
return x;
}
This returns error when I implement:
myclass myFunctions;
std::vector<cv::Point3f> sourcePoints;
vtkSmartPointer<vtkMatrix4x4> mat = vtkSmartPointer<vtkMatrix4x4>::New();
...........mat and sourcePoints filled..................
double c = myFunctions.compute(mat, sourcePoints);
Should I declare the vtkMatrix and sourcePoints as private attributes in header file? I am stuck at this point.
class myclass
{
public:
double myclass::compute(vtkSmartPointer<vtkMatrix4x4> mat, const std::vector<Point3f>& sourcePoints)
};
double myclass::compute(vtkSmartPointer<vtkMatrix4x4> mat, const std::vector<Point3f>& sourcePoints)
{
double x;
......code for computing x......
................................
return x;
}
// now you can call it in the desired way:
myclass myFunctions;
std::vector<cv::Point3f> sourcePoints;
vtkSmartPointer<vtkMatrix4x4> mat = vtkSmartPointer<vtkMatrix4x4>::New();
double c = myFunctions.compute(mat, sourcePoints);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.