00001
00002
00003
00004
00005
00006 #ifndef AQSENSE_SAL3DPP_INTEGRATOR_HPP
00007 #define AQSENSE_SAL3DPP_INTEGRATOR_HPP
00008
00009 #include <sal3d/integrator.h>
00010 #include <sal3dpp/Mesh.hpp>
00011 #include <sal3dpp/COP.hpp>
00012 #include <stdio.h>
00013
00014
00015
00016 namespace sal3d
00017 {
00028 class Integrator
00029 {
00030 public:
00031
00032 Integrator(const sal3d::COP& aCop)
00033 {
00034 _integrator.p = 0;
00035 sal3d_cop cop = aCop.c_cop();
00036
00037 Error e;
00038 sal3d_integrator_new_from_cop(&_integrator, cop, &e.e);
00039 if (e.e.value < 0)
00040 throw e;
00041 };
00042
00043 Integrator(const std::vector<sal3d::COP> &aCops)
00044 {
00045 _integrator.p = 0;
00046 std::vector<sal3d_cop> ccops;
00047 for(unsigned int i = 0; i < aCops.size(); i++)
00048 {
00049 ccops.push_back(aCops[i].c_cop());
00050 }
00051
00052 Error e;
00053 sal3d_integrator_new_from_cops(&_integrator,
00054 &ccops[0], static_cast<int>(ccops.size()), &e.e);
00055 if (e.e.value < 0)
00056 throw e;
00057 };
00058
00059 Integrator(const Integrator &aIntegrator):
00060 _integrator(aIntegrator._integrator)
00061 {
00062 Error e;
00063 sal3d_integrator_share(_integrator, &e.e);
00064 if (e.e.value < 0)
00065 throw e;
00066 }
00067
00068 explicit Integrator(sal3d_integrator aInteg):
00069 _integrator(_integrator)
00070 {
00071 Error e;
00072 sal3d_integrator_is_valid(aInteg, &e.e);
00073 if (e.e.value < 0)
00074 throw e;
00075 }
00076
00077 ~Integrator()
00078 {
00079 sal3d_integrator_release(_integrator);
00080 }
00081
00082 Mesh
00083 Reconstruct(unsigned int aDepth, unsigned int aSPN, int aVerbose = 0) const
00084 {
00085 sal3d_integrator_params params = sal3d_integrator_params_default;
00086 params.iDepth = aDepth;
00087 params.iVerbose = aVerbose;
00088 params.iSamplesPerNode = aSPN;
00089
00090 Error e;
00091 sal3d_integrator_reconstruct_surface(_integrator, ¶ms, &e.e);
00092 if (e.e.value < 0)
00093 throw e;
00094
00095 sal3d_mesh cmesh;
00096 sal3d_integrator_get_mesh(_integrator, &cmesh, &e.e);
00097 if (e.e.value < 0)
00098 throw e;
00099
00100 Mesh mesh(cmesh);
00101
00102 return mesh;
00103 }
00104
00105 sal3d_integrator
00106 c_integrator() const
00107 {
00108 return _integrator;
00109 }
00110
00111 private:
00112 sal3d_integrator _integrator;
00113 };
00114 }
00115
00116 #endif