Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/13691_mantid_geom_binding_fillin…
Browse files Browse the repository at this point in the history
…args'
  • Loading branch information
peterfpeterson committed Oct 15, 2015
2 parents 5b44344 + 7d572dc commit b0eaa04
Show file tree
Hide file tree
Showing 26 changed files with 291 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@ using namespace boost::python;
void export_BoundingBox() {
class_<BoundingBox>("BoundingBox", "Constructs a zero-sized box")
.def(init<double, double, double, double, double, double>(
(arg("xmax"), arg("ymax"), arg("zmax"), arg("xmin"), arg("ymin"),
arg("zmin")),
(arg("self"), arg("xmax"), arg("ymax"), arg("zmax"), arg("xmin"),
arg("ymin"), arg("zmin")),
"Constructs a box from the six given points"))

.def("minPoint", &BoundingBox::minPoint,
.def("minPoint", &BoundingBox::minPoint, arg("self"),
return_value_policy<copy_const_reference>(),
"Returns a V3D containing the values of the minimum of the box. See "
"mantid.kernel.V3D")

.def("maxPoint", &BoundingBox::maxPoint,
.def("maxPoint", &BoundingBox::maxPoint, arg("self"),
return_value_policy<copy_const_reference>(),
"Returns a V3D containing the values of the minimum of the box. See "
"mantid.kernel.V3D")

.def("centrePoint", &BoundingBox::centrePoint,
.def("centrePoint", &BoundingBox::centrePoint, arg("self"),
"Returns a V3D containing the coordinates of the centre point. See "
"mantid.kernel.V3D")

.def("width", &BoundingBox::width, "Returns a V3D containing the widths "
"for each dimension. See "
"mantid.kernel.V3D")
.def("width", &BoundingBox::width, arg("self"),
"Returns a V3D containing the widths "
"for each dimension. See "
"mantid.kernel.V3D")

.def("isNull", &BoundingBox::isNull,
.def("isNull", &BoundingBox::isNull, arg("self"),
"Returns true if the box has no dimensions that have been set")

.def("isPointInside", &BoundingBox::isPointInside,
.def("isPointInside", &BoundingBox::isPointInside, arg("self"),
"Returns true if the given point is inside the object. See "
"mantid.kernel.V3D")

.def("doesLineIntersect",
(bool (BoundingBox::*)(const V3D &, const V3D &) const) &
BoundingBox::doesLineIntersect,
(arg("startPoint"), arg("lineDir")),
(arg("self"), arg("startPoint"), arg("lineDir")),
"Returns true if the line given by the starting point & direction "
"vector passes through the box");
}
44 changes: 29 additions & 15 deletions Framework/PythonInterface/mantid/geometry/src/Exports/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,55 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Component_getParamDescription,
void export_Component() {
class_<Component, bases<IComponent>, boost::noncopyable>("Component", no_init)
.def("getParameterNames", &Component::getParameterNames,
Component_getParameterNames())
.def("hasParameter", &Component::hasParameter, Component_hasParameter())
Component_getParameterNames((arg("self"), arg("recursive") = true)))
.def("hasParameter", &Component::hasParameter,
Component_hasParameter(
(arg("self"), arg("name"), arg("recursive") = true)))
.def("getNumberParameter", &Component::getNumberParameter,
Component_getNumberParameter())
Component_getNumberParameter(
(arg("self"), arg("pname"), arg("recursive") = true)))
.def("getBoolParameter", &Component::getBoolParameter,
Component_getBoolParameter())
Component_getBoolParameter(
(arg("self"), arg("pname"), arg("recursive") = true)))
.def("getPositionParameter", &Component::getPositionParameter,
Component_getPositionParameter())
Component_getPositionParameter(
(arg("self"), arg("pname"), arg("recursive") = true)))
.def("getRotationParameter", &Component::getRotationParameter,
Component_getRotationParameter())
Component_getRotationParameter(
(arg("self"), arg("pname"), arg("recursive") = true)))
.def("getStringParameter", &Component::getStringParameter,
Component_getStringParameter())
Component_getStringParameter(
(arg("self"), arg("pname"), arg("recursive") = true)))
.def("getIntParameter", &Component::getIntParameter,
Component_getIntParameter())
Component_getIntParameter(
(arg("self"), arg("pname"), arg("recursive") = true)))
//
.def("getRotation", &Component::getRotation, Component_getRotation())
.def("getRotation", &Component::getRotation,
Component_getRotation(arg("self")))
.def("getRelativePos", &Component::getRelativePos,
Component_getRelativePos())
Component_getRelativePos(arg("self")))
//
.def("getParamShortDescription", &Component::getParamShortDescription,
Component_getParamShortDescription())
Component_getParamShortDescription(
(arg("self"), arg("pname"), arg("recursive") = true)))
.def("getParamDescription", &Component::getParamDescription,
Component_getParamDescription())
.def("getShortDescription", &Component::getShortDescription,
Component_getParamDescription(
(arg("self"), arg("pname"), arg("recursive") = true)))

