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


C++ Timeline::appendPhase方法代码示例

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


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

示例1: CreateTimelineFromArray

Timeline* CreateTimelineFromArray(Body* body,
                                  Universe& universe,
                                  ValueArray* timelineArray,
                                  const string& path,
                                  ReferenceFrame* defaultOrbitFrame,
                                  ReferenceFrame* defaultBodyFrame)
{
    Timeline* timeline = new Timeline();
    double previousEnding = -numeric_limits<double>::infinity();

    for (ValueArray::const_iterator iter = timelineArray->begin(); iter != timelineArray->end(); iter++)
    {
        Hash* phaseData = (*iter)->getHash();
        if (phaseData == NULL)
        {
            clog << "Error in timeline of '" << body->getName() << "': phase " << iter - timelineArray->begin() + 1 << " is not a property group.\n";
            delete timeline;
            return NULL;
        }

        bool isFirstPhase = iter == timelineArray->begin();
        bool isLastPhase = *iter == timelineArray->back();

        TimelinePhase* phase = CreateTimelinePhase(body, universe, phaseData,
                                                   path,
                                                   defaultOrbitFrame,
                                                   defaultBodyFrame,
                                                   isFirstPhase, isLastPhase, previousEnding);
        if (phase == NULL)
        {
            clog << "Error in timeline of '" << body->getName() << "', phase " << iter - timelineArray->begin() + 1 << endl;
            delete timeline;
            return NULL;
        }

        previousEnding = phase->endTime();

        timeline->appendPhase(phase);
    }

    return timeline;
}
开发者ID:nisselarsson,项目名称:Celestia,代码行数:42,代码来源:solarsys.cpp

示例2: CreateTimeline


//.........这里部分代码省略.........
            // Or, the definition may try to change other timeline phase properties such as
            // the orbit frame, but without providing an orbit. In both cases, we'll just
            // leave the original timeline alone.
            return true;
        }
        else
        {
            clog << "No valid orbit specified for object '" << body->getName() << "'. Skipping.\n";
            return false;
        }
    }

    // If a new orbit was given, override any old orbit
    if (newOrbit != NULL)
    {
        orbit = newOrbit;
        overrideOldTimeline = true;
    }

    // Get the rotation model for this body
    double syncRotationPeriod = orbit->getPeriod();
    RotationModel* newRotationModel = CreateRotationModel(planetData, path, syncRotationPeriod);

    // If a new rotation model was given, override the old one
    if (newRotationModel != NULL)
    {
        rotationModel = newRotationModel;
        overrideOldTimeline = true;
    }

    // If there was no rotation model specified, nor a previous rotation model to
    // override, create the default one.
    if (rotationModel == NULL)
    {
        // If no rotation model is provided, use a default rotation model--
        // a uniform rotation that's synchronous with the orbit (appropriate
        // for nearly all natural satellites in the solar system.)
        rotationModel = CreateDefaultRotationModel(syncRotationPeriod);
    }
    
    if (ParseDate(planetData, "Beginning", beginning))
        overrideOldTimeline = true;
    if (ParseDate(planetData, "Ending", ending))
        overrideOldTimeline = true;

    // Something went wrong if the disposition isn't modify and no timeline
    // is to be created.
    assert(disposition == ModifyObject || overrideOldTimeline);

    if (overrideOldTimeline)
    {
        if (beginning >= ending)
        {
            clog << "Beginning time must be before Ending time.\n";
            return false;
        }

        // We finally have an orbit, rotation model, frames, and time range. Create
        // the object timeline.
        TimelinePhase* phase = TimelinePhase::CreateTimelinePhase(universe,
                                                                  body,
                                                                  beginning, ending,
                                                                  *orbitFrame,
                                                                  *orbit,
                                                                  *bodyFrame,
                                                                  *rotationModel);

        // We've already checked that beginning < ending; nothing else should go
        // wrong during the creation of a TimelinePhase.
        assert(phase != NULL);
        if (phase == NULL)
        {
            clog << "Internal error creating TimelinePhase.\n";
            return false;
        }

        Timeline* timeline = new Timeline();
        timeline->appendPhase(phase);

        body->setTimeline(timeline);

        // Check for circular references in frames; this can only be done once the timeline
        // has actually been set.
        // TIMELINE-TODO: This check is not comprehensive; it won't find recursion in
        // multiphase timelines.
        if (newOrbitFrame && isFrameCircular(*body->getOrbitFrame(0.0), ReferenceFrame::PositionFrame))
        {
            clog << "Orbit frame for " << body->getName() << " is nested too deep (probably circular)\n";
            return false;
        }

        if (newBodyFrame && isFrameCircular(*body->getBodyFrame(0.0), ReferenceFrame::OrientationFrame))
        {
            clog << "Body frame for " << body->getName() << " is nested too deep (probably circular)\n";
            return false;
        }
    }

    return true;
}
开发者ID:nisselarsson,项目名称:Celestia,代码行数:101,代码来源:solarsys.cpp


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