mardi 26 mai 2020

C++, problems with structures in classes

everyone if someone can help me I'll be very grateful. I've been trying to fill in the structure called m_Center by a function of the same class, I'm using eclipse to work and it gave the next errors messages:

-'m_Center' was not declared in this scope
-Field 'radius' could not be resolved
-Symbol 'm_Center' could not be resolved

My header file is Obstacles.h:

#ifndef SRC_OBSTACLES_H_
#define SRC_OBSTACLES_H_

#include <eigen3/Eigen/Dense>
#include <iostream>
#include <random>
#include <list>
#include <stdlib.h>
#include <time.h>

class CObstacles
{
protected:
    struct Center
    {
        float m_vXdCenterX;
        float m_vXdCenterY;
        float m_vXdCenterZ;
        double distance;
        Eigen::VectorXf v_XfAxisCyl;
        Eigen::VectorXf vXfP1;
        double radius;
    };
    Center m_Center;

public:
    CObstacles(double dradius, Eigen::VectorXf &m_vXdMaxBound, Eigen::VectorXf &m_vXdMinBound, int num_obstacles);
    ~CObstacles();

    void generate_obstacles(double dradius, Eigen::VectorXf &m_vXdMaxBound, Eigen::VectorXf &m_vXdMinBound, int num_obstacles);
};


#endif

while the Obstacles.cpp is:

#include "Obstacles.h"

CObstacles::CObstacles(double dradius, Eigen::VectorXf &m_vXdMaxBound, Eigen::VectorXf &m_vXdMinBound, int num_obstacles)
{
    double m_dradius = dradius;
    Eigen::VectorXf m_dvXdMaxBound = m_vXdMaxBound;
    Eigen::VectorXf m_dvXdMinBound = m_vXdMinBound;
    int dnum_obstacles = num_obstacles;
}

CObstacles::~CObstacles()
{
}

void generate_obstacles(double dradius, Eigen::VectorXf &m_vXdMaxBound, Eigen::VectorXf &m_vXdMinBound, int num_obstacles)
{
    srand(time(NULL));
    float aux_centerx, aux_centery;
    Eigen::Vector3f vXfP1;
    Eigen::Vector3f vXfP2;
    Eigen::Vector3f distance;
    for(int num_obs = 0; num_obs < num_obstacles; num_obs++)
    {
        aux_centerx = rand() % 20 + 1;
        aux_centery = rand() % 20 + 1;
        vXfP2 << aux_centerx, aux_centery, 0;
        vXfP1 << aux_centerx, aux_centery, 0;
        distance = vXfP2 - vXfP1;
        m_Center[num_obs].radius = dradius;
    }
}

Aucun commentaire:

Enregistrer un commentaire