This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/freestyle/intern/python/Convert.cpp
Maxime Curioni e4748940c0 soc-2008-mxcurioni: SWIG removal - completed SVertex and CurvePoint classes migration. Stabilized a lot of the code for C++ -> Python conversion. Added the correct rich comparison operator and tested it. Corrected 'dupplicate' typo and changde to __copy__ for Python API.
From now on, when a set should be output (PySet_Type), it is given as a list (PyList_Type). The reason is that it doesn't really matter what we bring back to the Python interpreter. The set is guaranteed in memory on the C++ side.

For the CurvePoint class, the userdata variable is not yet ported (and will probably available as a list or a dictionary). The CurvePoint implementation works except for the initialization from other CurvePoints: somehow, the inner variables don't seem to be correctly handled. I do not know if it is a bug in Freestyle or if the CurvePoint object's state is correct for my test case. CurvePoint needs more testing.
2008-07-17 06:35:30 +00:00

81 lines
1.6 KiB
C++

#include "Convert.h"
#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////////////////
PyObject *PyBool_from_bool( bool b ){
// SWIG_From_bool
return PyBool_FromLong( b ? 1 : 0);
}
PyObject *Vector_from_Vec2f( Vec2f vec ) {
float vec_data[2]; // because vec->_coord is protected
if( &vec != 0 ){
vec_data[0] = vec.x(); vec_data[1] = vec.y();
return newVectorObject( vec_data, 2, Py_NEW);
}
Py_RETURN_NONE;
}
PyObject *Vector_from_Vec3f( Vec3f vec ) {
float vec_data[3]; // because vec->_coord is protected
if( &vec != 0 ){
vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[2] = vec.z();
return newVectorObject( vec_data, 3, Py_NEW);
}
Py_RETURN_NONE;
}
PyObject *Vector_from_Vec3r( Vec3r vec ) {
float vec_data[3]; // because vec->_coord is protected
if( &vec != 0 ){
vec_data[0] = vec.x(); vec_data[1] = vec.y(); vec_data[2] = vec.z();
return newVectorObject( vec_data, 3, Py_NEW);
}
Py_RETURN_NONE;
}
PyObject *BPy_Id_from_Id( Id id ) {
BPy_Id *py_id;
if( &id != 0 ) {
py_id = (BPy_Id *) Id_Type.tp_new( &Id_Type, 0, 0 );
py_id->id = new Id( id.getFirst(), id.getSecond() );
return (PyObject *)py_id;
}
Py_RETURN_NONE;
}
PyObject *BPy_SVertex_from_SVertex( SVertex sv ) {
BPy_SVertex *py_sv;
if( &sv != 0 ) {
py_sv = (BPy_SVertex *) SVertex_Type.tp_new( &SVertex_Type, 0, 0 );
py_sv->sv = new SVertex( sv );
py_sv->py_if0D.if0D = py_sv->sv;
return (PyObject *)py_sv;
}
Py_RETURN_NONE;
}
///////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif