Site Tools


Differences

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

Link to this comparison view

rhino:rhinov5status_extrusion_for_developers [2015/09/14]
127.0.0.1 external edit
rhino:rhinov5status_extrusion_for_developers [2016/07/11] (current)
sandy
Line 1: Line 1:
-====== Rhino 5.0 Status ​Lightweight Extrusion Objects for developers ​======+====== Rhino 5.0 Status:====== 
 +======Lightweight Extrusion Objects for Developers ​======
  
-Plugins ​written using C++ SDK, .NET SDK or Rhino common might fail to select the new lightweight extrusion objects depending on the programming style. ​ This is why it is very important for plugin ​developers (of Rhino 5.0) to test their product with lightweight extrusions and fix any bugs or crashes.+Plug-ins ​written using C++ SDK, .NET SDK or Rhino common might fail to select the new lightweight extrusion objects depending on the programming style. ​ This is why it is very important for plug-in ​developers (of Rhino 5.0) to test their product with lightweight extrusions and fix any bugs or crashes.
  
 ===== Overview ===== ===== Overview =====
  
-In general, the CRhinoObjRef (object reference) that you get from CRhinoGetObject (selecting a polysurface,​ faces or edges) is a special object reference especially when you select lightweight extrusion object. ​ The reference holds a pointer to the extrusion object and also a proxy brep of that object. ​ Consider the following sample to select a face:+In general, the CRhinoObjRef (object reference) that you get from CRhinoGetObject (selecting a polysurface,​ faces or edges) is a special object referenceespecially when you select lightweight extrusion object. ​ The reference holds a pointer to the extrusion object and also a proxy brep of that object. ​ Consider the following sample to select a face:
  
     CRhinoGetObject go;     CRhinoGetObject go;
Line 19: Line 20:
     int face_component_index = original_objref.m_component_index     int face_component_index = original_objref.m_component_index
  
-<color blue>​**Note** that "​original_obj"​ is not a "​CRhinoBrepObject"​ and cannot be casted as one.</​color> ​ In this case, it is actually a "​CRhinoExtrusionObject"​. ​ This one special object reference from the getter "​original_objref"​ has a proxy ON_Brep and therefore the brep and brep_face are both valid as long as the original_objref ​DOES NOT GO OUT OF SCOPE. ​ A case that result is deleting the proxy brep and the pointer will be invalid causing crashes and other failures+<color blue>​**Note** that "​original_obj"​ is not a "​CRhinoBrepObject"​ and cannot be casted as one.</​color> ​ In this case, it is actually a "​CRhinoExtrusionObject"​. ​ This one special object reference from the getter "​original_objref"​ has a proxy ON_Brep and therefore the brep and brep_face are both valid as long as the original_objref ​__does not go out of scope__.  
-<color blue>​**To be safe,​** ​you need to always keep the getter in scope or keep a copy of the object reference.</​color>​+<color blue>​**To be safe,** always keep the getter in scope or keep a copy of the object reference.</​color>​
  
-**Help:** Please ​post questions to [[news://​news.mcneel.com/​rhino.plug-ins+For help, please ​post questions to [[news://​news.mcneel.com/​rhino.plug-ins
 |Rhino developer newsgroup]]. ​ Please don't hesitate to ask.  |Rhino developer newsgroup]]. ​ Please don't hesitate to ask. 
  
-Following are examples where the code will fail when selecting extrusion objects and suggested solutions. ​If there are other cases that are failing and you need help with, +Following are examples where the code will fail when selecting extrusion objects and suggested solutions. ​
  
 ===== Casting CRhinoObject as CRhinoBrepObject ===== ===== Casting CRhinoObject as CRhinoBrepObject =====
Line 41: Line 42:
       return CRhinoCommand::​failure;​       return CRhinoCommand::​failure;​
  
-<color red>**Problem:​** ​casting ​will be a problem if you select extrusion object. The following line with cause error:</​color>​+**Problem:​** ​Casting ​will be a problem if you select extrusion object:
  
     const CRhinoBrepObject* brep_obj = CRhinoBrepObject ::​Cast(obj);​     const CRhinoBrepObject* brep_obj = CRhinoBrepObject ::​Cast(obj);​
Line 51: Line 52:
     const ON_Brep* org_brep = brep_obj->​Brep();​     const ON_Brep* org_brep = brep_obj->​Brep();​
  
