파이썬 도구에서 기존의 C++ 코드 인 NvTriStrip을 사용하고 싶습니다.Python에서 ** 매개 변수를 통해 구조체의 할당 된 배열을 반환하는 C++ 함수를 사용하는 방법은 무엇입니까?
SWIG는 간단한 매개 변수를 사용하여 함수를 쉽게 처리하지만 기본 함수 인 GenerateStrips
은 훨씬 더 복잡합니다.
primGroups
이 실제로 출력 매개 변수이고이를 delete[]
으로 정리해야한다는 것을 나타내려면 SWIG 인터페이스 파일에 무엇을 넣어야합니까?
///////////////////////////////////////////////////////////////////////////
// GenerateStrips()
//
// in_indices: input index list, the indices you would use to render
// in_numIndices: number of entries in in_indices
// primGroups: array of optimized/stripified PrimitiveGroups
// numGroups: number of groups returned
//
// Be sure to call delete[] on the returned primGroups to avoid leaking mem
//
bool GenerateStrips(const unsigned short* in_indices,
const unsigned int in_numIndices,
PrimitiveGroup** primGroups,
unsigned short* numGroups,
bool validateEnabled = false);
, 여기에 PrimitiveGroup
선언입니다 :
enum PrimType
{
PT_LIST,
PT_STRIP,
PT_FAN
};
struct PrimitiveGroup
{
PrimType type;
unsigned int numIndices;
unsigned short* indices;
PrimitiveGroup() : type(PT_STRIP), numIndices(0), indices(NULL) {}
~PrimitiveGroup()
{
if(indices)
delete[] indices;
indices = NULL;
}
};
SWIG 기반 솔루션이 아직 제공되지 않으면 언어 바인딩을 만드는 대신 Boost Python을 사용하는 것이 좋습니다. http://www.boost.org/doc/libs/1_43_0/libs/python/ doc/index.html – Rakis