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

Function Geom_loft_nurbs

Code/Source/PythonAPI/Geometry_PyModule.cxx:636–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634");
635
636static PyObject *
637Geom_loft_nurbs(PyObject* self, PyObject* args, PyObject* kwargs)
638{
639 #define ndbg_Geom_loft_nurbs
640 #ifdef dbg_Geom_loft_nurbs
641 std::cout << " " << std::endl;
642 std::cout << "========== Geom_loft_nurbs ==========" << std::endl;
643 #endif
644 auto api = PyUtilApiFunction("O!O!|i", PyRunTimeErr, __func__);
645 static char *keywords[] = {"polydata_list", "loft_options", "num_sections", NULL};
646 PyObject* objListArg;
647 PyObject* loftOptsArg;
648 int num_sections = 12;
649
650 if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &PyList_Type, &objListArg,
651 &PyLoftNurbsOptionsType, &loftOptsArg, &num_sections)) {
652 return api.argsError();
653 }
654
655 // Check the list of polydata curve profiles.
656 auto cvPolyDataList = GetGeometryObjects(api, objListArg);
657 int numProfiles = cvPolyDataList.size();
658 if (numProfiles == 0) {
659 return nullptr;
660 }
661
662 if (numProfiles < 2) {
663 api.error("At least two profiles are needed for lofing.");
664 return nullptr;
665 }
666
667 // Check that the profiles have the same number of points.
668 int numProfilePoints = 0;
669 for (auto const& profile : cvPolyDataList) {
670 int numPoints = profile->GetVtkPolyData()->GetNumberOfPoints();
671 if (numProfilePoints == 0) {
672 numProfilePoints = numPoints;
673 } else if (numPoints != numProfilePoints) {
674 api.error("Profiles do not have the same number of points.");
675 return nullptr;
676 }
677 }
678
679 // Extract loft option values from the loftOptions object.
680 //
681 int uDegree = LoftNurbsOptionsGetInt(loftOptsArg, LoftNurbsOptions::U_DEGREE);
682 int vDegree = LoftNurbsOptionsGetInt(loftOptsArg, LoftNurbsOptions::V_DEGREE);
683 double uSpacing = 1.0 / (num_sections * numProfiles);
684 double vSpacing = 1.0 / numProfilePoints;
685 char* uKnotSpanType = LoftNurbsOptionsGetString(loftOptsArg, LoftNurbsOptions::U_KNOT_SPAN_TYPE);
686 char* vKnotSpanType = LoftNurbsOptionsGetString(loftOptsArg, LoftNurbsOptions::V_KNOT_SPAN_TYPE);
687 char* uParametricSpanType = LoftNurbsOptionsGetString(loftOptsArg, LoftNurbsOptions::U_PARAMETRIC_SPAN_TYPE);
688 char* vParametricSpanType = LoftNurbsOptionsGetString(loftOptsArg, LoftNurbsOptions::V_PARAMETRIC_SPAN_TYPE);
689
690 #ifdef dbg_Geom_loft_nurbs
691 std::cout << "[Geom_loft_nurbs] numProfilePoints: " << numProfilePoints << std::endl;
692 std::cout << "[Geom_loft_nurbs] uDegree: " << uDegree << std::endl;
693 std::cout << "[Geom_loft_nurbs] vDegree: " << vDegree << std::endl;

Callers

nothing calls this directly

Calls 10

GetGeometryObjectsFunction · 0.85
LoftNurbsOptionsGetIntFunction · 0.85
argsErrorMethod · 0.80
sizeMethod · 0.80
errorMethod · 0.80
GetNumberOfPointsMethod · 0.80
dataMethod · 0.80
GetVtkPolyDataMethod · 0.45

Tested by

no test coverage detected