.def("getShortDescription", &Component::getShortDescription, arg("self"),
"Return the short description of current parameterized component")
.def("getDescription", &Component::getDescription,
.def("getDescription", &Component::getDescription, arg("self"),
"Return the description of current parameterized component")
.def("setDescription", &Component::setDescription,
(arg("self"), arg("descr")),
"Set component's description, works only if the component is "
"parameterized component")

// HACK -- python should return parameters regardless of type. this is
// untill rows below do not work
.def("getParameterType", &Component::getParameterType,
Component_getParameterType())
Component_getParameterType(
(arg("self"), arg("pname"), arg("recursive") = true)))
//// this does not work for some obvious or not obvious reasons
//.def("getParameter", &Component::getNumberParameter,
// Component_getNumberParameter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using namespace boost::python;
void export_DetectorGroup() {
class_<DetectorGroup, bases<IDetector>, boost::noncopyable>("DetectorGroup",
no_init)
.def("getDetectorIDs", &DetectorGroup::getDetectorIDs,
.def("getDetectorIDs", &DetectorGroup::getDetectorIDs, arg("self"),
"Returns the list of detector IDs within this group")
.def("getNameSeparator", &DetectorGroup::getNameSeparator,
.def("getNameSeparator", &DetectorGroup::getNameSeparator, arg("self"),
"Returns separator for list of names of detectors");
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ void export_Goniometer() {
getEulerAngles_overloads(args("self", "convention"),
"Default convention is \'YZX\'. Universal "
"goniometer is \'YZY\'"))
.def("getR", &Goniometer::getR, return_readonly_numpy())
.def("setR", &setR);
.def("getR", &Goniometer::getR, arg("self"), return_readonly_numpy())
.def("setR", &setR, (arg("self"), arg("rot")));
}
28 changes: 19 additions & 9 deletions Framework/PythonInterface/mantid/geometry/src/Exports/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,35 @@ void export_Group() {
.value("Associativity", Group::Associativity);

class_<Group, boost::noncopyable>("Group", no_init)
.def("__init__", make_constructor(&constructGroupFromString),
.def("__init__",
make_constructor(&constructGroupFromString, default_call_policies(),
(arg("symmetryOperationString"))),
"Construct a group from the provided initializer string.")
.def("__init__", make_constructor(&constructGroupFromVector),
.def("__init__",
make_constructor(&constructGroupFromVector, default_call_policies(),
(arg("symmetryOperationVector"))),
"Construct a group from the provided symmetry operation list.")
.def("__init__", make_constructor(&constructGroupFromPythonList),
.def("__init__", make_constructor(&constructGroupFromPythonList,
default_call_policies(),
(arg("symmetryOperationList"))),
"Construct a group from a python generated symmetry operation list.")
.def("getOrder", &Group::order, "Returns the order of the group.")
.def("getCoordinateSystem", &Group::getCoordinateSystem,
.def("getOrder", &Group::order, arg("self"),
"Returns the order of the group.")
.def("getCoordinateSystem", &Group::getCoordinateSystem, arg("self"),
"Returns the type of coordinate system to distinguish groups with "
"hexagonal system definition.")
.def("getSymmetryOperations", &Group::getSymmetryOperations,
.def("getSymmetryOperations", &Group::getSymmetryOperations, arg("self"),
"Returns the symmetry operations contained in the group.")
.def("getSymmetryOperationStrings", &getSymmetryOperationStrings,
arg("self"),
"Returns the x,y,z-strings for the contained symmetry operations.")
.def("containsOperation", &Group::containsOperation,
(arg("self"), arg("operation")),
"Checks whether a SymmetryOperation is included in Group.")
.def("isGroup", &Group::isGroup, "Checks whether the contained symmetry "
"operations fulfill the group axioms.")
.def("fulfillsAxiom", &Group::fulfillsAxiom,
.def("isGroup", &Group::isGroup, arg("self"),
"Checks whether the contained symmetry "
"operations fulfill the group axioms.")
.def("fulfillsAxiom", &Group::fulfillsAxiom, (arg("self"), arg("axiom")),
"Checks if the contained symmetry operations fulfill the specified "
"group axiom.");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ void export_ICompAssembly() {

class_<ICompAssembly, boost::python::bases<IComponent>, boost::noncopyable>(
"ICompAssembly", no_init)
.def("nelements", &ICompAssembly::nelements,
.def("nelements", &ICompAssembly::nelements, arg("self"),
"Returns the number of elements in the assembly")
.def("__getitem__", &ICompAssembly::operator[],
.def("__getitem__",
&ICompAssembly::operator[], (arg("self"), arg("index")),
"Return the component at the given index");
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ void export_IComponent() {
register_ptr_to_python<boost::shared_ptr<IComponent>>();

class_<IComponent, boost::noncopyable>("IComponent", no_init)
.def("getPos", &IComponent::getPos,
.def("getPos", &IComponent::getPos, arg("self"),
"Returns the absolute position of the component")
.def("getDistance", &getDistance, "Returns the distance, in metres, "
"between this and the given component")
.def("getName", &IComponent::getName, "Returns the name of the component")
.def("getFullName", &IComponent::getFullName,
.def("getDistance", &getDistance, (arg("self"), arg("other")),
"Returns the distance, in metres, "
"between this and the given component")
.def("getName", &IComponent::getName, arg("self"),
"Returns the name of the component")
.def("getFullName", &IComponent::getFullName, arg("self"),
"Returns full path name of component")
.def("type", &IComponent::type,
.def("type", &IComponent::type, arg("self"),
"Returns the type of the component represented as a string")
.def("getRelativeRot", &IComponent::getRelativeRot,
.def("getRelativeRot", &IComponent::getRelativeRot, arg("self"),
return_value_policy<copy_const_reference>(),
"Returns the relative rotation as a Quat");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ void export_IDetector() {

class_<IDetector, bases<IObjComponent>, boost::noncopyable>("IDetector",
no_init)
.def("getID", &IDetector::getID, "Returns the detector ID")
.def("isMasked", &IDetector::isMasked, "Returns the value of the masked "
"flag. True means ignore this "
"detector")
.def("isMonitor", &IDetector::isMonitor,
.def("getID", &IDetector::getID, arg("self"), "Returns the detector ID")
.def("isMasked", &IDetector::isMasked, arg("self"),
"Returns the value of the masked flag. True means ignore this "
"detector")
.def("isMonitor", &IDetector::isMonitor, arg("self"),
"Returns True if the detector is marked as a monitor in the IDF")
.def("solidAngle", &IDetector::solidAngle, "Return the solid angle in "
"steradians between this "
"detector and an observer")
.def("solidAngle", &IDetector::solidAngle, (arg("self"), arg("observer")),
"Return the solid angle in steradians between this "
"detector and an observer")
.def("getTwoTheta", &IDetector::getTwoTheta,
(arg("self"), arg("observer"), arg("axis")),
"Calculate the angle between this detector, another component and "
"an axis")
.def("getPhi", &IDetector::getPhi,
.def("getPhi", &IDetector::getPhi, arg("self"),
"Returns the azimuthal angle of this detector");
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ void export_IMDDimension() {
register_ptr_to_python<boost::shared_ptr<IMDDimension>>();

class_<IMDDimension, boost::noncopyable>("IMDDimension", no_init)
.def("getName", &IMDDimension::getName, "Return the name of the "
"dimension as can be displayed "
"along the axis")
.def("getMaximum", &IMDDimension::getMaximum,
.def("getName", &IMDDimension::getName, arg("self"),
"Return the name of the dimension as can be displayed "
"along the axis")
.def("getMaximum", &IMDDimension::getMaximum, arg("self"),
"Return the maximum extent of this dimension")
.def("getMinimum", &IMDDimension::getMinimum,
.def("getMinimum", &IMDDimension::getMinimum, arg("self"),
"Return the maximum extent of this dimension")
.def("getNBins", &IMDDimension::getNBins,
.def("getNBins", &IMDDimension::getNBins, arg("self"),
"Return the number of bins dimension have (an integrated has one). "
"A axis directed along dimension would have getNBins+1 axis points.")
.def("getX", &IMDDimension::getX,
.def("getX", &IMDDimension::getX, (arg("self"), arg("ind")),
"Return coordinate of the axis at the given index")
.def("getDimensionId", &IMDDimension::getDimensionId,
.def("getDimensionId", &IMDDimension::getDimensionId, arg("self"),
"Return a short name which identify the dimension among other "
"dimension."
"A dimension can be usually find by its ID and various ")
.def("getUnits", &getUnitsAsStr,
.def("getUnits", &getUnitsAsStr, arg("self"),
"Return the units associated with this dimension.")
.def("getMDFrame", &getMDFrame,
.def("getMDFrame", &getMDFrame, arg("self"),
"Return the multidimensional frame for this dimension.");
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void export_IObjComponent() {

class_<IObjComponent, boost::python::bases<IComponent>, boost::noncopyable>(
"IObjComponent", no_init)
.def("shape", &getShape, "Get the object that represents the physical "
"shape of this component");
.def("shape", &getShape, arg("self"), "Get the object that represents "
"the physical shape of this "
"component");
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,39 @@ void export_Instrument() {

class_<Instrument, bases<CompAssembly>, boost::noncopyable>("Instrument",
no_init)
.def("getSample", &Instrument::getSample,
.def("getSample", &Instrument::getSample, arg("self"),
return_value_policy<RemoveConstSharedPtr>(),
"Return the object that represents the sample")

.def("getSource", &Instrument::getSource,
.def("getSource", &Instrument::getSource, arg("self"),
return_value_policy<RemoveConstSharedPtr>(),
"Return the object that represents the source")

.def("getComponentByName",
(boost::shared_ptr<IComponent>(Instrument::*)(const std::string &)) &
Instrument::getComponentByName,
"Returns the named component")
(arg("self"), arg("cname")), "Returns the named component")

.def("getDetector", (boost::shared_ptr<IDetector>(
Instrument::*)(const detid_t &) const) &
Instrument::getDetector,
(arg("self"), arg("detector_id")),
"Returns the detector with the given ID")

.def("getReferenceFrame",
(boost::shared_ptr<const ReferenceFrame>(Instrument::*)()) &
Instrument::getReferenceFrame,
return_value_policy<RemoveConstSharedPtr>(),
arg("self"), return_value_policy<RemoveConstSharedPtr>(),
"Returns the reference frame attached that defines the instrument "
"axes")

.def("getValidFromDate", &Instrument::getValidFromDate,
.def("getValidFromDate", &Instrument::getValidFromDate, arg("self"),
"Return the valid from date of the instrument")

.def("getValidToDate", &Instrument::getValidToDate,
.def("getValidToDate", &Instrument::getValidToDate, arg("self"),
"Return the valid to date of the instrument")

.def("getBaseInstrument", &Instrument::baseInstrument,
.def("getBaseInstrument", &Instrument::baseInstrument, arg("self"),
return_value_policy<RemoveConstSharedPtr>(),
"Return reference to the base instrument");
;

;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ void export_MDFrame() {
register_ptr_to_python<boost::shared_ptr<MDFrame>>();

class_<MDFrame, boost::noncopyable>("MDFrame", no_init)
.def("getUnitLabel", &MDFrame::getUnitLabel)
.def("name", &MDFrame::name);
.def("getUnitLabel", &MDFrame::getUnitLabel, arg("self"))
.def("name", &MDFrame::name, arg("self"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ void export_Object() {
class_<Object, boost::noncopyable>("Object", no_init)
.def("getBoundingBox",
(const BoundingBox &(Object::*)() const) & Object::getBoundingBox,
return_value_policy<copy_const_reference>(),
arg("self"), return_value_policy<copy_const_reference>(),
"Return the axis-aligned bounding box for this shape")

.def("getShapeXML", &Object::getShapeXML,
.def("getShapeXML", &Object::getShapeXML, arg("self"),
"Returns the XML that was used to create this shape.");
}
Loading

0 comments on commit b0eaa04

Please sign in to comment.