Differences

This shows you the differences between two versions of the page.

 — developer:sdksamples:filletcurve [2015/09/14] (current) Line 1: Line 1: + ====== Fillet Curves ====== + > **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​ + > **Summary:​** //​Demonstrates how to create a fillet between two curves.// + + ===== Question ===== + I am trying to do some automated geometry generation. At one point, I have + two intersecting ON_Lines, each made out of two points, and I want to fillet + them with a specific radius. The only function I can see that does this is **RhinoGetFilletPoints**. What am I missing. + + ===== Answer ===== + **RhinoGetFilletPoints** is the function are looking for. From its results, you can calculate the fillet curve and where to trim back your input curves. + + The following example demonstrates how to create a fillet curve between two line curve. But you can use this example to fillet more complex curves too. + + ==== C++ ==== + + CRhinoCommand::​result CCommandTest::​RunCommand( const CRhinoCommandContext&​ context ) + { + ON_3dPoint point0( 10.0,  0.0, 0.0 ); + ON_3dPoint point1( 10.0, 10.0, 0.0 ); + ON_3dPoint point2( ​ 0.0, 10.0, 0.0 ); + + // Create the line curves to fillet + ON_LineCurve curve0( point0, point1 ); + ON_LineCurve curve1( point2, point1 ); + + // Fillet at the end points of the line curves + double curve0_t = curve0.Domain().Max();​ + double curve1_t = curve1.Domain().Max();​ + + // Fillet radius + double radius = 1.0; + + // Do the fillet calculation + double t0 = 0.0, t1 = 0.0; + ON_Plane plane; + if( RhinoGetFilletPoints(curve0,​ curve1, radius, curve0_t, curve1_t, t0, t1, plane) ) + { + // Trim back the two line curves + ON_Interval domain0( curve0.Domain().Min(),​ t0 ); + curve0.Trim( domain0 ); + + ON_Interval domain1( curve1.Domain().Min(),​ t1 ); + curve1.Trim( domain1 ); + + // Compute the fillet curve + ON_3dVector radial0 = curve0.PointAt(t0) - plane.Origin();​ + radial0.Unitize();​ + + ON_3dVector radial1 = curve1.PointAt(t1) - plane.Origin();​ + radial1.Unitize();​ + + double angle = acos( radial0 * radial1 ); + ON_Plane fillet_plane( plane.Origin(),​ radial0, radial1 ); + ON_Arc fillet( fillet_plane,​ plane.Origin(),​ radius, angle ); + + // Add the geometry + context.m_doc.AddCurveObject( curve0 ); + context.m_doc.AddCurveObject( curve1 ); + context.m_doc.AddCurveObject( fillet ); + + context.m_doc.Redraw();​ + } + + return CRhinoCommand::​success;​ + } + ​ + + \\ + + {{tag>​Developer cplusplus}} 