#Compilation problem using .h and .cxx files

5 messages · Page 1 of 1 (latest)

tranquil cypress
#

Hi, Im making a project about polygonal meshes, I have a function where I have to make like a imaginary box which covers an object like in the photo. Im using a .h file and a .cxx file where I put the implementation, I already have everything but when I compilate it somehow the compiler doesn't detect the function.

cxx file:

#include "mallas.h"
#include <iostream>
#include <fstream>
using namespace std;

std::vector<Objeto3D> objetosCargados;
void envolvente(std::string nombre_objeto) {
    if (objetosCargados.empty()) {
        std::cout << "Ningún objeto ha sido cargado en memoria." << std::endl;
        return;
    }

    if (objetosCargados.empty()) {
        // Caso: Generar caja envolvente global
        Objeto3D env_global;
        env_global.nombre = "env_global";
        for (const auto& objeto : objetosCargados) {
            calcularCajaEnvolvente(objeto, env_global);
        }
            objetosCargados.push_back(env_global);
        std::cout << "La caja envolvente de los objetos en memoria se ha generado con el nombre env_global y se ha agregado a los objetos en memoria." << std::endl;
    } else {
        // Caso: Generar caja envolvente para un objeto específico
        auto it = std::find_if(objetosCargados.begin(), objetosCargados.end(),
                               [&nombre_objeto](const Objeto3D& obj) { return obj.nombre == nombre_objeto; });

        if (it == objetosCargados.end()) {
            std::cout << "El objeto " << nombre_objeto << " no ha sido cargado en memoria." << std::endl;
        } else {
            Objeto3D env_objeto;
            env_objeto.nombre = "env_" + nombre_objeto;
            calcularCajaEnvolvente(*it, env_objeto);
                objetosCargados.push_back(env_objeto);
            std::cout << "La caja envolvente del objeto " << nombre_objeto << " se ha generado con el nombre "
                      << env_objeto.nombre << " y se ha agregado a los objetos en memoria." << std::endl;
        }
    }
}
craggy compassBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

sleek nacelle
#

looks like you header declares a function that takes a const std::string& parameter but your .cxx file defines a function that takes an std::string by value?

tranquil cypress
#

omg it worked, thank you very much

#

!solved