Rhino C++ API  8.13
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
CRhinoObjectIterator Class Reference

#include <rhinoSdkDoc.h>

Inheritance diagram for CRhinoObjectIterator:
CRhinoPageViewObjectIterator

Public Types

enum  object_category { active_objects = 1, reference_objects = 2, active_and_reference_objects = 3 }
 
enum  object_state {
  normal_objects = 1, locked_objects = 2, hidden_objects = 4, idef_objects = 8,
  deleted_objects = 16, normal_or_locked_objects = 3, undeleted_objects = 7, all_objects = 0xFFFFFFFF,
  undeleted_and_idef_objects = 0x7FFFFFFF
}
 

Public Member Functions

 CRhinoObjectIterator (const CRhinoDoc &, object_state=normal_or_locked_objects, object_category=active_objects)
 
 CRhinoObjectIterator (object_state s=normal_or_locked_objects, object_category c=active_objects)
 obsolete constructor - you must specify the document More...
 
 CRhinoObjectIterator (unsigned int rhino_doc_sn, const class CRhinoFileWriteOptions &fwo)
 
 CRhinoObjectIterator (unsigned int rhino_doc_sn, object_state=normal_or_locked_objects, object_category=active_objects)
 
 ~CRhinoObjectIterator ()
 
CRhinoDocDocument () const
 
void EnableSelectedFilter (BOOL32 b=true, BOOL32 bCheckSubObjects=false)
 
void EnableVisibleFilter (BOOL32 b=true)
 
CRhinoObjectFirst ()
 
void IncludeGrips (bool bIncludeGrips=true)
 
void IncludeLights (BOOL32 bIncludeLights=true)
 
void IncludePhantoms (bool bIncludePhantoms=true)
 
CRhinoObjectNext ()
 
void SetActiveInViewportFilter (bool bEnable, const CRhinoViewport &viewport, bool bFilter)
 
void SetLayerFilter (int layer_index)
 
void SetObjectFilter (unsigned int object_filter)
 
void SetSpaceFilter (bool bEnable, ON::active_space space, bool bFilter)
 
void SetViewportFilter (const CRhinoViewport &viewport)
 
void SetViewportIdFilter (bool bEnable, ON_UUID viewport_id, bool bFilter)
 

Public Attributes

const unsigned int m_rhino_doc_sn
 document being iterated. More...
 

Friends

class CRhinoDisplayPipeline
 

Detailed Description

Description: The CRhinoObjectIterator class is used to iterate through the objects in a CRhinoDoc.

Example:

/ The default CRhinoObjectIterator iterates / through all visible objects in the active document. CRhinoObjectIterator it(); CRhino3Object* pObject; for ( pObject = it.First(); pObject; pObject = it.Next() ) { ... }

Member Enumeration Documentation

◆ object_category

Description: There are 2 mutually exclusive object categories: active and reference. By default objects are active. If a Rhino file is loaded as a reference model, it's objects are reference objects. Reference objects cannot be modified and are never saved.

Enumerator
active_objects 

DO NOT CHANGE THESE ENUM VALUES - IT WILL BREAK THE SDK.

objects that are part of current model and saved in file

reference_objects 

objects that are for reference and not saved in file

active_and_reference_objects 

◆ object_state

Description: There are 5 mutually exclusive object states: normal, locked, hidden, instance, and deleted. The "instance" objects are the objects used to define the geometry of an instance definition. The instance references (instance objects) are in the normal, locked, hidden or deleted state.

Enumerator
normal_objects 

DO NOT CHANGE THESE ENUM VALUES - IT WILL BREAK THE SDK.

(not locked and not hidden)

locked_objects 

(locked objects or on locked layers)

hidden_objects 

(hidden objects or on hidden layers)

idef_objects 

objects in instance definitions (not the instance references)

deleted_objects 
normal_or_locked_objects 

normal or locked

undeleted_objects 

normal, locked, or hidden

all_objects 

normal, locked, hidden, or deleted (not idefs)

undeleted_and_idef_objects 

normal, locked, hidden and idef

Constructor & Destructor Documentation

◆ CRhinoObjectIterator() [1/4]

CRhinoObjectIterator::CRhinoObjectIterator ( unsigned int  rhino_doc_sn,
object_state  = normal_or_locked_objects,
object_category  = active_objects 
)

Description: This constructor iterates through all active documents

Parameters: s - [in] specifies what object states should be iterated c - [in] specifies what object categories should be iterated

◆ CRhinoObjectIterator() [2/4]

CRhinoObjectIterator::CRhinoObjectIterator ( const CRhinoDoc ,
object_state  = normal_or_locked_objects,
object_category  = active_objects 
)

◆ CRhinoObjectIterator() [3/4]

CRhinoObjectIterator::CRhinoObjectIterator ( object_state  s = normal_or_locked_objects,
object_category  c = active_objects 
)

