View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000895 | FreeCAD | Feature | public | 2012-12-01 09:09 | 2017-03-27 08:28 |
Reporter | shoogen | Assigned To | wmayer | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 0.12 | ||||
Fixed in Version | 0.14 | ||||
Summary | 0000895: Part.BSplineCurve: allow to set degree and mutliplicites when calling constructor. | ||||
Description | Currently the constructor creats a curve with the degree of 1. This will require the user to use removeKnot() to decrease the multiplicities to get a uniform curve (for degrees >1). Adjusting degree, multiplicites on an existing curve is requies a lot of knowledge about NURBS and OCCT. possible fix: Expose the constructor with all parameters | ||||
Tags | NURBS | ||||
FreeCAD Information | |||||
|
as removeKnot does not work on the first and last Knot of a periodic curve, there is currently no way to decrease the multiplicity. This is therefore a bug. |
|
http://forum.freecadweb.org/viewtopic.php?f=13&t=2553&start=10 |
|
I degrade that to a feature request, since it include a major rewrite to the python interface. On how that interface should look like we need more information/ideas. |
|
it should call OCC like in buildFromPoles. But the mults ans knots vexotrs should be given as pyhton iterables. |
|
for example (Poles, Weights, Knots, Mults, Degree, periodic) and (Poles, Knots, Mults, Degree, periodic) http://www.opencascade.org/org/forum/thread_21343/?forum=3 static PyObject * keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds) { static char *kwlist[] = {"poles", "knots", "mults", "periodic", "weights", NULL}; PyObject* periodic = Py_False; PyObject* poles; PyObject* knots; PyObject* mults; PyObject* weights; if (!PyArg_ParseTupleAndKeywords(args, keywds, "O!|O!O!O!O!", kwlist, &PyList_Type, &poles, &PyList_Type, &knots, &PyList_Type, &mults, &PyBool_Type, &periodic, &PyList_Type, &weights )) return NULL; |
|
Why do you try to use pointers of TColStd_Array* And the method name buildFromEverything sounds a bit strange. Here we should find a better name. Does the code already work as expected? |
|
I Agree about the name (it's just a placeholder by know) The interpolation of knots (spacing) is not yet implemented. And i didn't do any testing yet. I used pointers because i didn't know a better way to get the TColStd_Array* Objects out of the scope of my if clauses. |
|
Use smart pointer aka handles: Handle_TColStd_Array1OfReal occweights; if (...) occweights = new TColStd_Array1OfReal(...); else occweights = new TColStd_Array1OfReal(...); The problem with using plain pointers is that it's very difficult to release the memory in every situation. Especially, if OCC raises an exception (which often happens unexpected) you have a memory leak (in case you don't free the memory in the catch block). Thus, using handles always produces exception-safe code because the memory is freed when the scope where the object lives is left. |
|
Before i read your post i rearranged my if clauses. This way i can create the TColStd_Arrays on the stack in the scope of the try block, abandoning all pointers. The basic functionality is now completed. Documentation and Error reporting should be improved. Currently the user can supply inconsistent data that should cause ConstructionError exception in OCC. However the messages of the exceptions vary. But at least I'm not crashing FreeCAD anymore;) The Names "buildFromKeywords" and "detailedConstructor" came to my mind. But i don't like them either. |
|
What about buildFromPolesMultsKnots()? |
|
i changed the name and squashed the changes. git://github.com/5263/FreeCAD.git review-0000895-buildFromPolesMultsKnots |
|
I think it's now ready. It compiles on windows and 64bit linux. I did most of the testing on linux. |
|
OK. Might it be possible to add an example to the docstring of this method? Maybe an example for periodic and non-periodic splines. The examples shouldn't be too complex but not too trivial either. You can add the examples to this ticket. |
|
git show 3a0037f |
|
That's hard. If just poles are given it works like buildFromPoles the next step would be to just change the weights. (In a wiki page I would say that this is the R in NURBS ;) bsp=Part.BSplineCurve bsp.buildFromPolesMultsKnots((FreeCAD.Vector(-1,0,0),FreeCAD.Vector(1,0,0),FreeCAD.Vector(0,1,0)),weights=(0.3,0,3,0.5),periodic=True) I don't have an idea when one wants to change the spacing in the knot vector (the NU) in NURBS. it might be a good idea to name the requirements: len(poles) = len (weights) len(mults) = len (knots) if periodc: mults[0] = mults [-1] sum(mults[1:]) = len(poles) else: sum(mults) - degree -1 = len(poles) the degree defaults to 3 the weights to 1 the knot vector to [0..1] the mults vector defaults to uniform (if periodic) or quasi-uniform (if non-periodic) BSplineCurve works with only the poles given. BSplineSurface needs at least poles and mults (in u and v) for Surfaces the poles and weights are gives as sequences of sequences. the outer dimension matches u, the inner matches v (note not be included) i was to lazy to guess the mults for a surface as well. this function is for experts. If someone has not thought about mults for a surface he would be better of with an approximation or interpolation. IMHO there should rather be an example page in the wiki with pictures of the results. |
|
I have added a few simple examples. |
|
git show 5678247 |
FreeCAD: master 3a0037ff 2013-10-23 12:27:21 Sebastian Hoogen Committer: wmayer Details Diff |
0000895: Part.BSplineCurve: allow to set degree and mutliplicites when calling constructor. Adds the functions: Part.BSplineCurve.buildFromPolesMultsKnots() Part.BSplineSurface.buildFromPolesMultsKnots() |
Affected Issues 0000895 |
|
mod - src/Mod/Part/App/BSplineCurvePy.xml | Diff File | ||
mod - src/Mod/Part/App/BSplineCurvePyImp.cpp | Diff File | ||
mod - src/Mod/Part/App/BSplineSurfacePy.xml | Diff File | ||
mod - src/Mod/Part/App/BSplineSurfacePyImp.cpp | Diff File | ||
FreeCAD: master 56782476 2013-10-27 09:56:05 wmayer Details Diff |
0000895: Part.BSplineCurve: allow to set degree and mutliplicites when calling constructor. |
Affected Issues 0000895 |
|
mod - src/Mod/Part/App/BSplineCurvePy.xml | Diff File | ||
mod - src/Mod/Part/App/BSplineCurvePyImp.cpp | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-12-01 09:09 | shoogen | New Issue | |
2012-12-01 09:23 | shoogen | Note Added: 0002605 | |
2012-12-01 09:25 | shoogen | Note Edited: 0002605 | |
2012-12-01 13:30 | yorik | Severity | feature => minor |
2012-12-01 13:30 | yorik | Category | Feature => Bug |
2012-12-02 14:10 | wmayer | Note Added: 0002606 | |
2012-12-20 18:59 |
|
Note Added: 0002688 | |
2012-12-20 18:59 |
|
Status | new => feedback |
2012-12-20 18:59 |
|
Category | Bug => Feature |
2012-12-29 19:12 | shoogen | Note Added: 0002766 | |
2013-06-30 12:49 | wmayer | Status | feedback => assigned |
2013-06-30 12:49 | wmayer | Assigned To | => wmayer |
2013-10-04 16:14 | shoogen | Note Added: 0003714 | |
2013-10-06 06:31 | shoogen | Note Edited: 0003714 | |
2013-10-23 13:30 | wmayer | Note Added: 0003791 | |
2013-10-23 13:45 | shoogen | Note Added: 0003792 | |
2013-10-24 05:59 | wmayer | Note Added: 0003793 | |
2013-10-24 07:51 | shoogen | Note Added: 0003795 | |
2013-10-24 13:27 | wmayer | Note Added: 0003799 | |
2013-10-25 05:35 | shoogen | Note Added: 0003804 | |
2013-10-25 15:09 | shoogen | Note Added: 0003806 | |
2013-10-26 06:24 | wmayer | Note Added: 0003810 | |
2013-10-26 06:52 | wmayer | Note Added: 0003811 | |
2013-10-26 07:29 | shoogen | Note Added: 0003812 | |
2013-10-27 10:55 | wmayer | Note Added: 0003815 | |
2013-10-27 10:56 | wmayer | Note Added: 0003816 | |
2013-10-27 10:56 | wmayer | Status | assigned => closed |
2013-10-27 10:56 | wmayer | Resolution | open => fixed |
2013-10-27 10:56 | wmayer | Fixed in Version | => 0.14 |
2013-11-04 22:54 | yorik | Changeset attached | => FreeCAD Master master 56782476 |
2014-08-03 08:00 | shoogen | Relationship added | related to 0000337 |
2014-08-03 08:01 | shoogen | Tag Attached: NURBS | |
2017-03-27 08:28 | Kunda1 | Changeset attached | => FreeCAD master 3a0037ff |