Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:addtorus [2015/09/14] (current)
Line 1: Line 1:
 +====== How To: Add a Torus to Rhino ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to create a torus using ON_BrepTorus and add it to Rhino.//
  
 +For more information on the ON_BrepTorus function, see it's definition in opennurbs_brep.h.
 +
 +===== C++ =====
 +<code c++>
 +CRhinoCommand::​result CCommandTest::​RunCommand(
 +        const CRhinoCommandContext&​ context ​
 +        )
 +{
 +  double major_radius = 4.0;
 +  double minor_radius = 2.0;
 +  ON_Plane plane( ON_origin, ON_zaxis );
 +  ON_Circle circle( plane, major_radius );
 +  ON_Torus torus( circle, minor_radius );
 +  ON_Brep* brep = ON_BrepTorus( torus );
 +  if( brep )
 +  {
 +    CRhinoBrepObject* torus_object = new CRhinoBrepObject();​
 +    torus_object->​SetBrep( brep );
 +    if( context.m_doc.AddObject(torus_object) )
 +      context.m_doc.Redraw();​
 +    else
 +      delete torus_object;​
 +  }
 +  return CRhinoCommand::​success;​
 +}
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer cplusplus}}
developer/sdksamples/addtorus.txt ยท Last modified: 2015/09/14 (external edit)