// Copyright (C) 2002-2003 Gideon May (gideon@computer.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. #include #include #include #include #include #include #include #include "held_ptr.hpp" #include "Math.hpp" using namespace boost::python; namespace PyOSG { void osgHeightField_setData(osg::HeightField * self, numeric::array& data) { object shape = data.getshape(); int rows = extract(shape[0]); int cols = extract(shape[1]); if((rows == 0) || (cols == 0)) { PyErr_SetString(PyExc_ValueError, "Invalid array dimensions"); throw_error_already_set(); return; } // Switch this to R,C maybe? self->allocate(cols,rows); float value = 0.0f; for(int r = 0; r < rows; ++r) { for(int c = 0; c < cols; ++c) { value = extract(data[make_tuple(r,c)]); self->setHeight(c, r, value); } } } void init_Shape3() { // InfinitePlane // class_, bases, boost::noncopyable> infplane("InfinitePlane"); // TriangleMesh class_, bases, boost::noncopyable> trimesh("TriangleMesh", no_init); trimesh.def(init<>()); trimesh.def("setVertices", &osg::TriangleMesh::setVertices); trimesh.def("getVertices", (osg::Vec3Array *(osg::TriangleMesh::*)()) &osg::TriangleMesh::getVertices, return_value_policy()); trimesh.def("setIndices", &osg::TriangleMesh::setIndices); trimesh.def("getIndices", (osg::IndexArray *(osg::TriangleMesh::*)()) &osg::TriangleMesh::getIndices, return_value_policy()); // ConvexHull class_, bases, boost::noncopyable> convhull("ConvexHull", no_init); convhull.def(init<>()); // HeightField - abstract base class class_, bases, boost::noncopyable> hfield("HeightField", no_init); hfield.def(init<>()); hfield.def("allocate", &osg::HeightField::allocate); hfield.def("getNumColumns", &osg::HeightField::getNumColumns); hfield.def("getNumRows", &osg::HeightField::getNumRows); hfield.def("setOrigin", &osg::HeightField::setOrigin); hfield.def("getOrigin", &osg::HeightField::getOrigin, return_value_policy()); hfield.def("setXInterval", &osg::HeightField::setXInterval); hfield.def("getXInterval", &osg::HeightField::getXInterval); hfield.def("setYInterval", &osg::HeightField::setYInterval); hfield.def("getYInterval", &osg::HeightField::getYInterval); hfield.def("setSkirtHeight", &osg::HeightField::setSkirtHeight); hfield.def("getSkirtHeight", &osg::HeightField::getSkirtHeight); hfield.def("setBorderWidth", &osg::HeightField::setBorderWidth); hfield.def("getBorderWidth", &osg::HeightField::getBorderWidth); hfield.def("setRotation", &osg::HeightField::setRotation); hfield.def("getRotation", &osg::HeightField::getRotation, return_value_policy()); hfield.def("computeRotationMatrix", &osg::HeightField::computeRotationMatrix); hfield.def("zeroRotation", &osg::HeightField::zeroRotation); hfield.def("setHeight", &osg::HeightField::setHeight); hfield.def("getHeight", (float (osg::HeightField::*)(unsigned int, unsigned int) const) &osg::HeightField::getHeight); hfield.def("setHeightData", &osgHeightField_setData); hfield.def("getVertex", &osg::HeightField::getVertex); hfield.def("getNormal", &osg::HeightField::getNormal); // Grid // class_, bases, boost::noncopyable> grid("Grid", no_init); // grid.def(init<>()); // grid.def("allocateGrid", &osg::Grid::allocateGrid); // grid.def("getHeight", (float (osg::Grid::*)(unsigned int, unsigned int) const) &osg::Grid::getHeight); // CompositeShape class_, bases, boost::noncopyable> cshape("CompositeShape", no_init); cshape.def(init<>()); cshape.def("setShape", &osg::CompositeShape::setShape, "Set the shape that encloses all of the children."); cshape.def("getShape", (osg::Shape *(osg::CompositeShape::*)()) &osg::CompositeShape::getShape, "Get the shape that encloses all of the children.", return_value_policy()); cshape.def("getNumChildren", &osg::CompositeShape::getNumChildren, "Get the number of children of this composite shape."); cshape.def("getChild", (osg::Shape *(osg::CompositeShape::*)(unsigned int)) &osg::CompositeShape::getChild, "Get a child", return_value_policy()); cshape.def("addChild", &osg::CompositeShape::addChild, "Add a child to the list"); cshape.def("removeChild", &osg::CompositeShape::removeChild, "remove a child from the list."); cshape.def("findChildNo", &osg::CompositeShape::findChildNo, "find the index number of child, if child is not found then it returns getNumChildren(),\n" "so should be used in similar sytle of STL's result!=end()."); } }