AppReverseEngineeringPy.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <TColgp_Array1OfPnt.hxx>
00027 # include <Handle_Geom_BSplineSurface.hxx>
00028 #endif
00029
00030 #include <CXX/Objects.hxx>
00031 #include <Base/PyObjectBase.h>
00032 #include <Base/Console.h>
00033
00034 #include <Mod/Part/App/BSplineSurfacePy.h>
00035
00036 #include "ApproxSurface.h"
00037
00038 using namespace Reen;
00039
00040
00041
00042 static PyObject * approxSurface(PyObject *self, PyObject *args)
00043 {
00044 PyObject *o;
00045 int orderU=4,orderV=4;
00046 int pointsU=6,pointsV=6;
00047 if (!PyArg_ParseTuple(args, "O|iiii",&o,&orderU,&orderV,&pointsU,&pointsV))
00048 return NULL;
00049
00050 PY_TRY {
00051 Py::List l(o);
00052 TColgp_Array1OfPnt clPoints(0, l.size()-1);
00053
00054 int index=0;
00055 for (Py::List::iterator it = l.begin(); it != l.end(); ++it) {
00056 Py::Tuple t(*it);
00057 clPoints(index++) = gp_Pnt(
00058 (double)Py::Float(t.getItem(0)),
00059 (double)Py::Float(t.getItem(1)),
00060 (double)Py::Float(t.getItem(2)));
00061 }
00062
00063 Reen::BSplineParameterCorrection pc(orderU,orderV,pointsU,pointsV);
00064 Handle_Geom_BSplineSurface hSurf;
00065
00066
00067 pc.EnableSmoothing(true, 0.1f, 1.0f, 0.0f, 0.0f);
00068 hSurf = pc.CreateSurface(clPoints, 5, true, 1.0);
00069 if (!hSurf.IsNull()) {
00070 return new Part::BSplineSurfacePy(new Part::GeomBSplineSurface(hSurf));
00071 }
00072
00073 PyErr_SetString(PyExc_Exception, "Computation of B-Spline surface failed");
00074 return 0;
00075 } PY_CATCH;
00076 }
00077
00078
00079 struct PyMethodDef ReverseEngineering_methods[] = {
00080 {"approxSurface" , approxSurface, 1},
00081 {NULL, NULL}
00082 };