我有以下头文件
possion_surface_reconstructor.h
#ifndef POISSON_SURFACE_RECONSTRUCTOR_H
#define POISSON_SURFACE_RECONSTRUCTOR_H
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <iostream>
#include <boost/format.hpp>
#include "../core/PreProcessor.h"
#include "../core/MyMiscellany.h"
#include "../core/CmdLineParser.h"
#include "../core/PPolynomial.h"
#include "../core/FEMTree.h"
#include "../core/Ply.h"
#include "../core/PointStreamData.h"
#include "../core/Image.h"
#include "callbacks.h"
namespace MeshingAdapter
{
#undef USE_DOUBLE // If enabled, double-precesion is used
#define DATA_DEGREE 0 // The order of the B-Spline used to splat in data for color interpolation
#define WEIGHT_DEGREE 2 // The order of the B-Spline used to splat in the weights for density estimation
#define NORMAL_DEGREE 2 // The order of the B-Spline used to splat in the normals for constructing the Laplacian constraints
#define DEFAULT_FEM_DEGREE 1 // The default finite-element degree
#define DEFAULT_FEM_BOUNDARY BOUNDARY_NEUMANN // The default finite-element boundary type
#define DIMENSION 3
cmdLineParameter< char* >
In("in"),
Out("out"),
TempDir("tempDir"),
Grid("grid"),
Tree("tree"),
Transform("xForm");
cmdLineReadable
Performance("performance"),
ShowResidual("showResidual"),
NoComments("noComments"),
PolygonMesh("polygonMesh"),
NonManifold("nonManifold"),
ASCII("ascii"),
Density("density"),
LinearFit("linearFit"),
PrimalGrid("primalGrid"),
ExactInterpolation("exact"),
Normals("normals"),
Colors("colors"),
InCore("inCore"),
Verbose("verbose");
cmdLineParameter< int >
#ifndef FAST_COMPILE
Degree("degree", DEFAULT_FEM_DEGREE),
#endif // !FAST_COMPILE
Depth("depth", 8),
KernelDepth("kernelDepth"),
Iters("iters", 8),
FullDepth("fullDepth", 5),
BaseDepth("baseDepth", 0),
BaseVCycles("baseVCycles", 1),
#ifndef FAST_COMPILE
BType("bType", DEFAULT_FEM_BOUNDARY + 1),
#endif // !FAST_COMPILE
MaxMemoryGB("maxMemory", 0),
#ifdef _OPENMP
ParallelType("parallel", (int)ThreadPool::OPEN_MP),
#else // !_OPENMP
ParallelType("parallel", (int)ThreadPool::THREAD_POOL),
#endif // _OPENMP
ScheduleType("schedule", (int)ThreadPool::DefaultSchedule),
ThreadChunkSize("chunkSize", (int)ThreadPool::DefaultChunkSize),
Threads("threads", (int)std::thread::hardware_concurrency());
cmdLineParameter< float >
DataX("data", 32.f),
SamplesPerNode("samplesPerNode", 1.5f),
Scale("scale", 1.1f),
Width("width", 0.f),
Confidence("confidence", 0.f),
ConfidenceBias("confidenceBias", 0.f),
CGSolverAccuracy("cgAccuracy", 1e-3f),
PointWeight("pointWeight");
cmdLineReadable* params[] =
{
#ifndef FAST_COMPILE
&Degree,
&BType,
#endif // !FAST_COMPILE
&In,
&Depth,
&Out,
&Transform,
&Width,
&Scale,
&Verbose,
&CGSolverAccuracy,
&NoComments,
&KernelDepth,
&SamplesPerNode,
&Confidence,
&NonManifold,
&PolygonMesh,
&ASCII,
&ShowResidual,
&ConfidenceBias,
&BaseDepth,
&BaseVCycles,
&PointWeight,
&Grid,
&Threads,
&Tree,
&Density,
&FullDepth,
&Iters,
&DataX,
&Colors,
&Normals,
&LinearFit,
&PrimalGrid,
&TempDir,
&ExactInterpolation,
&Performance,
&MaxMemoryGB,
&InCore,
&ParallelType,
&ScheduleType,
&ThreadChunkSize,
NULL
};
class PoissonSurfaceReconstructor
{
public:
PoissonSurfaceReconstructor(
ProgressCallback& progressCallback,
WarningCallback& warningCallback,
ErrorCallback& errorCallback);
bool ExecuteSurfaceReconstruction(int argc, char* argv[]);
private:
template< unsigned int Dim, class Real >
struct FEMTreeProfiler;
template< unsigned int Dim, typename Real >
struct ConstraintDual;
template< unsigned int Dim, typename Real >
struct SystemDual;
template< unsigned int Dim >
struct SystemDual< Dim, double >;
template< class Real, typename ... SampleData, unsigned int ... FEMSigs >
int Execute(int argc, char* argv[], UIntPack< FEMSigs ... >);
template< unsigned int Dim, class Real, typename ... SampleData >
int Execute(int argc, char* argv[]);
template< typename Real, unsigned int Dim >
int WriteGrid(ConstPointer(Real) values, int res, const char* fileName);
template< typename Vertex, typename Real, typename SetVertexFunction, unsigned int ... FEMSigs, typename ... SampleData >
int ExtractMesh(
UIntPack< FEMSigs ... >,
std::tuple< SampleData ... >,
FEMTree< sizeof ... (FEMSigs), Real >& tree,
const DenseNodeData< Real, UIntPack< FEMSigs ... > >& solution,
Real isoValue,
const std::vector< typename FEMTree< sizeof ... (FEMSigs),
Real >::PointSample >* samples,
std::vector< MultiPointStreamData< Real, PointStreamNormal< Real, DIMENSION >,
MultiPointStreamData< Real, SampleData ... > > >* sampleData,
const typename FEMTree< sizeof ... (FEMSigs), Real >::template DensityEstimator< WEIGHT_DEGREE >* density,
const SetVertexFunction& SetVertex,
std::vector< std::string >& comments,
XForm< Real, sizeof...(FEMSigs) + 1 > iXForm);
template< class Real, unsigned int Dim >
XForm< Real, Dim + 1 > GetBoundingBoxXForm(Point< Real, Dim > min, Point< Real, Dim > max, Real scaleFactor);
template< class Real, unsigned int Dim >
XForm< Real, Dim + 1 > GetBoundingBoxXForm(
Point< Real, Dim > min,
Point< Real, Dim > max,
Real width,
Real scaleFactor,
int& depth);
template< class Real, unsigned int Dim >
XForm< Real, Dim + 1 > GetPointXForm(InputPointStream< Real, Dim >& stream, Real width, Real scaleFactor, int& depth);
template< class Real, unsigned int Dim >
XForm< Real, Dim + 1 > GetPointXForm(InputPointStream< Real, Dim >& stream, Real scaleFactor);
template<typename... Arguments>
std::string FormatString(const std::string& fmt, const Arguments&... args);
double Weight(double v, double start, double end);
const float DefaultPointWeightMultiplier = 2.f;
ProgressCallback _progressCallback;
WarningCallback _warningCallback;
ErrorCallback _errorCallback;
};
}
#endif // POISSON_SURFACE_RECONSTRUCTOR_H
支持该类的.cpp文件可以正常编译。我可以将此代码编译为.exe并进行一些调整,这就是我想要的。但是,我需要从C#调用此代码,因此我创建了一个可从C#调用的包装器类。
configuration.h
#ifndef MESHING_DLL_CONFIG_H #define MESHING_DLL_CONFIG_H #if defined(_MSC_VER) # define LIBRARY_EXPORT __declspec(dllexport) # define LIBRARY_IMPORT __declspec(dllimport) #elif defined(__GNUC__) && __GNUC__ > 3 # define LIBRARY_EXPORT __attribute__((visibility("default"))) # define LIBRARY_IMPORT __attribute__((visibility("default"))) #else # define LIBRARY_EXPORT # define LIBRARY_IMPORT #endif #ifdef LIBRARY_API_EXPORTS # define LIBRARY_API LIBRARY_EXPORT #elif LIBRARY_API_IMPORTS # define LIBRARY_API LIBRARY_IMPORT #else # define LIBRARY_API #endif #endif /* MESHING_DLL_CONFIG_H */
wrappers.h
#ifndef MESHING_WRAPPERS_H #define MESHING_WRAPPERS_H #include <exception> #include "configuration.h" #include "callbacks.h" #include "poisson_surface_reconstructor.h" typedef intptr_t ArrayHandle; extern "C" { LIBRARY_EXPORT bool ExecutePoissonSurfaceReconstruction( int argc, char* argv[], ProgressCallback progressCallback, WarningCallback warningCallback, ErrorCallback errorCallback); LIBRARY_EXPORT bool Release(ArrayHandle arrayHandle); } #endif // MESHING_WRAPPERS_H
wrappers.cpp
#include "wrappers.h" using namespace MeshingAdapter; LIBRARY_EXPORT bool ExecutePoissonSurfaceReconstruction( int argc, char* argv[], ProgressCallback progressCallback, WarningCallback warningCallback, ErrorCallback errorCallback) { try { PoissonSurfaceReconstructor* poissonSurfaceRecon = new PoissonSurfaceReconstructor( progressCallback, warningCallback, errorCallback); bool success = poissonSurfaceRecon->ExecuteSurfaceReconstruction(argc, argv); delete poissonSurfaceRecon; return success; } catch (const std::exception& ex) { errorCallback(ex.what()); return false; } } LIBRARY_EXPORT bool Release(ArrayHandle arrayHandle) { // #TODO can we do this smarter? return true; }
但是,仅包含
possion_surface_reconstructor.h
会导致114LNK2005
错误,主要是我从不同项目引用的类中。一个例子是
2> wrappers.obj:错误LNK2005:“私有:静态布尔ThreadPool :: _ Close”(?_Close @ ThreadPool @@ 0_NA)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“ public:静态无符号__int64 ThreadPool :: DefaultChunkSize”(?DefaultChunkSize @ ThreadPool @@ 2_KA)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“私有:静态类std :: vector> ThreadPool :: _ Threads”(?_ Threads @ ThreadPool @@ 0V?$ vector @ Vthread @ std @@ V?$ allocator @ Vthread @ std @ @@ 2 @@ std @@ A)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“私有:静态类std :: condition_variable ThreadPool :: _ DoneWithWork”(?_DoneWithWork @ ThreadPool @@ 0Vcondition_variable @ std @@ A)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“ public:静态int const(* HyperCube :: MarchingSquares :: edges)[5]”(?edges @ MarchingSquares @ HyperCube @@ 2QAY04 $$ CBHA)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:poisson_surface_reconstructor.obj中已经定义了“ char const * * type_names”(?type_names @@ 3PAPEBDA)2> wrappers.obj:错误LNK2005:“ char const * * BoundaryNames”(?BoundaryNames @@ 3PAPEBDA)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“ char const * * ShowGlobalResidualNames”(?ShowGlobalResidualNames @@ 3PAPEBDA)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“私有:静态无符号整数易失性ThreadPool :: __ RemainingTasks”(?_ RemainingTasks @ ThreadPool @@ 0IC)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“ public:static char const * const StackTracer :: exec”(?exec @ StackTracer @@ 2PEBDEB)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“ public:静态字符const * const ImageWriterParams :: DefaultTileExtension”(?DefaultTileExtension @ ImageWriterParams @@ 2PEBDEB)已在poisson_surface_reconstructor.obj中定义2> wrappers.obj:错误LNK2005:“ public:静态枚举ThreadPool :: ScheduleType ThreadPool :: DefaultSchedule”(?DefaultSchedule @ ThreadPool @@ 2W4ScheduleType @ 1 @ A)已在poisson_surface_reconstructor.obj中定义。
还有更多。我对进入点的拆解为什么会引起这样的问题感到困惑。
我很高兴从上面说来这是不可复制的(我很乐意提供有问题的项目),但是代码很庞大;目的是要确定一些建议]
- 提供一些可能的原因吗?
谢谢。
我有以下头文件possion_surface_reconstructor.h #ifndef POISSON_SURFACE_RECONSTRUCTOR_H #define POISSON_SURFACE_RECONSTRUCTOR_H #include
还有更多。我对进入点的拆解为什么会引起这样的问题感到困惑。
您如何确定这就是导致此问题的原因?没有。