Grasshopper

algorithmic modeling for Rhino

Hello, people

Sorry to steer a little off-topic here but I thought of no better place for starting this discussion.

I came across this piece of code when browsing rhino c++ examples:

ON_3dPoint center_point( 0.0, 0.0, 0.0 );   
double radius = 5.0;
ON_3dPoint height_point( 0.0, 0.0, 10.0 );
ON_3dVector zaxis = height_point - center_point;
ON_Plane plane( center_point, zaxis );
ON_Circle circle( plane, radius );
ON_Cylinder cylinder( circle, zaxis.Length() );
THIS LINE --------> ON_Brep* brep = ON_BrepCylinder( cylinder, TRUE, TRUE );

if( brep ) { CRhinoBrepObject* cylinder_object = new CRhinoBrepObject();
cylinder_object->SetBrep( brep );

if( context.m_doc.AddObject(cylinder_object) )
context.m_doc.Redraw();

else
delete cylinder_object;


In the marked line, we are creating a pointer, but what does it point to? As far as I can understand a pointer
is only an integer address so it cannot be assigned to a structure such as ON_BrepCylinder. Shouldn't it be:

ON_Brep* brep = &cylinder;

It would be great if any of our C++ gurus could shine some light on this.

Views: 381

Replies to This Discussion

Perhaps ON_BrepCylinder is a function returning the adress of a newly created cylinder?

If ON_BrepCylinder() is a method then it may return a pointer to the ON_Brep it creates. If the cylinder you're using is invalid, I imagine this method will fail in which case it will return a null pointer.

A pointer is an address in memory. On 32-bit Rhino it will be a 32-bit integer, on 64-bit Rhino it will be a 64-bit integer. It basically identifies the first byte that is part of the ON_Brep instance.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service