obsolete constructor - you must specify the document

◆ CRhinoObjectIterator() [4/4]

CRhinoObjectIterator::CRhinoObjectIterator ( unsigned int  rhino_doc_sn,
const class CRhinoFileWriteOptions fwo 
)

This constructor is useful for iterating though objects t when writing files.

◆ ~CRhinoObjectIterator()

CRhinoObjectIterator::~CRhinoObjectIterator ( )

Member Function Documentation

◆ Document()

CRhinoDoc* CRhinoObjectIterator::Document ( ) const

Returns: CRhinoDoc::FromRuntimeSerialNumber(m_rhino_doc_sn) Remarks: Returned pointer will be null if document has been deleted or an invalid document was used in the constructor.

◆ EnableSelectedFilter()

void CRhinoObjectIterator::EnableSelectedFilter ( BOOL32  b = true,
BOOL32  bCheckSubObjects = false 
)

Description: If the selected filter is enabled, then the iterator will limit itself to selected objects. The default is to ignore selection state.

Parameters: b - [in] true limits the iteration to selected objects. bCheckSubObjects - [in] if true and b=true, then the iteration will include objects that have some subset of the object selected, like some edges of a surface. The default is ignore objects where the entire object is not selected.

Example: If you want to iterate through the list of selected points and curves, then you would do something like:

CRhinoObjectIterator it();
it.EnableSelectedFilter(true);
it.SetObjectFilter( ON::point_object | ON::curve_object );
CRhino3Object* pObject;
for ( pObject = it.First(); pObject; pObject = it.Next() )
{
  ...
}

See Also: CRhinoObjectIterator::SetObjectFilter CRhinoObjectIterator::SetLayerFilter CRhinoObjectIterator::EnableSelectedFilter CRhinoObjectIterator::EnableVisibleFilter

◆ EnableVisibleFilter()

void CRhinoObjectIterator::EnableVisibleFilter ( BOOL32  b = true)

Description: If the visible filter is enabled, then the iterator will limit itself to visible objects. The default is to ignore visibility.

Parameters: b - [in] true limits the iteration to visible objects.

Remarks: Hidden objects and objects on layers that are turned off are not visible.

See Also: CRhinoObjectIterator::SetObjectFilter CRhinoObjectIterator::SetLayerFilter CRhinoObjectIterator::EnableSelectedFilter CRhinoObjectIterator::EnableVisibleFilter

◆ First()

CRhinoObject* CRhinoObjectIterator::First ( )

Description: Returns the first object in list. The next call to CRhinoObjectIterator::Next will return the second object in the list. Example:

    CRhinoObjectIterator it;
    CRhinoObject* obj;
    for ( obj = it.First(); obj; obj = it.Next() )
    {
      ...
    }

Returns: First object in the list. See Also: CRhinoObjectIterator::Next

◆ IncludeGrips()

void CRhinoObjectIterator::IncludeGrips ( bool  bIncludeGrips = true)

Description: The default object iterator does not iterate through grip objects. If you want the iterator to include lights, then call IncludeGrips(true). Parameters: bIncludeGrips - [in] true to include grips in the iteration

◆ IncludeLights()

void CRhinoObjectIterator::IncludeLights ( BOOL32  bIncludeLights = true)

Description: The default object iterator does not iterate through render light objects. If you want the iterator to include lights, then call IncludeLights(true). Parameters: bIncludeLights - [in] true to include lights in the iteration Remarks: If you just want to look at render lights, it may be easier to use the CRhinoDoc::m_light_table[] array.

◆ IncludePhantoms()

void CRhinoObjectIterator::IncludePhantoms ( bool  bIncludePhantoms = true)

Description: The default object iterator does not iterate through phantom objects. If you want the iterator to include phantoms, then call IncludePhantoms(true). Parameters: bIncludePhantoms - [in] true to include phantom objects in the iteration

◆ Next()

CRhinoObject* CRhinoObjectIterator::Next ( )

Description: Returns the next object in list. Returns NULL when no more objects are in the list. Example:

    CRhinoObjectIterator it;
    CRhinoObject* obj;
    for ( obj = it.First(); obj; obj = it.Next() )
    {
      ...
    }

Returns: Next object in the list; See Also: CRhinoObjectIterator::First

◆ SetActiveInViewportFilter()

void CRhinoObjectIterator::SetActiveInViewportFilter ( bool  bEnable,
const CRhinoViewport viewport,
bool  bFilter 
)

Description: Filter on value of object->IsActiveInViewport()

Parameters: bEnable - [in] true to enable the filter viewport - [in] The caller is responsible for making sure this class persists until the iterator is no longer needed. Otherwise, you will crash. bFilter - [in] An object is included in the iteration only if bFilter = object->IsActiveInViewport(viewport) is active in that view.

◆ SetLayerFilter()

