If it is ok, I am going to ask some basic c++ questions:
1. I need the OCCGenerateMesh function in 3 files. If I define this function in all 3 files I get multiple definitions (the cxx-files are compiled into one target). So what is the obvious way to define the function only in one file and use it in all 3 files.
2. Defining the function in a header file and including it in all the 3 cxx files also results in redefinition errors.
3. How to handle occparam? I found this in the
netgen code:
https://github.com/NGSolve/netgen/blob/ ... L1952L1953
Code: Select all
DLL_HEADER extern OCCParameters occparam;
OCCParameters occparam;
I wonder what's the obvious way to define this interface function so that it is useable in any cxx file and to allow also the external function to be used if an older version of
netgen is installed. Does specifying external function in a header file works?
My attempt to create the interface looked like this:
Code: Select all
#ifndef _NETGENPlugin_interface_HXX_
#define _NETGENPlugin_interface_HXX_
#include <occgeom.hpp>
#include <meshing.hpp>
#include <nglib.h>
namespace netgen {
#ifdef NEW_NETGEN_INTERFACE
int OCCGenerateMesh(OCCGeometry& geo, shared_ptr<netgen::Mesh>& mesh, netgen::MeshingParameters& params)
{
geo.SetOCCParameters(netgen::occparam);
auto result = geo.GenerateMesh(mesh, params);
mesh->SetGeometry(geo);
return result;
}
#else
#if NETGEN_VERSION >= NETGEN_VERSION_STRING(6,2)
DLL_HEADER extern int OCCGenerateMesh(OCCGeometry&, shared_ptr<Mesh>&, MeshingParameters&);
#elif NETGEN_VERSION >= NETGEN_VERSION_STRING(6,0)
DLL_HEADER extern int OCCGenerateMesh(OCCGeometry&, shared_ptr<Mesh>&, MeshingParameters&, int, int);
#elif NETGEN_VERSION >= NETGEN_VERSION_STRING(5,0)
DLL_HEADER extern int OCCGenerateMesh(OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
#else
DLL_HEADER extern int OCCGenerateMesh(OCCGeometry&, Mesh*&, int, int, char*);
#endif
#endif
}
#endif