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


C++ Body::getClassification方法代码示例

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


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

示例1: child

// Add children to item, but group objects of certain classes
// into subtrees to avoid clutter. Stars, planets, and moons
// are shown as direct children of the parent. Small moons,
// asteroids, and spacecraft a grouped together, as there tend to be
// large collections of such objects.
void
SolarSystemTreeModel::addTreeItemChildrenGrouped(TreeItem* item,
                                                 PlanetarySystem* sys,
                                                 const vector<Star*>* orbitingStars,
                                                 Selection parent)
{
    vector<Body*> asteroids;
    vector<Body*> spacecraft;
    vector<Body*> minorMoons;
	vector<Body*> surfaceFeatures;
	vector<Body*> components;
    vector<Body*> other;
    vector<Body*> normal;

    bool groupAsteroids = true;
    bool groupSpacecraft = true;
	bool groupComponents = true;
	bool groupSurfaceFeatures = true;
    if (parent.body())
    {
        // Don't put asteroid moons in the asteroid group; make them
        // immediate children of the parent.
        if (parent.body()->getClassification() == Body::Asteroid)
            groupAsteroids = false;

        if (parent.body()->getClassification() == Body::Spacecraft)
            groupSpacecraft = false;
    }

    for (int i = 0; i < sys->getSystemSize(); i++)
    {
        Body* body = sys->getBody(i);
        switch (body->getClassification())
        {
        case Body::Planet:
        case Body::DwarfPlanet:
        case Body::Invisible:
            normal.push_back(body);
            break;
        case Body::Moon:
            normal.push_back(body);
            break;
        case Body::MinorMoon:
            minorMoons.push_back(body);
            break;
        case Body::Asteroid:
        case Body::Comet:
            if (groupAsteroids)
                asteroids.push_back(body);
            else
                normal.push_back(body);
            break;
        case Body::Spacecraft:
            if (groupSpacecraft)
                spacecraft.push_back(body);
            else
                normal.push_back(body);
            break;
		case Body::Component:
			if (groupComponents)
				components.push_back(body);
			else
				normal.push_back(body);
			break;
		case Body::SurfaceFeature:
			if (groupSurfaceFeatures)
				surfaceFeatures.push_back(body);
			else
				normal.push_back(body);
			break;
        default:
            other.push_back(body);
            break;
        }
    }

    // Calculate the total number of children
    item->nChildren = 0;
    if (orbitingStars != NULL)
        item->nChildren += orbitingStars->size();

    item->nChildren += normal.size();
    if (!asteroids.empty())
        item->nChildren++;
    if (!spacecraft.empty())
        item->nChildren++;
    if (!minorMoons.empty())
        item->nChildren++;
	if (!surfaceFeatures.empty())
		item->nChildren++;
	if (!components.empty())
		item->nChildren++;
    if (!other.empty())
        item->nChildren++;

//.........这里部分代码省略.........
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:101,代码来源:qtsolarsystembrowser.cpp

示例2: CreateBody

// Create a body (planet, moon, spacecraft, etc.) using the values from a
// property list. The usePlanetsUnits flags specifies whether period and
// semi-major axis are in years and AU rather than days and kilometers.
static Body* CreateBody(const string& name,
                        PlanetarySystem* system,
                        Universe& universe,
                        Body* existingBody,
                        Hash* planetData,
                        const string& path,
                        Disposition disposition,
                        BodyType bodyType)
{
    Body* body = NULL;

    if (disposition == ModifyObject || disposition == ReplaceObject)
    {
        body = existingBody;
    }

    if (body == NULL)
    {
        body = new Body(system, name);
        // If the body doesn't exist, always treat the disposition as 'Add'
        disposition = AddObject;
        
        // Set the default classification for new objects based on the body type.
        // This may be overridden by the Class property.
        if (bodyType == SurfaceObject)
        {
            body->setClassification(Body::SurfaceFeature);
        }
    }

    if (!CreateTimeline(body, system, universe, planetData, path, disposition, bodyType))
    {
        // No valid timeline given; give up.
        if (body != existingBody)
            delete body;
        return NULL;
    }

    // Three values control the shape and size of an ellipsoidal object:
    // semiAxes, radius, and oblateness. It is an error if neither the
    // radius nor semiaxes are set. If both are set, the radius is
    // multipled by each of the specified semiaxis to give the shape of
    // the body ellipsoid. Oblateness is ignored if semiaxes are provided;
    // otherwise, the ellipsoid has semiaxes: ( radius, radius, 1-radius ).
    // These rather complex rules exist to maintain backward compatibility.
    //
    // If the body also has a mesh, it is always scaled in x, y, and z by
    // the maximum semiaxis, never anisotropically.

    double radius = (double) body->getRadius();
    bool radiusSpecified = false;
    if (planetData->getLength("Radius", radius))
    {
        body->setSemiAxes(Vector3f::Constant((float) radius));
        radiusSpecified = true;
    }

    Vector3d semiAxes = Vector3d::Ones();
    if (planetData->getVector("SemiAxes", semiAxes))
    {
        if (radiusSpecified)
        {
            // if the radius has been specified, treat SemiAxes as dimensionless
            // (i.e. ignore units) and multiply the radius by the SemiAxes
            semiAxes *= radius;
        }
        else
        {
            double semiAxesScale = 1.0;
            planetData->getLengthScale("SemiAxes", semiAxesScale);
            semiAxes *= semiAxesScale;
        }
        // Swap y and z to match internal coordinate system
        body->setSemiAxes(Vector3f((float) semiAxes.x(), (float) semiAxes.z(), (float) semiAxes.y()));
    }
    else
    {
        double oblateness = 0.0;
        if (planetData->getNumber("Oblateness", oblateness))
        {
            body->setSemiAxes((float) body->getRadius() * Vector3f(1.0f, 1.0f - (float) oblateness, 1.0f));
        }
    }

    int classification = body->getClassification();
    string classificationName;
    if (planetData->getString("Class", classificationName))
        classification = GetClassificationId(classificationName);

    if (classification == Body::Unknown)
    {
        // Try to guess the type
        if (system->getPrimaryBody() != NULL)
        {
            if(radius > 0.1)
                classification = Body::Moon;
            else
//.........这里部分代码省略.........
开发者ID:nisselarsson,项目名称:Celestia,代码行数:101,代码来源:solarsys.cpp


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