void CRhinoObjectIterator::SetLayerFilter ( int  layer_index)
Description:
  The layer filter can be used to limit the iteration to
  objects on a specific layer.
Parameters:
  layer_index - [in] index of layer or -1 do disable layer
     filtering.
Example:
  If you want to iterate through the list of objects
  that are on mesh and
  brep objects, then you would do something like:

      const CRhinoLayer& layer = ...
      int layer_index = layer.LayerIndex();

/ or

      CRhinoObject& object = ...;
      int layer_index = object.Attributes().m_layer_index;

      CRhinoObjectIterator it();
      it.SetLayerFilter( layer_index );
      CRhino3Object* pObject;
      for ( pObject = it.First(); pObject; pObject = it.Next() )
      {
        ...
      }
Remarks:
  By default, no layer filter is enabled.
See Also:
  CRhinoObjectIterator::SetObjectFilter
  CRhinoObjectIterator::SetLayerFilter
  CRhinoObjectIterator::EnableSelectedFilter
  CRhinoObjectIterator::EnableVisibleFilter

◆ SetObjectFilter()

void CRhinoObjectIterator::SetObjectFilter ( unsigned int  object_filter)

Description: The object filter can be used to limit the iteration to specific types of geometry.

Parameters: object_filter - [in] an unsigned int made by or-ing ( | ) values from the ON::object_type enum. If you pass 0, then all objects will be iterated.

Example: If you want to iterate through the list of mesh and brep objects, then you would do something like:

  CRhinoObjectIterator it();
  it.SetObjectFilter( ON::brep_object | ON::mesh_object );
  CRhino3Object* pObject;
  for ( pObject = it.First(); pObject; pObject = it.Next() )
  {
    ...
  }

Remarks: If object_filter has the ON::light_object bit set, then iterating through lights is automatically enabled.

See Also: CRhinoObjectIterator::SetObjectFilter CRhinoObjectIterator::SetLayerFilter CRhinoObjectIterator::EnableSelectedFilter CRhinoObjectIterator::EnableVisibleFilter

◆ SetSpaceFilter()

void CRhinoObjectIterator::SetSpaceFilter ( bool  bEnable,
ON::active_space  space,
bool  bFilter 
)

Description: The object space filter can be used to filter on the value of ON_3dmObjectAttributes.m_space. Parameters: bEnable - [in] true to enable this filter. (default is false). space - [in] bFilter - [in] If bEnable is true, then the object will be included in the iteration if and only if bFilter == ( space == object_attributes.m_space). Example: If you want to iterate through the list of objects that are in model space

CRhinoObjectIterator it();
it.SetObjectSpaceFilter(true,ON::model_space,true);

CRhino3Object* pObject;
for ( pObject = it.First(); pObject; pObject = it.Next() )
{
  ...
}

If you want to iterate through the list of objects that are active in a specific page view.

CRhinoObjectIterator it();
it.SetObjectSpaceFilter(true,ON::page_space,true);
const CRhinoViewport* page_viewport = ...;
it.SetViewportIdFilter(
                      true,
                      page_viewport->ViewportId(),
                      true);

CRhino3Object* pObject;
for ( pObject = it.First(); pObject; pObject = it.Next() )
{
  ...
}

See Also: CRhinoObjectIterator::SetViewportFilter

Remarks: Model space objects and model views are not special. Page view objects, like title block annotation, are marked as special and page views are marked as special views. This filter is primarily used to limit the iteration to objects that are only in a certain page view or objects that are in model space.

◆ SetViewportFilter()

void CRhinoObjectIterator::SetViewportFilter ( const CRhinoViewport viewport)

Description: This function is a one-call way to set up the common filter that quickly weeds out objects in the wrong space or on the wrong page view.

if ( ON::page_view_type == viewport.m_v.m_view_type ) { SetSpaceFilter(true,ON::page_space,true); SetViewportIdFilter(true,viewport.ViewportId(),true); } else { SetSpaceFilter(true,ON::model_space,true); SetViewportIdFilter(false,ON_nil_uuid,false); }

Parameters: viewport - [in]

◆ SetViewportIdFilter()

void CRhinoObjectIterator::SetViewportIdFilter ( bool  bEnable,
ON_UUID  viewport_id,
bool  bFilter 
)

Description: The object space filter can be used to filter on the value of ON_3dmObjectAttributes.m_viewport_id. Parameters: bEnable - [in] true to enable this filter. (default is false). viewport_id - [in] bFilter - [in] If bEnable is true, then the object will be included in the iteration if and only if bFilter == ( viewport_id == object_attributes.m_viewport_id).

See Also: CRhinoObjectIterator::SetViewportFilter

Friends And Related Function Documentation

◆ CRhinoDisplayPipeline

friend class CRhinoDisplayPipeline
friend

Member Data Documentation

◆ m_rhino_doc_sn

const unsigned int CRhinoObjectIterator::m_rhino_doc_sn

document being iterated.