-<color blue>**Solution:​** ​to make your code work with extrusion objects, get your brep directly from the object reference:</​color>​+**Solution:​** ​To make your code work with extrusion objects, get your brep directly from the object reference:
  
     const ON_Brep* input_brep = go.Object(0).Brep();​     const ON_Brep* input_brep = go.Object(0).Brep();​
Line 162: Line 163:
     CRhinoCommand::​result rc = CRhinoCommand::​failure;​     CRhinoCommand::​result rc = CRhinoCommand::​failure;​
  
-<color red>​**Problem case # 1:** when call a selection function that returns a pointer to input object and edge index:</​color>​+<color red>​**Problem case # 1:** When call a selection function that returns a pointer to input object and edge index.</​color>​
     rc = MyGetEdge1(obj,​ edge_index);​     rc = MyGetEdge1(obj,​ edge_index);​
     if( rc != CRhinoCommand::​success )     if( rc != CRhinoCommand::​success )
Line 182: Line 183:
  
  
-<color red>​**Problem case # 2** when call a selection function that returns a pointer to input brep and edge index:</​color>​+<color red>​**Problem case # 2:** When call a selection function that returns a pointer to input brep and edge index</​color>​
     rc = MyGetEdge2(brep,​ edge_index);​     rc = MyGetEdge2(brep,​ edge_index);​
     if( rc != CRhinoCommand::​success )     if( rc != CRhinoCommand::​success )
Line 197: Line 198:
  
  
-<color red>​**Problem case # 3:** - when call a selection function that returns a pointer to input edge:</​color>​+<color red>​**Problem case # 3:** When call a selection function that returns a pointer to input edge.</​color>​
     rc = MyGetEdge3( edge );     rc = MyGetEdge3( edge );
     if( rc != CRhinoCommand::​success )     if( rc != CRhinoCommand::​success )
Line 212: Line 213:
  
  
-<color red>​**Problem case # 4** - when the getter is inside a block or a loop:</​color>​+<color red>​**Problem case # 4:** When the getter is inside a block or a loop.</​color>​
     {     {
       CRhinoGetObject go; //the getter will be destoyed once exiting the block       CRhinoGetObject go; //the getter will be destoyed once exiting the block
Line 231: Line 232:
  
  
-<color red>​**Problem case # 5** Using Object GUID and ComponentIndex to reference objects and sub-objects:</​color>​+<color red>​**Problem case # 5:** Using Object GUID and ComponentIndex to reference objects and sub-objects.</​color>​
     ON_UUID uuid = ON_nil_uuid;​     ON_UUID uuid = ON_nil_uuid;​
     ON_COMPONENT_INDEX component_index;​     ON_COMPONENT_INDEX component_index;​
Line 254: Line 255:
  
  
-<color blue>​**Solution:​** ​you need to either instantiate and pass the getter by refrence ​from the main function; or, you can also return a copy of the object reference, as follows:</​color>​+<color blue>​**Solution:​** ​You need to either instantiate and pass the getter by reference ​from the main function; or, you can also return a copy of the object reference, as follows.</​color>​
  
   CRhinoCommand::​result MyGetFace_work( CRhinoObjRef&​ obj_ref)   CRhinoCommand::​result MyGetFace_work( CRhinoObjRef&​ obj_ref)
Line 330: Line 331:
   {   {
  
-<color red>​**Problem:​** ​the following will fail with extrusion objects because the passed object is of type CRhinoExtrusionObject:</​color>​+<color red>​**Problem:​** ​The following will fail with extrusion objects because the passed object is of type CRhinoExtrusionObject.</​color>​
     const CRhinoBrepObject* brep_object = CRhinoBrepObject::​Cast(object);​     const CRhinoBrepObject* brep_object = CRhinoBrepObject::​Cast(object);​
     if ( 0 == brep_object )     if ( 0 == brep_object )
Line 341: Line 342:
       return false;       return false;
  
-<color blue>​**Solution:​** ​the following will work with extrusion objects. Just remember to cast the geometry rather than the object:</​color>​+<color blue>​**Solution:​** ​The following will work with extrusion objects. Just remember to cast the geometry rather than the object.</​color>​
  
     //first, make sure that the component index belongs to a brep     //first, make sure that the component index belongs to a brep
rhino/rhinov5status_extrusion_for_developers.txt · Last modified: 2016/07/11 by sandy