void ParametersDialog::on_compute_clicked() { const Mesh::MeshObject& kernel = myMesh->Mesh.getValue(); if (kernel.hasSelectedFacets()) { std::vector<unsigned long> facets, points; kernel.getFacetsFromSelection(facets); points = kernel.getPointsFromFacets(facets); MeshCore::MeshPointArray coords = kernel.getKernel().GetPoints(points); // Copy points into right format FitParameter::Points fitpts; fitpts.insert(fitpts.end(), coords.begin(), coords.end()); coords.clear(); values = fitParameter->getParameter(fitpts); if (values.size() == spinBoxes.size()) { for (std::size_t i=0; i<values.size(); i++) { spinBoxes[i]->setValue(values[i]); } } meshSel.stopSelection(); meshSel.clearSelection(); } else { QMessageBox::warning(this, tr("No selection"), tr("Before fitting the surface select an area.")); } }
static PyObject * calculateEigenTransform(PyObject *self, PyObject *args) { PyObject *input; if (!PyArg_ParseTuple(args, "O",&input)) return NULL; if(! PySequence_Check(input) ){ PyErr_SetString(Base::BaseExceptionFreeCADError, "Input have to be a sequence of Base.Vector()"); return NULL; } PY_TRY { MeshCore::MeshKernel aMesh; MeshCore::MeshPointArray vertices; vertices.clear(); MeshCore::MeshFacetArray faces; faces.clear(); MeshCore::MeshPoint current_node; Py::Sequence list(input); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { PyObject* value = (*it).ptr(); if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) { Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value); Base::Vector3d* val = pcObject->getVectorPtr(); current_node.Set(float(val->x),float(val->y),float(val->z)); vertices.push_back(current_node); } } MeshCore::MeshFacet aFacet; aFacet._aulPoints[0] = 0;aFacet._aulPoints[1] = 1;aFacet._aulPoints[2] = 2; faces.push_back(aFacet); //Fill the Kernel with the temp smesh structure and delete the current containers aMesh.Adopt(vertices,faces); MeshCore::MeshEigensystem pca(aMesh); pca.Evaluate(); Base::Matrix4D Trafo = pca.Transform(); return new Base::PlacementPy(new Base::Placement(Trafo) ); } PY_CATCH; Py_Return; }