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


C++ Array_::back方法代码示例

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


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

示例1: extendFinalizeFromProperties

void Mesh::extendFinalizeFromProperties() {

    if (!isObjectUpToDateWithProperties()) {
        const Component* rootModel = nullptr;
        if (!hasParent()) {
            std::clog << "Mesh " << get_mesh_file() << " not connected to model..ignoring\n";
            return;   // Orphan Mesh not part of a model yet
        }
        const Component* parent = &getParent();
        while (parent != nullptr) {
            if (dynamic_cast<const Model*>(parent) != nullptr) {
                rootModel = parent;
                break;
            }
            if (parent->hasParent())
                parent = &(parent->getParent()); // traverse up Component tree
            else
                break; // can't traverse up.
        }

        if (rootModel == nullptr) {
            std::clog << "Mesh " << get_mesh_file() << " not connected to model..ignoring\n";
            return;   // Orphan Mesh not descendent of a model
        }
        // Current interface to Visualizer calls generateDecorations on every frame.
        // On first time through, load file and create DecorativeMeshFile and cache it
        // so we don't load files from disk during live drawing/rendering.
        const std::string& file = get_mesh_file();
        bool isAbsolutePath; string directory, fileName, extension;
        SimTK::Pathname::deconstructPathname(file,
            isAbsolutePath, directory, fileName, extension);
        const string lowerExtension = SimTK::String::toLower(extension);
        if (lowerExtension != ".vtp" && lowerExtension != ".obj" && lowerExtension != ".stl") {
            std::clog << "ModelVisualizer ignoring '" << file
                << "'; only .vtp .stl and .obj files currently supported.\n";
            return;
        }

        // File is a .vtp or .obj. See if we can find it.
        Array_<string> attempts;
        const Model& model = dynamic_cast<const Model&>(*rootModel);
        bool foundIt = ModelVisualizer::findGeometryFile(model, file, isAbsolutePath, attempts);

        if (!foundIt) {
            std::clog << "ModelVisualizer couldn't find file '" << file
                << "'; tried\n";
            for (unsigned i = 0; i < attempts.size(); ++i)
                std::clog << "  " << attempts[i] << "\n";
            if (!isAbsolutePath &&
                !Pathname::environmentVariableExists("OPENSIM_HOME"))
                std::clog << "Set environment variable OPENSIM_HOME "
                << "to search $OPENSIM_HOME/Geometry.\n";
            return;
        }

        SimTK::PolygonalMesh pmesh;
        try {
            std::ifstream objFile;
            objFile.open(attempts.back().c_str());
            pmesh.loadFile(attempts.back().c_str());
            // objFile closes when destructed

        }
        catch (const std::exception& e) {
            std::clog << "Visualizer couldn't read "
                << attempts.back() << " because:\n"
                << e.what() << "\n";
            return;
        }

        cachedMesh.reset(new DecorativeMeshFile(attempts.back().c_str()));
    }
}
开发者ID:bit20090138,项目名称:opensim-core,代码行数:73,代码来源:Geometry.cpp


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