void visit(PyClass& cl) const { cl .def(bp::init<>("Default constructor")) .def(bp::init<Vector3,Vector3> ((bp::arg("linear"),bp::arg("angular")), "Initialize from linear and angular components (dont mix the order).")) .def(bp::init<Vector6>((bp::arg("Vector 6d")),"Init from a vector 6[f,n]")) .def(bp::init<Force>((bp::arg("other")),"Copy constructor.")) .add_property("linear", &ForcePythonVisitor::getLinear, &ForcePythonVisitor::setLinear, "Linear part of a *this, corresponding to the linear velocity in case of a Spatial velocity.") .add_property("angular", &ForcePythonVisitor::getAngular, &ForcePythonVisitor::setAngular, "Angular part of a *this, corresponding to the angular velocity in case of a Spatial velocity.") .add_property("vector", &ForcePythonVisitor::getVector, &ForcePythonVisitor::setVector, "Returns the components of *this as a 6d vector.") .add_property("np",&ForcePythonVisitor::getVector) .def("se3Action",&Force::template se3Action<Scalar,Options>, bp::args("M"),"Returns the result of the dual action of M on *this.") .def("se3ActionInverse",&Force::template se3ActionInverse<Scalar,Options>, bp::args("M"),"Returns the result of the dual action of the inverse of M on *this.") .def("setZero",&ForcePythonVisitor::setZero, "Set the linear and angular components of *this to zero.") .def("setRandom",&ForcePythonVisitor::setRandom, "Set the linear and angular components of *this to random values.") .def(bp::self + bp::self) .def(bp::self += bp::self) .def(bp::self - bp::self) .def(bp::self -= bp::self) .def(-bp::self) .def(bp::self == bp::self) .def(bp::self != bp::self) .def(bp::self * Scalar()) .def(Scalar() * bp::self) .def(bp::self / Scalar()) .def("isApprox",(bool (Force::*)(const Force & other, const Scalar & prec) const) &Force::isApprox,bp::args("other","prec"),"Returns true if *this is approximately equal to other, within the precision given by prec.") .def("isApprox",isApprox,bp::args("other"),"Returns true if *this is approximately equal to other.") .def("Random",&Force::Random,"Returns a random Force.") .staticmethod("Random") .def("Zero",&Force::Zero,"Returns a zero Force.") .staticmethod("Zero") .def_pickle(Pickle()) ; }
bool OSExchangeDataProviderWin::GetPickledData(CLIPFORMAT format, Pickle* data) const { DCHECK(data); FORMATETC format_etc = { format, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; bool success = false; STGMEDIUM medium; if(SUCCEEDED(source_object_->GetData(&format_etc, &medium))) { if(medium.tymed & TYMED_HGLOBAL) { base::win::ScopedHGlobal<char> c_data(medium.hGlobal); DCHECK_GT(c_data.Size(), 0u); // Need to subtract 1 as SetPickledData adds an extra byte to the end. *data = Pickle(c_data.get(), static_cast<int>(c_data.Size()-1)); success = true; } ReleaseStgMedium(&medium); } return success; }