BSplineSurfacePyImp.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <Geom_BSplineCurve.hxx>
00027 # include <Geom_BSplineSurface.hxx>
00028 # include <Handle_Geom_BSplineCurve.hxx>
00029 # include <TColStd_Array1OfReal.hxx>
00030 # include <TColStd_Array2OfReal.hxx>
00031 # include <TColStd_Array1OfInteger.hxx>
00032 # include <TColgp_Array1OfPnt.hxx>
00033 # include <TColgp_Array2OfPnt.hxx>
00034 #endif
00035 
00036 #include <Base/GeometryPyCXX.h>
00037 #include <Base/VectorPy.h>
00038 
00039 #include "Geometry.h"
00040 #include "BSplineCurvePy.h"
00041 #include "BSplineSurfacePy.h"
00042 #include "BSplineSurfacePy.cpp"
00043 
00044 using namespace Part;
00045 
00046 // returns a string which represents the object e.g. when printed in python
00047 std::string BSplineSurfacePy::representation(void) const
00048 {
00049     return "<BSplineSurface object>";
00050 }
00051 
00052 PyObject *BSplineSurfacePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00053 {
00054     // create a new instance of BSplineSurfacePy and the Twin object 
00055     return new BSplineSurfacePy(new GeomBSplineSurface);
00056 }
00057 
00058 // constructor method
00059 int BSplineSurfacePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00060 {
00061     return 0;
00062 }
00063 
00064 PyObject* BSplineSurfacePy::bounds(PyObject *args)
00065 {
00066     if (!PyArg_ParseTuple(args, ""))
00067         return 0;
00068 
00069     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00070         (getGeometryPtr()->handle());
00071     Py::Tuple bound(4);
00072     Standard_Real u1,u2,v1,v2;
00073     surf->Bounds(u1,u2,v1,v2);
00074     bound.setItem(0,Py::Float(u1));
00075     bound.setItem(1,Py::Float(u2));
00076     bound.setItem(2,Py::Float(v1));
00077     bound.setItem(3,Py::Float(v2));
00078     return Py::new_reference_to(bound);
00079 }
00080 
00081 PyObject* BSplineSurfacePy::isURational(PyObject *args)
00082 {
00083     if (!PyArg_ParseTuple(args, ""))
00084         return 0;
00085 
00086     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00087         (getGeometryPtr()->handle());
00088     Standard_Boolean val = surf->IsURational();
00089     if (val) {
00090         Py_INCREF(Py_True);
00091         return Py_True;
00092     }
00093     else {
00094         Py_INCREF(Py_False);
00095         return Py_False;
00096     }
00097 }
00098 
00099 PyObject* BSplineSurfacePy::isVRational(PyObject *args)
00100 {
00101     if (!PyArg_ParseTuple(args, ""))
00102         return 0;
00103 
00104     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00105         (getGeometryPtr()->handle());
00106     Standard_Boolean val = surf->IsVRational();
00107     if (val) {
00108         Py_INCREF(Py_True);
00109         return Py_True;
00110     }
00111     else {
00112         Py_INCREF(Py_False);
00113         return Py_False;
00114     }
00115 }
00116 
00117 PyObject* BSplineSurfacePy::isUPeriodic(PyObject *args)
00118 {
00119     if (!PyArg_ParseTuple(args, ""))
00120         return 0;
00121 
00122     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00123         (getGeometryPtr()->handle());
00124     Standard_Boolean val = surf->IsUPeriodic();
00125     if (val) {
00126         Py_INCREF(Py_True);
00127         return Py_True;
00128     }
00129     else {
00130         Py_INCREF(Py_False);
00131         return Py_False;
00132     }
00133 }
00134 
00135 PyObject* BSplineSurfacePy::isVPeriodic(PyObject *args)
00136 {
00137     if (!PyArg_ParseTuple(args, ""))
00138         return 0;
00139 
00140     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00141         (getGeometryPtr()->handle());
00142     Standard_Boolean val = surf->IsVPeriodic();
00143     if (val) {
00144         Py_INCREF(Py_True);
00145         return Py_True;
00146     }
00147     else {
00148         Py_INCREF(Py_False);
00149         return Py_False;
00150     }
00151 }
00152 
00153 PyObject* BSplineSurfacePy::isUClosed(PyObject *args)
00154 {
00155     if (!PyArg_ParseTuple(args, ""))
00156         return 0;
00157 
00158     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00159         (getGeometryPtr()->handle());
00160     Standard_Boolean val = surf->IsUClosed();
00161     if (val) {
00162         Py_INCREF(Py_True);
00163         return Py_True;
00164     }
00165     else {
00166         Py_INCREF(Py_False);
00167         return Py_False;
00168     }
00169 }
00170 
00171 PyObject* BSplineSurfacePy::isVClosed(PyObject *args)
00172 {
00173     if (!PyArg_ParseTuple(args, ""))
00174         return 0;
00175 
00176     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00177         (getGeometryPtr()->handle());
00178     Standard_Boolean val = surf->IsVPeriodic();
00179     if (val) {
00180         Py_INCREF(Py_True);
00181         return Py_True;
00182     }
00183     else {
00184         Py_INCREF(Py_False);
00185         return Py_False;
00186     }
00187 }
00188 
00189 PyObject* BSplineSurfacePy::increaseDegree(PyObject *args)
00190 {
00191     int udegree, vdegree;
00192     if (!PyArg_ParseTuple(args, "ii",&udegree,&vdegree))
00193         return 0;
00194 
00195     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00196         (getGeometryPtr()->handle());
00197     surf->IncreaseDegree(udegree,vdegree);
00198     Py_Return;
00199 }
00200 
00201 PyObject* BSplineSurfacePy::increaseUMultiplicity(PyObject *args)
00202 {
00203     int mult=-1;
00204     int start, end;
00205     if (!PyArg_ParseTuple(args, "ii|i", &start, &end, &mult))
00206         return 0;
00207 
00208     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00209         (getGeometryPtr()->handle());
00210     if (mult == -1) {
00211         mult = end;
00212         surf->IncreaseUMultiplicity(start, mult);
00213     }
00214     else {
00215         surf->IncreaseUMultiplicity(start, end, mult);
00216     }
00217 
00218     Py_Return;
00219 }
00220 
00221 PyObject* BSplineSurfacePy::increaseVMultiplicity(PyObject *args)
00222 {
00223     int mult=-1;
00224     int start, end;
00225     if (!PyArg_ParseTuple(args, "ii|i", &start, &end, &mult))
00226         return 0;
00227 
00228     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00229         (getGeometryPtr()->handle());
00230     if (mult == -1) {
00231         mult = end;
00232         surf->IncreaseVMultiplicity(start, mult);
00233     }
00234     else {
00235         surf->IncreaseVMultiplicity(start, end, mult);
00236     }
00237 
00238     Py_Return;
00239 }
00240 
00241 PyObject* BSplineSurfacePy::incrementUMultiplicity(PyObject *args)
00242 {
00243     int start, end, mult;
00244     if (!PyArg_ParseTuple(args, "iii", &start, &end, &mult))
00245         return 0;
00246 
00247     try {
00248         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00249             (getGeometryPtr()->handle());
00250         surf->IncrementUMultiplicity(start, end, mult);
00251     }
00252     catch (Standard_Failure) {
00253         Handle_Standard_Failure e = Standard_Failure::Caught();
00254         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00255         return 0;
00256     }
00257 
00258     Py_Return;
00259 }
00260 
00261 PyObject* BSplineSurfacePy::incrementVMultiplicity(PyObject *args)
00262 {
00263     int start, end, mult;
00264     if (!PyArg_ParseTuple(args, "iii", &start, &end, &mult))
00265         return 0;
00266 
00267     try {
00268         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00269             (getGeometryPtr()->handle());
00270         surf->IncrementVMultiplicity(start, end, mult);
00271     }
00272     catch (Standard_Failure) {
00273         Handle_Standard_Failure e = Standard_Failure::Caught();
00274         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00275         return 0;
00276     }
00277 
00278     Py_Return;
00279 }
00280 
00281 PyObject* BSplineSurfacePy::insertUKnot(PyObject *args)
00282 {
00283     double U, tol = 0.0;
00284     int M=1;
00285     PyObject* add = Py_True;
00286     if (!PyArg_ParseTuple(args, "did|O!", &U, &M, &tol, &PyBool_Type, &add))
00287         return 0;
00288 
00289     try {
00290         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00291             (getGeometryPtr()->handle());
00292         surf->InsertUKnot(U,M,tol,(add==Py_True));
00293     }
00294     catch (Standard_Failure) {
00295         Handle_Standard_Failure e = Standard_Failure::Caught();
00296         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00297         return 0;
00298     }
00299 
00300     Py_Return;
00301 }
00302 
00303 PyObject* BSplineSurfacePy::insertUKnots(PyObject *args)
00304 {
00305     double tol = 0.0;
00306     PyObject* add = Py_True;
00307     PyObject* obj1;
00308     PyObject* obj2;
00309     if (!PyArg_ParseTuple(args, "O!O!|dO!", &PyList_Type, &obj1,
00310                                             &PyList_Type, &obj2,
00311                                             &tol, &PyBool_Type, &add))
00312         return 0;
00313 
00314     try {
00315         Py::List knots(obj1);
00316         TColStd_Array1OfReal k(1,knots.size());
00317         int index=1;
00318         for (Py::List::iterator it = knots.begin(); it != knots.end(); ++it) {
00319             Py::Float val(*it);
00320             k(index++) = (double)val;
00321         }
00322         Py::List mults(obj2);
00323         TColStd_Array1OfInteger m(1,mults.size());
00324         index=1;
00325         for (Py::List::iterator it = mults.begin(); it != mults.end(); ++it) {
00326             Py::Int val(*it);
00327             m(index++) = (int)val;
00328         }
00329 
00330         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00331             (getGeometryPtr()->handle());
00332         surf->InsertUKnots(k,m,tol,(add==Py_True));
00333         Py_Return;
00334     }
00335     catch (Standard_Failure) {
00336         Handle_Standard_Failure e = Standard_Failure::Caught();
00337         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00338         return 0;
00339     }
00340 
00341     Py_Return;
00342 }
00343 
00344 PyObject* BSplineSurfacePy::insertVKnot(PyObject *args)
00345 {
00346     double V, tol = 0.0;
00347     int M=1;
00348     PyObject* add = Py_True;
00349     if (!PyArg_ParseTuple(args, "did|O!", &V, &M, &tol, &PyBool_Type, &add))
00350         return 0;
00351 
00352     try {
00353         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00354             (getGeometryPtr()->handle());
00355         surf->InsertVKnot(V,M,tol,(add==Py_True));
00356     }
00357     catch (Standard_Failure) {
00358         Handle_Standard_Failure e = Standard_Failure::Caught();
00359         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00360         return 0;
00361     }
00362 
00363     Py_Return;
00364 }
00365 
00366 PyObject* BSplineSurfacePy::insertVKnots(PyObject *args)
00367 {
00368     double tol = 0.0;
00369     PyObject* add = Py_True;
00370     PyObject* obj1;
00371     PyObject* obj2;
00372     if (!PyArg_ParseTuple(args, "O!O!|dO!", &PyList_Type, &obj1,
00373                                             &PyList_Type, &obj2,
00374                                             &tol, &PyBool_Type, &add))
00375         return 0;
00376 
00377     try {
00378         Py::List knots(obj1);
00379         TColStd_Array1OfReal k(1,knots.size());
00380         int index=1;
00381         for (Py::List::iterator it = knots.begin(); it != knots.end(); ++it) {
00382             Py::Float val(*it);
00383             k(index++) = (double)val;
00384         }
00385         Py::List mults(obj2);
00386         TColStd_Array1OfInteger m(1,mults.size());
00387         index=1;
00388         for (Py::List::iterator it = mults.begin(); it != mults.end(); ++it) {
00389             Py::Int val(*it);
00390             m(index++) = (int)val;
00391         }
00392 
00393         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00394             (getGeometryPtr()->handle());
00395         surf->InsertUKnots(k,m,tol,(add==Py_True));
00396         Py_Return;
00397     }
00398     catch (Standard_Failure) {
00399         Handle_Standard_Failure e = Standard_Failure::Caught();
00400         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00401         return 0;
00402     }
00403 
00404     Py_Return;
00405 }
00406 
00407 PyObject* BSplineSurfacePy::removeUKnot(PyObject *args)
00408 {
00409     double tol;
00410     int Index,M;
00411     if (!PyArg_ParseTuple(args, "iid", &Index, &M, &tol))
00412         return 0;
00413 
00414     try {
00415         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00416             (getGeometryPtr()->handle());
00417         Standard_Boolean ok = surf->RemoveUKnot(Index,M,tol);
00418         if (ok) {
00419             Py_INCREF(Py_True);
00420             return Py_True;
00421         }
00422         else {
00423             Py_INCREF(Py_False);
00424             return Py_False;
00425         }
00426     }
00427     catch (Standard_Failure) {
00428         Handle_Standard_Failure e = Standard_Failure::Caught();
00429         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00430         return 0;
00431     }
00432 }
00433 
00434 PyObject* BSplineSurfacePy::removeVKnot(PyObject *args)
00435 {
00436     double tol;
00437     int Index,M;
00438     if (!PyArg_ParseTuple(args, "iid", &Index, &M, &tol))
00439         return 0;
00440 
00441     try {
00442         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00443             (getGeometryPtr()->handle());
00444         Standard_Boolean ok = surf->RemoveVKnot(Index,M,tol);
00445         if (ok) {
00446             Py_INCREF(Py_True);
00447             return Py_True;
00448         }
00449         else {
00450             Py_INCREF(Py_False);
00451             return Py_False;
00452         }
00453     }
00454     catch (Standard_Failure) {
00455         Handle_Standard_Failure e = Standard_Failure::Caught();
00456         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00457         return 0;
00458     }
00459 }
00460 
00461 PyObject* BSplineSurfacePy::segment(PyObject *args)
00462 {
00463     double u1,u2,v1,v2;
00464     if (!PyArg_ParseTuple(args, "dddd", &u1,&u2,&v1,&v2))
00465         return 0;
00466     try {
00467         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00468             (getGeometryPtr()->handle());
00469         surf->Segment(u1,u2,v1,v2);
00470         Py_Return;
00471     }
00472     catch (Standard_Failure) {
00473         Handle_Standard_Failure e = Standard_Failure::Caught();
00474         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00475         return 0;
00476     }
00477 }
00478 
00479 PyObject* BSplineSurfacePy::setUKnot(PyObject *args)
00480 {
00481     int Index, M=-1;
00482     double K;
00483     if (!PyArg_ParseTuple(args, "id|i", &Index, &K, &M))
00484         return 0;
00485 
00486     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00487         (getGeometryPtr()->handle());
00488     if (M == -1) {
00489         surf->SetUKnot(Index, K);
00490     }
00491     else {
00492         surf->SetUKnot(Index, K, M);
00493     }
00494 
00495     Py_Return;
00496 }
00497 
00498 PyObject* BSplineSurfacePy::setVKnot(PyObject *args)
00499 {
00500     int Index, M=-1;
00501     double K;
00502     if (!PyArg_ParseTuple(args, "id|i", &Index, &K, &M))
00503         return 0;
00504 
00505     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00506         (getGeometryPtr()->handle());
00507     if (M == -1) {
00508         surf->SetUKnot(Index, K);
00509     }
00510     else {
00511         surf->SetUKnot(Index, K, M);
00512     }
00513 
00514     Py_Return;
00515 }
00516 
00517 PyObject* BSplineSurfacePy::getUKnot(PyObject *args)
00518 {
00519     int Index;
00520     if (!PyArg_ParseTuple(args, "i", &Index))
00521         return 0;
00522 
00523     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00524         (getGeometryPtr()->handle());
00525     double M = surf->UKnot(Index);
00526 
00527     return Py_BuildValue("d",M);
00528 }
00529 
00530 PyObject* BSplineSurfacePy::getVKnot(PyObject *args)
00531 {
00532     int Index;
00533     if (!PyArg_ParseTuple(args, "i", &Index))
00534         return 0;
00535 
00536     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00537         (getGeometryPtr()->handle());
00538     double M = surf->VKnot(Index);
00539 
00540     return Py_BuildValue("d",M);
00541 }
00542 
00543 PyObject* BSplineSurfacePy::setUKnots(PyObject *args)
00544 {
00545     PyObject* obj;
00546     if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &obj))
00547         return 0;
00548     try {
00549         Py::List list(obj);
00550         TColStd_Array1OfReal k(1,list.size());
00551         int index=1;
00552         for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00553             Py::Float val(*it);
00554             k(index++) = (double)val;
00555         }
00556 
00557         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00558             (getGeometryPtr()->handle());
00559         surf->SetUKnots(k);
00560         Py_Return;
00561     }
00562     catch (Standard_Failure) {
00563         Handle_Standard_Failure e = Standard_Failure::Caught();
00564         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00565         return 0;
00566     }
00567 }
00568 
00569 PyObject* BSplineSurfacePy::setVKnots(PyObject *args)
00570 {
00571     PyObject* obj;
00572     if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &obj))
00573         return 0;
00574     try {
00575         Py::List list(obj);
00576         TColStd_Array1OfReal k(1,list.size());
00577         int index=1;
00578         for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00579             Py::Float val(*it);
00580             k(index++) = (double)val;
00581         }
00582 
00583         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00584             (getGeometryPtr()->handle());
00585         surf->SetVKnots(k);
00586         Py_Return;
00587     }
00588     catch (Standard_Failure) {
00589         Handle_Standard_Failure e = Standard_Failure::Caught();
00590         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00591         return 0;
00592     }
00593 }
00594 
00595 PyObject* BSplineSurfacePy::getUKnots(PyObject *args)
00596 {
00597     if (!PyArg_ParseTuple(args, ""))
00598         return 0;
00599     try {
00600         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00601             (getGeometryPtr()->handle());
00602         TColStd_Array1OfReal w(1,surf->NbUKnots());
00603         surf->UKnots(w);
00604         Py::List knots;
00605         for (Standard_Integer i=w.Lower(); i<=w.Upper(); i++) {
00606             knots.append(Py::Float(w(i)));
00607         }
00608         return Py::new_reference_to(knots);
00609     }
00610     catch (Standard_Failure) {
00611         Handle_Standard_Failure e = Standard_Failure::Caught();
00612         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00613         return 0;
00614     }
00615 }
00616 
00617 PyObject* BSplineSurfacePy::getVKnots(PyObject *args)
00618 {
00619     if (!PyArg_ParseTuple(args, ""))
00620         return 0;
00621     try {
00622         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00623             (getGeometryPtr()->handle());
00624         TColStd_Array1OfReal w(1,surf->NbVKnots());
00625         surf->VKnots(w);
00626         Py::List knots;
00627         for (Standard_Integer i=w.Lower(); i<=w.Upper(); i++) {
00628             knots.append(Py::Float(w(i)));
00629         }
00630         return Py::new_reference_to(knots);
00631     }
00632     catch (Standard_Failure) {
00633         Handle_Standard_Failure e = Standard_Failure::Caught();
00634         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00635         return 0;
00636     }
00637 }
00638 
00639 PyObject* BSplineSurfacePy::setPole(PyObject *args)
00640 {
00641     int uindex, vindex;
00642     double weight=-1.0;
00643     PyObject* p;
00644     if (!PyArg_ParseTuple(args, "iiO!|d", &uindex,&vindex,&(Base::VectorPy::Type),&p,&weight))
00645         return 0;
00646     Base::Vector3d vec = static_cast<Base::VectorPy*>(p)->value();
00647     gp_Pnt pnt(vec.x, vec.y, vec.z);
00648     try {
00649         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00650             (getGeometryPtr()->handle());
00651         if (weight < 0.0)
00652             surf->SetPole(uindex,vindex,pnt);
00653         else
00654             surf->SetPole(uindex,vindex,pnt,weight);
00655         Py_Return;
00656     }
00657     catch (Standard_Failure) {
00658         Handle_Standard_Failure e = Standard_Failure::Caught();
00659         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00660         return 0;
00661     }
00662 }
00663 
00664 PyObject* BSplineSurfacePy::setPoleCol(PyObject *args)
00665 {
00666     int vindex;
00667     PyObject* obj;
00668     PyObject* obj2=0;
00669     if (!PyArg_ParseTuple(args, "iO!|O!",&vindex,&PyList_Type,&obj,&PyList_Type,&obj2))
00670         return 0;
00671     try {
00672         Py::List list(obj);
00673         TColgp_Array1OfPnt poles(1, list.size());
00674         int index=1;
00675         for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00676             Py::Vector p(*it);
00677             Base::Vector3d v = p.toVector();
00678             poles(index++) = gp_Pnt(v.x,v.y,v.z);
00679         }
00680 
00681         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00682             (getGeometryPtr()->handle());
00683         if (obj2 == 0) {
00684             surf->SetPoleCol(vindex, poles);
00685         }
00686         else {
00687             Py::List list(obj2);
00688             TColStd_Array1OfReal weights(1, list.size());
00689             int index=1;
00690             for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00691                 weights(index++) = (double)Py::Float(*it);
00692             }
00693             surf->SetPoleCol(vindex, poles, weights);
00694         }
00695 
00696         Py_Return;
00697     }
00698     catch (Standard_Failure) {
00699         Handle_Standard_Failure e = Standard_Failure::Caught();
00700         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00701         return 0;
00702     }
00703 }
00704 
00705 PyObject* BSplineSurfacePy::setPoleRow(PyObject *args)
00706 {
00707     int uindex;
00708     PyObject* obj;
00709     PyObject* obj2=0;
00710     if (!PyArg_ParseTuple(args, "iO!|O!",&uindex,&PyList_Type,&obj,&PyList_Type,&obj2))
00711         return 0;
00712     try {
00713         Py::List list(obj);
00714         TColgp_Array1OfPnt poles(1, list.size());
00715         int index=1;
00716         for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00717             Py::Vector p(*it);
00718             Base::Vector3d v = p.toVector();
00719             poles(index++) = gp_Pnt(v.x,v.y,v.z);
00720         }
00721 
00722         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00723             (getGeometryPtr()->handle());
00724         if (obj2 == 0) {
00725             surf->SetPoleRow(uindex, poles);
00726         }
00727         else {
00728             Py::List list(obj2);
00729             TColStd_Array1OfReal weights(1, list.size());
00730             int index=1;
00731             for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00732                 weights(index++) = (double)Py::Float(*it);
00733             }
00734             surf->SetPoleRow(uindex, poles, weights);
00735         }
00736 
00737         Py_Return;
00738     }
00739     catch (Standard_Failure) {
00740         Handle_Standard_Failure e = Standard_Failure::Caught();
00741         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00742         return 0;
00743     }
00744 }
00745 
00746 PyObject* BSplineSurfacePy::getPole(PyObject *args)
00747 {
00748     int uindex,vindex;
00749     if (!PyArg_ParseTuple(args, "ii", &uindex,&vindex))
00750         return 0;
00751     try {
00752         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00753             (getGeometryPtr()->handle());
00754         gp_Pnt pnt = surf->Pole(uindex,vindex);
00755         Base::VectorPy* vec = new Base::VectorPy(Base::Vector3d(
00756             pnt.X(), pnt.Y(), pnt.Z()));
00757         return vec;
00758     }
00759     catch (Standard_Failure) {
00760         Handle_Standard_Failure e = Standard_Failure::Caught();
00761         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00762         return 0;
00763     }
00764 }
00765 
00766 PyObject* BSplineSurfacePy::getPoles(PyObject *args)
00767 {
00768     if (!PyArg_ParseTuple(args, ""))
00769         return 0;
00770     try {
00771         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00772             (getGeometryPtr()->handle());
00773         TColgp_Array2OfPnt p(1,surf->NbUPoles(),1,surf->NbVPoles());
00774         surf->Poles(p);
00775         Py::List poles;
00776         for (Standard_Integer i=p.LowerRow(); i<=p.UpperRow(); i++) {
00777             Py::List row;
00778             for (Standard_Integer j=p.LowerCol(); j<=p.UpperCol(); j++) {
00779                 const gp_Pnt& pole = p(i,j);
00780                 row.append(Py::Object(new Base::VectorPy(
00781                     Base::Vector3d(pole.X(),pole.Y(),pole.Z()))));
00782             }
00783             poles.append(row);
00784         }
00785         return Py::new_reference_to(poles);
00786     }
00787     catch (Standard_Failure) {
00788         Handle_Standard_Failure e = Standard_Failure::Caught();
00789         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00790         return 0;
00791     }
00792 }
00793 
00794 PyObject* BSplineSurfacePy::setWeight(PyObject *args)
00795 {
00796     int uindex,vindex;
00797     double weight;
00798     if (!PyArg_ParseTuple(args, "iid",&uindex,&vindex,&weight))
00799         return 0;
00800     try {
00801         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00802             (getGeometryPtr()->handle());
00803         surf->SetWeight(uindex,vindex,weight);
00804         Py_Return;
00805     }
00806     catch (Standard_Failure) {
00807         Handle_Standard_Failure e = Standard_Failure::Caught();
00808         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00809         return 0;
00810     }
00811 }
00812 
00813 PyObject* BSplineSurfacePy::setWeightCol(PyObject *args)
00814 {
00815     int vindex;
00816     PyObject* obj;
00817     if (!PyArg_ParseTuple(args, "iO!",&vindex,&PyList_Type,&obj))
00818         return 0;
00819     try {
00820         Py::List list(obj);
00821         TColStd_Array1OfReal weights(1, list.size());
00822         int index=1;
00823         for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00824             weights(index++) = (double)Py::Float(*it);
00825         }
00826 
00827         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00828             (getGeometryPtr()->handle());
00829         surf->SetWeightCol(vindex, weights);
00830         Py_Return;
00831     }
00832     catch (Standard_Failure) {
00833         Handle_Standard_Failure e = Standard_Failure::Caught();
00834         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00835         return 0;
00836     }
00837 }
00838 
00839 PyObject* BSplineSurfacePy::setWeightRow(PyObject *args)
00840 {
00841     int uindex;
00842     PyObject* obj;
00843     if (!PyArg_ParseTuple(args, "iO!",&uindex,&PyList_Type,&obj))
00844         return 0;
00845     try {
00846         Py::List list(obj);
00847         TColStd_Array1OfReal weights(1, list.size());
00848         int index=1;
00849         for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
00850             weights(index++) = (double)Py::Float(*it);
00851         }
00852 
00853         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00854             (getGeometryPtr()->handle());
00855         surf->SetWeightRow(uindex, weights);
00856         Py_Return;
00857     }
00858     catch (Standard_Failure) {
00859         Handle_Standard_Failure e = Standard_Failure::Caught();
00860         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00861         return 0;
00862     }
00863 }
00864 
00865 PyObject* BSplineSurfacePy::getWeight(PyObject *args)
00866 {
00867     int uindex,vindex;
00868     if (!PyArg_ParseTuple(args, "ii",&uindex,&vindex))
00869         return 0;
00870     try {
00871         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00872             (getGeometryPtr()->handle());
00873         double w = surf->Weight(uindex,vindex);
00874         return Py_BuildValue("d", w);
00875     }
00876     catch (Standard_Failure) {
00877         Handle_Standard_Failure e = Standard_Failure::Caught();
00878         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00879         return 0;
00880     }
00881 }
00882 
00883 PyObject* BSplineSurfacePy::getWeights(PyObject *args)
00884 {
00885     if (!PyArg_ParseTuple(args, ""))
00886         return 0;
00887     try {
00888         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00889             (getGeometryPtr()->handle());
00890         TColStd_Array2OfReal w(1,surf->NbUPoles(),1,surf->NbVPoles());
00891         surf->Weights(w);
00892         Py::List weights;
00893         for (Standard_Integer i=w.LowerRow(); i<=w.UpperRow(); i++) {
00894             Py::List row;
00895             for (Standard_Integer j=w.LowerCol(); j<=w.UpperCol(); j++) {
00896                 row.append(Py::Float(w(i,j)));
00897             }
00898             weights.append(row);
00899         }
00900         return Py::new_reference_to(weights);
00901     }
00902     catch (Standard_Failure) {
00903         Handle_Standard_Failure e = Standard_Failure::Caught();
00904         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00905         return 0;
00906     }
00907 }
00908 
00909 PyObject* BSplineSurfacePy::getResolution(PyObject *args)
00910 {
00911     double tol;
00912     if (!PyArg_ParseTuple(args, "d", &tol))
00913         return 0;
00914     try {
00915         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00916             (getGeometryPtr()->handle());
00917         double utol, vtol;
00918         surf->Resolution(tol,utol,vtol);
00919         return Py_BuildValue("(dd)",utol,vtol);
00920     }
00921     catch (Standard_Failure) {
00922         Handle_Standard_Failure e = Standard_Failure::Caught();
00923         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00924         return 0;
00925     }
00926 }
00927 
00928 PyObject* BSplineSurfacePy::movePoint(PyObject *args)
00929 {
00930     double U,V;
00931     int uindex1, uindex2;
00932     int vindex1, vindex2;
00933     PyObject* pnt;
00934     if (!PyArg_ParseTuple(args, "ddO!iiii", &U, &V, &(Base::VectorPy::Type),&pnt,
00935                                             &uindex1, &uindex2,&vindex1, &vindex2))
00936         return 0;
00937     try {
00938         Base::Vector3d p = static_cast<Base::VectorPy*>(pnt)->value();
00939         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00940             (getGeometryPtr()->handle());
00941         int ufirst, ulast, vfirst, vlast;
00942         surf->MovePoint(U, V, gp_Pnt(p.x,p.y,p.z), uindex1, uindex2, vindex1, vindex2,
00943             ufirst, ulast, vfirst, vlast);
00944         return Py_BuildValue("(iiii)",ufirst, ulast, vfirst, vlast);
00945     }
00946     catch (Standard_Failure) {
00947         Handle_Standard_Failure e = Standard_Failure::Caught();
00948         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00949         return 0;
00950     }
00951 }
00952 
00953 PyObject* BSplineSurfacePy::setUNotPeriodic(PyObject *args)
00954 {
00955     if (!PyArg_ParseTuple(args, ""))
00956         return 0;
00957     try {
00958         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00959             (getGeometryPtr()->handle());
00960         surf->SetUNotPeriodic();
00961         Py_Return;
00962     }
00963     catch (Standard_Failure) {
00964         Handle_Standard_Failure e = Standard_Failure::Caught();
00965         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00966         return 0;
00967     }
00968 }
00969 
00970 PyObject* BSplineSurfacePy::setVNotPeriodic(PyObject *args)
00971 {
00972     if (!PyArg_ParseTuple(args, ""))
00973         return 0;
00974     try {
00975         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00976             (getGeometryPtr()->handle());
00977         surf->SetVNotPeriodic();
00978         Py_Return;
00979     }
00980     catch (Standard_Failure) {
00981         Handle_Standard_Failure e = Standard_Failure::Caught();
00982         PyErr_SetString(PyExc_Exception, e->GetMessageString());
00983         return 0;
00984     }
00985 }
00986 
00987 PyObject* BSplineSurfacePy::setUPeriodic(PyObject *args)
00988 {
00989     if (!PyArg_ParseTuple(args, ""))
00990         return 0;
00991     try {
00992         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
00993             (getGeometryPtr()->handle());
00994         surf->SetUPeriodic();
00995         Py_Return;
00996     }
00997     catch (Standard_Failure) {
00998         Handle_Standard_Failure e = Standard_Failure::Caught();
00999         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01000         return 0;
01001     }
01002 }
01003 
01004 PyObject* BSplineSurfacePy::setVPeriodic(PyObject *args)
01005 {
01006     if (!PyArg_ParseTuple(args, ""))
01007         return 0;
01008     try {
01009         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01010             (getGeometryPtr()->handle());
01011         surf->SetVPeriodic();
01012         Py_Return;
01013     }
01014     catch (Standard_Failure) {
01015         Handle_Standard_Failure e = Standard_Failure::Caught();
01016         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01017         return 0;
01018     }
01019 }
01020 
01021 PyObject* BSplineSurfacePy::setUOrigin(PyObject *args)
01022 {
01023     int index;
01024     if (!PyArg_ParseTuple(args, "i", &index))
01025         return 0;
01026     try {
01027         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01028             (getGeometryPtr()->handle());
01029         surf->SetUOrigin(index);
01030         Py_Return;
01031     }
01032     catch (Standard_Failure) {
01033         Handle_Standard_Failure e = Standard_Failure::Caught();
01034         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01035         return 0;
01036     }
01037 }
01038 
01039 PyObject* BSplineSurfacePy::setVOrigin(PyObject *args)
01040 {
01041     int index;
01042     if (!PyArg_ParseTuple(args, "i", &index))
01043         return 0;
01044     try {
01045         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01046             (getGeometryPtr()->handle());
01047         surf->SetVOrigin(index);
01048         Py_Return;
01049     }
01050     catch (Standard_Failure) {
01051         Handle_Standard_Failure e = Standard_Failure::Caught();
01052         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01053         return 0;
01054     }
01055 }
01056 
01057 PyObject* BSplineSurfacePy::getUMultiplicity(PyObject *args)
01058 {
01059     int index;
01060     if (!PyArg_ParseTuple(args, "i", &index))
01061         return 0;
01062     try {
01063         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01064             (getGeometryPtr()->handle());
01065         int mult = surf->UMultiplicity(index);
01066         return Py_BuildValue("i", mult);
01067     }
01068     catch (Standard_Failure) {
01069         Handle_Standard_Failure e = Standard_Failure::Caught();
01070         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01071         return 0;
01072     }
01073 }
01074 
01075 PyObject* BSplineSurfacePy::getVMultiplicity(PyObject *args)
01076 {
01077     int index;
01078     if (!PyArg_ParseTuple(args, "i", &index))
01079         return 0;
01080     try {
01081         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01082             (getGeometryPtr()->handle());
01083         int mult = surf->VMultiplicity(index);
01084         return Py_BuildValue("i", mult);
01085     }
01086     catch (Standard_Failure) {
01087         Handle_Standard_Failure e = Standard_Failure::Caught();
01088         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01089         return 0;
01090     }
01091 }
01092 
01093 PyObject* BSplineSurfacePy::getUMultiplicities(PyObject *args)
01094 {
01095     if (!PyArg_ParseTuple(args, ""))
01096         return 0;
01097     try {
01098         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01099             (getGeometryPtr()->handle());
01100         TColStd_Array1OfInteger m(1,surf->NbUKnots());
01101         surf->UMultiplicities(m);
01102         Py::List mults;
01103         for (Standard_Integer i=m.Lower(); i<=m.Upper(); i++) {
01104             mults.append(Py::Int(m(i)));
01105         }
01106         return Py::new_reference_to(mults);
01107     }
01108     catch (Standard_Failure) {
01109         Handle_Standard_Failure e = Standard_Failure::Caught();
01110         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01111         return 0;
01112     }
01113 }
01114 
01115 PyObject* BSplineSurfacePy::getVMultiplicities(PyObject *args)
01116 {
01117     if (!PyArg_ParseTuple(args, ""))
01118         return 0;
01119     try {
01120         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01121             (getGeometryPtr()->handle());
01122         TColStd_Array1OfInteger m(1,surf->NbVKnots());
01123         surf->VMultiplicities(m);
01124         Py::List mults;
01125         for (Standard_Integer i=m.Lower(); i<=m.Upper(); i++) {
01126             mults.append(Py::Int(m(i)));
01127         }
01128         return Py::new_reference_to(mults);
01129     }
01130     catch (Standard_Failure) {
01131         Handle_Standard_Failure e = Standard_Failure::Caught();
01132         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01133         return 0;
01134     }
01135 }
01136 
01137 PyObject* BSplineSurfacePy::exchangeUV(PyObject *args)
01138 {
01139     if (!PyArg_ParseTuple(args, ""))
01140         return 0;
01141 
01142     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01143         (getGeometryPtr()->handle());
01144     surf->ExchangeUV();
01145     Py_Return;
01146 }
01147 
01148 PyObject* BSplineSurfacePy::uIso(PyObject * args)
01149 {
01150     double u;
01151     if (!PyArg_ParseTuple(args, "d", &u))
01152         return 0;
01153 
01154     try {
01155         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01156             (getGeometryPtr()->handle());
01157         Handle_Geom_Curve c = surf->UIso(u);
01158         return new BSplineCurvePy(new GeomBSplineCurve(Handle_Geom_BSplineCurve::DownCast(c)));
01159     }
01160     catch (Standard_Failure) {
01161         Handle_Standard_Failure e = Standard_Failure::Caught();
01162         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01163         return 0;
01164     }
01165 }
01166 
01167 PyObject* BSplineSurfacePy::vIso(PyObject * args)
01168 {
01169     double v;
01170     if (!PyArg_ParseTuple(args, "d", &v))
01171         return 0;
01172 
01173     try {
01174         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01175             (getGeometryPtr()->handle());
01176         Handle_Geom_Curve c = surf->VIso(v);
01177         return new BSplineCurvePy(new GeomBSplineCurve(Handle_Geom_BSplineCurve::DownCast(c)));
01178     }
01179     catch (Standard_Failure) {
01180         Handle_Standard_Failure e = Standard_Failure::Caught();
01181         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01182         return 0;
01183     }
01184 }
01185 
01186 PyObject* BSplineSurfacePy::reparametrize(PyObject * args)
01187 {
01188     int u,v;
01189     double tol = 0.000001;
01190     if (!PyArg_ParseTuple(args, "ii|d", &u, &v, &tol))
01191         return 0;
01192 
01193     // u,v must be at least 2
01194     u = std::max<int>(u, 2);
01195     v = std::max<int>(v, 2);
01196 
01197     try {
01198         Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01199             (getGeometryPtr()->handle());
01200 
01201         double maxU = surf->UKnot(surf->NbUKnots()); // 1.0 if normalized surface
01202         double maxV = surf->VKnot(surf->NbVKnots()); // 1.0 if normalized surface
01203 
01204         GeomBSplineSurface* geom = new GeomBSplineSurface();
01205         Handle_Geom_BSplineSurface spline = Handle_Geom_BSplineSurface::DownCast
01206             (geom->handle());
01207         for (int i=1; i<u-1; i++) {
01208             double U = i * 1.0 / (u-1.0);
01209             spline->InsertUKnot(U,i,tol,Standard_True);
01210         }
01211 
01212         for (int i=1; i<v-1; i++) {
01213             double V = i * 1.0 / (v-1.0);
01214             spline->InsertVKnot(V,i,tol,Standard_True);
01215         }
01216 
01217         for (int j=0; j<u; j++) {
01218             double U = j * maxU / (u-1.0);
01219             double newU = j * 1.0 / (u-1.0);
01220             for (int k=0; k<v; k++) {
01221                 double V = k * maxV / (v-1.0);
01222                 double newV = k * 1.0 / (v-1.0);
01223                 // Get UV point and move new surface UV point
01224                 gp_Pnt point = surf->Value(U,V);
01225                 int ufirst, ulast, vfirst, vlast;
01226                 spline->MovePoint(newU, newV, point, j+1, j+1, k+1, k+1, ufirst, ulast, vfirst, vlast);
01227             }
01228         }
01229 
01230         return new BSplineSurfacePy(geom);
01231     }
01232     catch (Standard_Failure) {
01233         Handle_Standard_Failure e = Standard_Failure::Caught();
01234         PyErr_SetString(PyExc_Exception, e->GetMessageString());
01235         return 0;
01236     }
01237 }
01238 
01239 Py::Int BSplineSurfacePy::getUDegree(void) const
01240 {
01241     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01242         (getGeometryPtr()->handle());
01243     int deg = surf->UDegree();
01244     return Py::Int(deg);
01245 }
01246 
01247 Py::Int BSplineSurfacePy::getVDegree(void) const
01248 {
01249     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01250         (getGeometryPtr()->handle());
01251     int deg = surf->VDegree();
01252     return Py::Int(deg);
01253 }
01254 
01255 Py::Int BSplineSurfacePy::getMaxDegree(void) const
01256 {
01257     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01258         (getGeometryPtr()->handle());
01259     return Py::Int(surf->MaxDegree()); 
01260 }
01261 
01262 Py::Int BSplineSurfacePy::getNbUPoles(void) const
01263 {
01264     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01265         (getGeometryPtr()->handle());
01266     return Py::Int(surf->NbUPoles()); 
01267 }
01268 
01269 Py::Int BSplineSurfacePy::getNbVPoles(void) const
01270 {
01271     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01272         (getGeometryPtr()->handle());
01273     return Py::Int(surf->NbVPoles()); 
01274 }
01275 
01276 Py::Int BSplineSurfacePy::getNbUKnots(void) const
01277 {
01278     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01279         (getGeometryPtr()->handle());
01280     return Py::Int(surf->NbUKnots()); 
01281 }
01282 
01283 Py::Int BSplineSurfacePy::getNbVKnots(void) const
01284 {
01285     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01286         (getGeometryPtr()->handle());
01287     return Py::Int(surf->NbVKnots()); 
01288 }
01289 
01290 Py::Object BSplineSurfacePy::getFirstUKnotIndex(void) const
01291 {
01292     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01293         (getGeometryPtr()->handle());
01294     int index = surf->FirstUKnotIndex();
01295     return Py::Int(index);
01296 }
01297 
01298 Py::Object BSplineSurfacePy::getLastUKnotIndex(void) const
01299 {
01300     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01301         (getGeometryPtr()->handle());
01302     int index = surf->LastUKnotIndex();
01303     return Py::Int(index);
01304 }
01305 
01306 Py::Object BSplineSurfacePy::getFirstVKnotIndex(void) const
01307 {
01308     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01309         (getGeometryPtr()->handle());
01310     int index = surf->FirstVKnotIndex();
01311     return Py::Int(index);
01312 }
01313 
01314 Py::Object BSplineSurfacePy::getLastVKnotIndex(void) const
01315 {
01316     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01317         (getGeometryPtr()->handle());
01318     int index = surf->LastVKnotIndex();
01319     return Py::Int(index);
01320 }
01321 
01322 Py::List BSplineSurfacePy::getUKnotSequence(void) const
01323 {
01324     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01325         (getGeometryPtr()->handle());
01326     Standard_Integer m = 0;
01327     for (int i=1; i<= surf->NbUKnots(); i++)
01328         m += surf->UMultiplicity(i);
01329     TColStd_Array1OfReal k(1,m);
01330     surf->UKnotSequence(k);
01331     Py::List list;
01332     for (Standard_Integer i=k.Lower(); i<=k.Upper(); i++) {
01333         list.append(Py::Float(k(i)));
01334     }
01335     return list;
01336 }
01337 
01338 Py::List BSplineSurfacePy::getVKnotSequence(void) const
01339 {
01340     Handle_Geom_BSplineSurface surf = Handle_Geom_BSplineSurface::DownCast
01341         (getGeometryPtr()->handle());
01342     Standard_Integer m = 0;
01343     for (int i=1; i<= surf->NbVKnots(); i++)
01344         m += surf->VMultiplicity(i);
01345     TColStd_Array1OfReal k(1,m);
01346     surf->VKnotSequence(k);
01347     Py::List list;
01348     for (Standard_Integer i=k.Lower(); i<=k.Upper(); i++) {
01349         list.append(Py::Float(k(i)));
01350     }
01351     return list;
01352 }
01353 
01354 PyObject *BSplineSurfacePy::getCustomAttributes(const char* /*attr*/) const
01355 {
01356     return 0;
01357 }
01358 
01359 int BSplineSurfacePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
01360 {
01361     return 0; 
01362 }

Generated on Wed Nov 23 18:59:59 2011 for FreeCAD by  doxygen 1.6.1