Problème C++ boost::shared_ptr
rickey
-
rickey91 -
rickey91 -
Bonjour,
je débute en C++ et j'ai quelques soucis avec une bibliothèques que j'ai téléchargé.
Pour faire simple, j'ai créé un projet DLL permettant normalement d'utiliser cette bibliothèque C++ avec Scilab.
Normalement, cette bibliothèque trouve les données à traiter grâce au chemin du fichier données.
Or je souhaiterais lui faire passer en entrée des tableaux de doubles(correspondant aux données à traiter).
Malheuresement j'ai un problème d'incompatibilité entre les boost::shared_ptr<dVec> x_arr(new std::vector<double>); et les double xx[].
Si quelqu'un à une idée pour m'aider. Merci d'avance
Voici mon main:
// justdoit.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <MBA.h>
#include <UCButils.h>
#include <boost/shared_ptr.hpp>
#include <PointAccessUtils.h>
//Functions declarations
//extern "C" __declspec(dllexport) void __cdecl justdoit(boost::shared_ptr<dVec> xx, boost::shared_ptr<dVec> yy, boost::shared_ptr<dVec> zz);
//extern "C" __declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]);
//extern "C" __declspec(dllexport) void __cdecl justdoit(std::vector<double> xx, std::vector<double> yy, std::vector<double> zz);
extern "C" __declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
//int main() {
//__declspec(dllexport) void justdoit(boost::shared_ptr<dVec>& xx, boost::shared_ptr<dVec> yy, boost::shared_ptr<dVec> zz){
//__declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]){
//__declspec(dllexport) void __cdecl justdoit(std::vector<double> xx, std::vector<double> yy, std::vector<double> zz){
__declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]){
// Read scattered data from file
// Each array is maintained by "standard" boost shared pointers.
// (See for example www.boost.org)
// The format is assumed to be:
// x y z
// x y z
// x y z
// etc
// for (int i=0; i<21; i++) {
// yy[i]=xx[i]-3;
// }
typedef std::vector<double> dVec;
boost::shared_ptr<dVec> x_arr(new std::vector<double>);
boost::shared_ptr<dVec> y_arr(new std::vector<double>);
boost::shared_ptr<dVec> z_arr(new std::vector<double>);
/*
boost::shared_ptr<dVec> xxx(&xx);
boost::shared_ptr<dVec> yyy(&yy);
boost::shared_ptr<dVec> zzz(&zz);
*/
/*
x_arr=xx;
y_arr=yy;
z_arr=zz;
*/
//UCBspl::readScatteredData("c:/user/U236436/work/Interfacage_MP/MOVB/justdoit/Data/scat.dat", *x_arr, *y_arr, *z_arr);
MBA mba(x_arr, y_arr, z_arr); // Initialize with scattered data.
mba.MBAalg(1,1,7); // Create spline surface.
UCBspl::SplineSurface surface = mba.getSplineSurface(); // Get the spline surface object
double x = (surface.umin() + surface.umax())/2.; // In the middle of the domain
double y = (surface.vmin() + surface.vmax())/2.;
double nx,ny,nz;
double z = surface.f(x,y); // Find height of surface in (x,y).
surface.normalVector(x,y, nx,ny,nz); // Find normal vector of surface in (x,y).
std::cout << "z-value in (" << x << ',' << y << ") = " << z << std::endl;
std::cout << "Normal in (" << x << ',' << y << ") = (" << nx << "," << ny << "," << nz << ")" << std::endl;
// Sample surface and print to VRML file.
UCBspl::printVRMLgrid("C_CE_FICHIER.wrl", surface, 50, 50, true);
// return 0;
}
je débute en C++ et j'ai quelques soucis avec une bibliothèques que j'ai téléchargé.
Pour faire simple, j'ai créé un projet DLL permettant normalement d'utiliser cette bibliothèque C++ avec Scilab.
Normalement, cette bibliothèque trouve les données à traiter grâce au chemin du fichier données.
Or je souhaiterais lui faire passer en entrée des tableaux de doubles(correspondant aux données à traiter).
Malheuresement j'ai un problème d'incompatibilité entre les boost::shared_ptr<dVec> x_arr(new std::vector<double>); et les double xx[].
Si quelqu'un à une idée pour m'aider. Merci d'avance
Voici mon main:
// justdoit.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <MBA.h>
#include <UCButils.h>
#include <boost/shared_ptr.hpp>
#include <PointAccessUtils.h>
//Functions declarations
//extern "C" __declspec(dllexport) void __cdecl justdoit(boost::shared_ptr<dVec> xx, boost::shared_ptr<dVec> yy, boost::shared_ptr<dVec> zz);
//extern "C" __declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]);
//extern "C" __declspec(dllexport) void __cdecl justdoit(std::vector<double> xx, std::vector<double> yy, std::vector<double> zz);
extern "C" __declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
//int main() {
//__declspec(dllexport) void justdoit(boost::shared_ptr<dVec>& xx, boost::shared_ptr<dVec> yy, boost::shared_ptr<dVec> zz){
//__declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]){
//__declspec(dllexport) void __cdecl justdoit(std::vector<double> xx, std::vector<double> yy, std::vector<double> zz){
__declspec(dllexport) void __cdecl justdoit(double xx[], double yy[], double zz[]){
// Read scattered data from file
// Each array is maintained by "standard" boost shared pointers.
// (See for example www.boost.org)
// The format is assumed to be:
// x y z
// x y z
// x y z
// etc
// for (int i=0; i<21; i++) {
// yy[i]=xx[i]-3;
// }
typedef std::vector<double> dVec;
boost::shared_ptr<dVec> x_arr(new std::vector<double>);
boost::shared_ptr<dVec> y_arr(new std::vector<double>);
boost::shared_ptr<dVec> z_arr(new std::vector<double>);
/*
boost::shared_ptr<dVec> xxx(&xx);
boost::shared_ptr<dVec> yyy(&yy);
boost::shared_ptr<dVec> zzz(&zz);
*/
/*
x_arr=xx;
y_arr=yy;
z_arr=zz;
*/
//UCBspl::readScatteredData("c:/user/U236436/work/Interfacage_MP/MOVB/justdoit/Data/scat.dat", *x_arr, *y_arr, *z_arr);
MBA mba(x_arr, y_arr, z_arr); // Initialize with scattered data.
mba.MBAalg(1,1,7); // Create spline surface.
UCBspl::SplineSurface surface = mba.getSplineSurface(); // Get the spline surface object
double x = (surface.umin() + surface.umax())/2.; // In the middle of the domain
double y = (surface.vmin() + surface.vmax())/2.;
double nx,ny,nz;
double z = surface.f(x,y); // Find height of surface in (x,y).
surface.normalVector(x,y, nx,ny,nz); // Find normal vector of surface in (x,y).
std::cout << "z-value in (" << x << ',' << y << ") = " << z << std::endl;
std::cout << "Normal in (" << x << ',' << y << ") = (" << nx << "," << ny << "," << nz << ")" << std::endl;
// Sample surface and print to VRML file.
UCBspl::printVRMLgrid("C_CE_FICHIER.wrl", surface, 50, 50, true);
// return 0;
}
A voir également:
- Problème C++ boost::shared_ptr
- Dialogue boost - Accueil - Guide streaming
- Quick boost - Télécharger - Optimisation
- Ram boost - Télécharger - Optimisation
- Driver boost - Télécharger - Pilotes & Matériel
- Logiciel boost pc - Accueil - Utilitaires