当前位置: 首页>>代码示例>>C++>>正文


C++ Aggregate::Begin方法代码示例

本文整理汇总了C++中Aggregate::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Aggregate::Begin方法的具体用法?C++ Aggregate::Begin怎么用?C++ Aggregate::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aggregate的用法示例。


在下文中一共展示了Aggregate::Begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: print_it

// Recursively print the hierarchy starting from the root.
// If there is only one aggregate object, the hierarchy will
// only be one level deep (i.e. the children of the one
// aggregate).  However, if there are other aggregates nested 
// within the top one, the printer will print each nested
// aggregate with further indentation.
void printer::print_it( std::ostream &out, Object *root )
    {
    if( root == NULL ) return;
    if( root->PluginType() == aggregate_plugin )
        {
        Aggregate *agg = (Aggregate *)root;
        out << indent() << "begin " << root->MyName() << endl;
        indent_n += 4;
        agg->Begin();
        for( int n = 0;  ; n++ )
            {
            Object *obj = agg->GetChild();
            if( obj == NULL ) break;
            if( limit > 0 && n == limit )
                {
                // Indicate that the list has been truncated.
                out << indent() << "..." << endl;
                break;
                }
            else print_it( out, obj );
            }
        indent_n -= 4;
        out << indent() << "end" << endl;
        }
    else if( root->PluginType() == primitive_plugin )
        {
        out << indent() << root->MyName() << endl;
        }
    }
开发者ID:IshwarKulkarni,项目名称:ToyTracer,代码行数:35,代码来源:printer.cpp

示例2: CountObjects

// Count the number of objects (either just primitives, or both primitives
// and aggregates) contained in a scene graph.
int CountObjects( const Object *root, bool just_primitives )
    {
    if( root == NULL ) return 0;
    if( root->PluginType() != aggregate_plugin ) return 1;
    Aggregate *agg = (Aggregate *)root;
    agg->Begin();
    int count = ( just_primitives ? 0 : 1 );
    for(;;)
        {
        Object *obj = agg->GetChild();
        if( obj == NULL ) break;
        count += CountObjects( obj, just_primitives );
        }
    return count;
    }
开发者ID:IshwarKulkarni,项目名称:ToyTracer,代码行数:17,代码来源:util.cpp


注:本文中的Aggregate::Begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。