| 169 | |
| 170 | |
| 171 | void TriVector::Coercion( |
| 172 | PyObject* from, |
| 173 | PyObject** to ) |
| 174 | { |
| 175 | // check for None first - never coerce this type! <halldor 2006.07.13> |
| 176 | if( from == Py_None ) |
| 177 | { |
| 178 | return; |
| 179 | } |
| 180 | |
| 181 | // convert from any standard numeric value |
| 182 | PyObject* pyfloat = PyNumber_Float( from ); |
| 183 | |
| 184 | if( !pyfloat ) |
| 185 | return; |
| 186 | |
| 187 | float f = (float)PyFloat_AS_DOUBLE( pyfloat ); |
| 188 | Py_DECREF( pyfloat ); |
| 189 | |
| 190 | // the return value |
| 191 | ITriVectorPtr vec; |
| 192 | vec.Attach( new OTriVector ); |
| 193 | vec->SetXYZ( f, f, f ); |
| 194 | *to = PyOS->WrapBlueObject( vec ); |
| 195 | } |
| 196 | #endif |
| 197 | |
| 198 | |