XYZ和STL文件MFC显示


VS13 MFC工程代码, 示例如何使用glfw通过opengl显示xyz文件以及stl文件. 代码中使用到的glfw是进过稍微修改过后的, 可以直接支持将创建的窗口集成到MFC控件中. 代码结构清晰, 使用示例简单. 详情可以查看博客: http://blog.csdn.net/sunbibei/article/details/51783783
资源截图
代码片段和文件信息
#include “stdafx.h“
#include “CloudWindow.h“

std::atomic g_cloud_window_scale_ = 1.0;

static void glfwScrollfun(GLFWwindow* window double xoffset double yoffset) {
    std::cout << “GLFWscrollfun: “ << xoffset << “ “ << yoffset << std::endl;

    g_cloud_window_scale_ = g_cloud_window_scale_ + 0.1*yoffset;
    if (g_cloud_window_scale_ < 0) g_cloud_window_scale_ = 0;
}

CloudWindow::CloudWindow() {
    this->is_open_ = false;
    this->close_window_.clear();
    this->lock_data_access_.clear();
    this->glfw_points_.clear();
}

CloudWindow::~CloudWindow(){
    this->Close();
}

void CloudWindow::Close(){
    if (this->IsOpen()){
        // Tell window to close
        while (this->close_window_.test_and_set()){}

        // Wait for window loop to finish processing
        while (this->lock_data_access_.test_and_set()){}

        // Clear all window data
        this->is_open_ = false;
        this->glfw_points_.clear();
        this->lock_data_access_.clear();
        this->close_window_.clear();
    }
}

bool CloudWindow::Open(const std::string &title const unsigned int &width const unsigned int &height int hparent) { // Sized empty window
    if (!this->IsOpen()){
        this->is_open_ = true;

        // If width or height equal 0 open fullscreen
        if ((width == 0) || (height == 0)){
            std::thread window_loop(&CloudWindow::Loop this title true 0 0 hparent);
            window_loop.detach();
        }
        else{
            // Open the window to a specific size
            std::thread window_loop(&CloudWindow::Loop this title false width height hparent);
            window_loop.detach();
        }

        // Wait 50ms and check that window opened
        std::this_thread::sleep_for(std::chrono::milliseconds(50));

        if (!this->is_open_) return false;
    }

    return true;
}

bool CloudWindow::Update(const std::vector& _cloud) {
    // Check that window is open and the point cloud has points
    if ((!this->IsOpen()) || (_cloud.size() == 0))
        return false;

    // the number of cloud is same don‘t need to update.
    if (glfw_points_.size() == _cloud.size()) {
        return true;
    }

    // Set the flag to copy the data
    while (this->lock_data_access_.test_and_set()) {}

    // Clear the old data
    this->glfw_points_.clear();

    // Grab the first point to start the min max calculations
    this->limited[_X][_MIN] = _cloud[0].xx;
    this->limited[_X][_MAX] = _cloud[0].xx;
    this->limited[_Y][_MIN] = _cloud[0].yy;
    this->limited[_Y][_MAX] = _cloud[0].yy;
    this->limited[_Z][_MIN] = _cloud[0].zz;
    this->limited[_Z][_MAX] = _cloud[0].zz;
    this->limited[_X][_AVE] = 0;
    this->limited[_Y][_AVE] = 0;
    this->limited[_Z][_AVE] = 0;

    // Find the minimum maximum and average
    for (auto pt : _cloud) {
        if (this->limited[_X][_MIN] > pt.xx) this->limi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-08-17 00:34  MFCApplication1
     目录           0  2016-08-16 23:51  MFCApplication1glfw
     文件      100864  2016-08-05 17:18  MFCApplication1glfwglfw3.dll
     文件       17966  2016-08-05 17:18  MFCApplication1glfwglfw3dll.lib
     目录           0  2016-08-16 23:51  MFCApplication1glfwinclude
     目录           0  2016-08-16 23:51  MFCApplication1glfwincludeGLFW
     文件       82334  2016-06-29 15:52  MFCApplication1glfwincludeGLFWglfw3.h
     文件        5684  2015-01-28 00:33  MFCApplication1glfwincludeGLFWglfw3native.h
     目录           0  2016-08-16 23:51  MFCApplication1glfwlib-vc2013
     文件      100864  2016-08-05 17:18  MFCApplication1glfwlib-vc2013glfw3.dll
     文件      238850  2016-06-02 21:54  MFCApplication1glfwlib-vc2013glfw3.lib
     文件       17966  2016-08-05 17:18  MFCApplication1glfwlib-vc2013glfw3dll.lib
     文件      242802  2005-10-19 15:55  MFCApplication1glfwlib-vc2013opengl.lib
     文件      336274  2005-10-19 15:55  MFCApplication1glfwlib-vc2013OPENGL32.LIB
     目录           0  2016-08-17 00:34  MFCApplication1MFCApplication1
     文件         991  2016-08-16 23:48  MFCApplication1MFCApplication1.sln
     文件       30208  2016-08-17 00:34  MFCApplication1MFCApplication1.v12.suo
     文件       13917  2016-08-17 00:24  MFCApplication1MFCApplication1CloudWindow.cpp
     文件        1611  2016-08-16 23:56  MFCApplication1MFCApplication1CloudWindow.h
     目录           0  2016-08-17 00:33  MFCApplication1MFCApplication1data
     文件      509183  2016-08-10 11:30  MFCApplication1MFCApplication1data1.xyz
     文件      601070  2016-08-10 11:38  MFCApplication1MFCApplication1data2.xyz
     文件      429750  2016-08-10 11:39  MFCApplication1MFCApplication1data3.xyz
     文件      757449  2016-08-10 11:39  MFCApplication1MFCApplication1data4.xyz
     文件      454791  2016-08-10 11:39  MFCApplication1MFCApplication1data5.xyz
     文件      947131  2016-08-10 11:40  MFCApplication1MFCApplication1data6.xyz
     文件      955730  2016-08-10 11:40  MFCApplication1MFCApplication1data7.xyz
     文件      589941  2016-08-10 11:40  MFCApplication1MFCApplication1data8.xyz
     文件      488953  2016-08-10 11:40  MFCApplication1MFCApplication1data9.xyz
     文件      436933  2016-08-10 11:41  MFCApplication1MFCApplication1data10.xyz
     文件      390835  2016-08-10 11:41  MFCApplication1MFCApplication1data11.xyz
............此处省略40个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)