MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / PyUtilGetFrameData

Function PyUtilGetFrameData

Code/Source/PythonAPI/PyUtils.cxx:729–787  ·  view source on GitHub ↗

-------------------- PyUtilGetFrameData -------------------- Get the data used to define a coordinate frame. The input data can be 1) center and normal 2) PathFrame object Returns: pathPoint

Source from the content-addressed store, hash-verified

727// Returns: pathPoint
728//
729bool
730PyUtilGetFrameData(PyUtilApiFunction& api, PyObject* centerArg, std::array<double,3>& center,
731 PyObject* normalArg, std::array<double,3>& normal, PyObject* frameObj, sv3::PathElement::PathPoint& pathPoint)
732{
733 // Get the center and normal data.
734 //
735 bool haveCenter = false;
736
737 if ((centerArg != nullptr) || (normalArg != nullptr)) {
738 if ((centerArg == nullptr) || (normalArg == nullptr)) {
739 api.error("Both a 'center' and a 'normal' argument must be given.");
740 return false;
741 }
742 std::string emsg;
743 double cval[3];
744 if (!PyUtilGetPointData(centerArg, emsg, cval)) {
745 api.error("The 'center' argument " + emsg);
746 return false;
747 }
748 double nval[3];
749 if (!PyUtilGetPointData(normalArg, emsg, nval)) {
750 api.error("The 'normal' argument " + emsg);
751 return false;
752 }
753
754 for (int i = 0; i < 3; i++) {
755 center[i] = cval[i];
756 normal[i] = nval[i];
757 }
758 haveCenter = true;
759 }
760
761 if ((frameObj != nullptr) && haveCenter) {
762 api.error("Both a 'center/normal' and 'frame' argument was given; only one is allowed.");
763 return false;
764 }
765
766 if (haveCenter) {
767 return true;
768 }
769
770 // Get the frame argument value.
771 //
772 if (frameObj != nullptr) {
773 std::string emsg;
774 if (!PyPathFrameGetData(frameObj, pathPoint.id, pathPoint.pos, pathPoint.rotation, pathPoint.tangent, emsg)) {
775 api.error("The 'frame' argument " + emsg);
776 return false;
777 }
778 center[0] = pathPoint.pos[0];
779 center[1] = pathPoint.pos[1];
780 center[2] = pathPoint.pos[2];
781 } else {
782 api.error("A 'center/normal' or 'frame' argument must be given.");
783 return false;
784 }
785
786 return true;

Callers 2

PyCircleSegmentationInitFunction · 0.85

Calls 3

PyUtilGetPointDataFunction · 0.85
PyPathFrameGetDataFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected