3D modeling & numerical simulation

### decompose B-Spline -> circles

decompose B-Spline -> circles
 jelle 2011/05/23 16:18 Hi, I'm trying to decompose a b-spline to a set of circle definitions. If you're working; yes I'm trying to generate G-Code ;) Since a number of CNC / CAM apps are based on OCC I'm wondering whether you might be able to point me in the right direction. Thanks, -jelle
 Fabian Hachenberg 2011/05/25 09:36 Extract control points from BSplines? Raster a spline? Calculate derivatives on the spline? In order to point you in the right direction, we need to know exactly what you require to implement your decomposition algorithm using OCC...
 jelle 2011/05/25 10:49 Sure, sorry I was a little unclear. What I'm trying to do is to generate a number of position & vectors along a TopoDS_Wire such that I can write ABB RAPID [ industrial robot ] code from it. The precision of the robot is ~ 0.1 mm. Much like a CNC router, a robot can use linear and circular movements. Since my controller is pretty old, I'd like to be economic in the description of the toolpaths. Hence, moving circular is the preferred option. Wrt the spline decomposition algorithm, honestly, I haven't given it too much thought... I figured that CPnts_UniformDeflection could be useful to get the circle points. For the moment simplicity of implementation outweighs sophistication of the algorithm [ uh, my robots are coming friday ;) ] Thanks! -jelle
 Fabian Hachenberg 2011/05/25 14:47 I would like to point out that your project sounds pretty interesting. For the case that you might end up with something useful to use OCC data as input source for CNC machines, maybe you could add your project to http://opencascade.wikidot.com/projects ? And concerning the decomposition: I'm not familiar with the ABB RADID code - could you describe your problem at bit more mathematically? Do you want to interpolate a general curve from OCC (spline, parabola, hyperbola, ...) using only arcs and lines (preferring arcs over lines)? Can you arbitrarily change the radius and central point of the arcs from one segment of the interpolation to the next? (can you approximate a "S"-line using 2 arcs with same radius and central points at (-x,a) and (x,b) ? Another question: Aren't there any decomposition algorithms publicly avaible yet? So wouldn't it be easier to write a converter from OCC curve description into the respective format of the existing decomposition?
 Forum supervisor 2011/05/26 13:53 Dear all, OPEN CASCADE has a good experience in solving similar tasks for its customers working in CNC domain. We have good level of expertise and some re-usable solutions we can offer on a paid basis. Please, do not hesitate to contact us via http://www.opencascade.com/contact/ for more detailed information. Best regards, Forum supervisor
 jelle 2011/05/27 11:18 Hi Fabian, >Do you want to interpolate a general curve from OCC (spline, parabola, hyperbola, ...) using only arcs and lines (preferring arcs over lines)? indeed > Can you arbitrarily change the radius and central point of the arcs from one segment of the interpolation to the next? (can you approximate a "S"-line using 2 arcs with same radius and central points at (-x,a) and (x,b) ? yep >Aren't there any decomposition algorithms publicly avaible yet? yes, there are, I suppose its a question of implementing these. pretty involved from what I've deduced from this [ excellent ] article: http://itc.ktu.lt/itc354/Riskus354.pdf -jelle
 AlexP 2011/08/10 08:06 if you have catia, this powercopy/user defined feature shows the principle, and it is well documented. http://www.gtwiki.org/mwiki/index.php?title=Approximation_of_planar_and_3D_curves_by_Arcs_and_Lines Best, Alexp
 jelle 2011/08/10 09:26 cool, thanks for that reference Alex, the GT wiki is a pretty cool place...
 AlexP 2011/08/14 14:34 // Missed the Spline function : TopoDS_Shape HSF::AddNewSplineSShape(QList Points)      {       TColgp_Array1OfPnt arrayval (1,Points.count()); // sizing array       QListIterator iT(Points);       int count = 0;       while (iT.hasNext())       {       gp_Pnt curpoint = iT.next();       arrayval.SetValue(count+1,curpoint);       count +=1;       }             Handle(Geom_BSplineCurve) SPL1 = GeomAPI_PointsToBSpline(arrayval).Curve();            /* GeomConvert_ApproxCurve aApprox(SPL1,Precision::Confusion(),GeomAbs_C1,3,3); SPL1 = aApprox.Curve();*/       double fp,lp;       fp = SPL1->FirstParameter();       lp = SPL1->LastParameter();       TopoDS_Shape aShape = BRepBuilderAPI_MakeEdge(SPL1,fp,lp);       return aShape;      }
 AlexP 2011/08/14 14:43 be wary of those ">>" they are suppossed to be >> remove all the " "; They must have been tabs and spaces in Visual Studio, who knows... Best, AlexP
 AlexP 2011/08/14 15:45 Solution Space before trimming You have to be logged in to download the attached file
 AlexP 2011/08/14 15:46 solution space after trimming You have to be logged in to download the attached file
 jelle 2011/08/15 09:57 some pretty gorgous screenshots Alex! interesting; I'm an architect as well! what about we catch up off list to talk OCC & architecture? would be interesting! jelleferinga youknowthecharacter gmail dot com
 jelle 2011/08/15 10:00 btw [your?] HSF lib looks pretty neat! is there a repo somewhere? I'd love to know more about it...
 AlexP 2011/08/14 14:47 I guess its the forum: remove the ampersand-n-b-s-p-semicolon from the the first post, if you see them. and two ampersand-g-t-semicolon are suppossed to be ">>" if you see them.
 jelle 2011/08/16 10:37 thanks for sharing that code Alex. will add a pythonocc version of it to hb-robotics-code soon! http://code.google.com/p/hb-robotics-code/source/browse/#svn%2Ftrunk%2FCode%2FPyRAPID
 AlexP 2011/08/16 14:16 No Worries Jelle ... Best, AlexP
 Arthur Magill 2011/08/12 18:10 Hey Jelle, In case you're looking for some code to work from, these guys have solved the same problem to convert SVG (from Inkscape) into G-code. I haven't used the plugin, but I think it does what you want. And you'll be pleased to see it's written in Python ;-) http://www.cnc-club.ru/forum/viewtopic.php?t=35
 jelle 2011/08/12 18:32 really cool! many thanks for the heads up Arthur!
 Yuriy Sinithin 2011/08/13 15:44 Hello, Jelle! It's cool think to decode approximation arcs, circles, B-spline curves with gl2ps module when we save the svg, ps or another vector format. Because when we search objects in frame buffer we have no token like GL_ARC or GL_CIRCLE. And we can calculate the lines into Arc or Circle. Now I'm test the svg, saved with Approximation lines and with Arcs. And the first svg file bigger for 10 times. Also more fast rendering for any vector formats and 1000 more reasons to use transformation of approximations to lines some part of gl.h: /* FeedBackToken */ #define GL_PASS_THROUGH_TOKEN 0x0700 #define GL_POINT_TOKEN 0x0701 #define GL_LINE_TOKEN 0x0702 #define GL_POLYGON_TOKEN 0x0703 #define GL_BITMAP_TOKEN 0x0704 #define GL_DRAW_PIXEL_TOKEN 0x0705 #define GL_COPY_PIXEL_TOKEN 0x0706 #define GL_LINE_RESET_TOKEN 0x0707
 jelle 2011/08/13 17:49 hi Yuriy, right, I see, so without knowing whether you're dealing with GL_ARC or GL_CIRCLE its hard to optimize / encode things efficiently?
 Yuriy Sinithin 2011/08/13 23:23 Sorry for my bad English. I'm talk about optimize output of vector graphic files, no any OpenGL modification. I'm use the OCC HLR algorithm and all lines that was included in this algo after have approximations with StdPrs_DeflectionCurve. I'm know which type of object I'm input in HLR algo, but I don't know what I have after. Also I can save my scene without gl2ps module and OpenGL framebuffer, in my application all objects have drivers, that include information about geom and type of object. And I don't know what I must to do: modify the HLR to save information about lines that I have input and after store this lines under driver of object, or modify gl2ps module for calculating the lines and found there some circles and arcs. First things that I modify the HLR, because after use of this algorithm I don't have information about objects, I at all don't know witch color of lines was inserted in HLR algo.
 alton 2013/07/02 11:16 I really like your way of expressing the opinion and sharing the information.