Open CASCADE学习|显示文本

news2025/1/31 3:32:14

目录

1、修改代码

Viewer.h:

Viewer.cpp:

2、显示文本

OpenCasCade 你好啊

霜吹花落


1、修改代码

在文章《Open CASCADE学习|显示模型》基础上,增加部分代码,实现对文本显示的支持,具体如下:

Viewer.h:

//-----------------------------------------------------------------------------// Created on: 24 August 2017//-----------------------------------------------------------------------------// Copyright (c) 2017, Sergey Slyadnev (sergey.slyadnev@gmail.com)// All rights reserved.//// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are met:////    * Redistributions of source code must retain the above copyright//      notice, this list of conditions and the following disclaimer.//    * Redistributions in binary form must reproduce the above copyright//      notice, this list of conditions and the following disclaimer in the//      documentation and/or other materials provided with the distribution.//    * Neither the name of the copyright holder(s) nor the//      names of all contributors may be used to endorse or promote products//      derived from this software without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE// DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.//-----------------------------------------------------------------------------#pragma once#ifdef _WIN32#include <Windows.h>#endif// Local includes#include "ViewerInteractor.h"// OpenCascade includes#include <TopoDS_Shape.hxx>#include <AIS_TextLabel.hxx>#include <WNT_Window.hxx>// Standard includes#include <vector>class V3d_Viewer;class V3d_View;class AIS_InteractiveContext;class AIS_ViewController;//-----------------------------------------------------------------------------//! Simple 3D viewer.class Viewer{public:    Viewer(const int left,        const int top,        const int width,        const int height);public:    Viewer& operator<<(const TopoDS_Shape& shape)    {        this->AddShape(shape);        return *this;    }    Viewer& operator<<(const Handle(AIS_TextLabel)& label)    {        this->AddLabel(label);        return *this;    }    void AddShape(const TopoDS_Shape& shape);    void AddLabel(const Handle(AIS_TextLabel)& label);    void StartMessageLoop();    void StartMessageLoop2();private:    static LRESULT WINAPI        wndProcProxy(HWND hwnd,            UINT message,            WPARAM wparam,            LPARAM lparam);    LRESULT CALLBACK        wndProc(HWND hwnd,            UINT message,            WPARAM wparam,            LPARAM lparam);    void init(const HANDLE& windowHandle);    /* API-related things */private:    std::vector<TopoDS_Shape> m_shapes; //!< Shapes to visualize.    std::vector<Handle(AIS_TextLabel)> m_labels; //!< Shapes to visualize.    /* OpenCascade's things */private:    Handle(V3d_Viewer)             m_viewer;    Handle(V3d_View)               m_view;    Handle(AIS_InteractiveContext) m_context;    Handle(WNT_Window)             m_wntWindow;    Handle(ViewerInteractor)       m_evtMgr;    /* Lower-level things */private:    HINSTANCE m_hInstance; //!< Handle to the instance of the module.    HWND      m_hWnd;      //!< Handle to the instance of the window.    bool      m_bQuit;     //!< Indicates whether user want to quit from window.};

Viewer.cpp:

//-----------------------------------------------------------------------------
// Created on: 24 August 2017
//-----------------------------------------------------------------------------
// Copyright (c) 2017, Sergey Slyadnev (sergey.slyadnev@gmail.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//    * Redistributions of source code must retain the above copyright
//      notice, this list of conditions and the following disclaimer.
//    * Redistributions in binary form must reproduce the above copyright
//      notice, this list of conditions and the following disclaimer in the
//      documentation and/or other materials provided with the distribution.
//    * Neither the name of the copyright holder(s) nor the
//      names of all contributors may be used to endorse or promote products
//      derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------

// Own include
#include "Viewer.h"

// OpenCascade includes
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_DisplayConnection.hxx>
#include <Aspect_Handle.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>

namespace {
    //! Adjust the style of local selection.
    //! \param[in] context the AIS context.
    void AdjustSelectionStyle(const Handle(AIS_InteractiveContext)& context)
    {
        // Initialize style for sub-shape selection.
        Handle(Prs3d_Drawer) selDrawer = new Prs3d_Drawer;
        //
        selDrawer->SetLink(context->DefaultDrawer());
        selDrawer->SetFaceBoundaryDraw(true);
        selDrawer->SetDisplayMode(1); // Shaded
        selDrawer->SetTransparency(0.5f);
        selDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost);
        selDrawer->SetColor(Quantity_NOC_GOLD);
        selDrawer->SetBasicFillAreaAspect(new Graphic3d_AspectFillArea3d());

        // Adjust fill area aspect.
        const Handle(Graphic3d_AspectFillArea3d)&
            fillArea = selDrawer->BasicFillAreaAspect();
        //
        fillArea->SetInteriorColor(Quantity_NOC_GOLD);
        fillArea->SetBackInteriorColor(Quantity_NOC_GOLD);
        //
        fillArea->ChangeFrontMaterial().SetMaterialName(Graphic3d_NOM_NEON_GNC);
        fillArea->ChangeFrontMaterial().SetTransparency(0.4f);
        fillArea->ChangeBackMaterial().SetMaterialName(Graphic3d_NOM_NEON_GNC);
        fillArea->ChangeBackMaterial().SetTransparency(0.4f);

        selDrawer->UnFreeBoundaryAspect()->SetWidth(1.0);

        // Update AIS context.
        context->SetHighlightStyle(Prs3d_TypeOfHighlight_LocalSelected, selDrawer);
    }
}

//-----------------------------------------------------------------------------

Viewer::Viewer(const int left,
    const int top,
    const int width,
    const int height)
    : m_hWnd(NULL),
    m_bQuit(false)
{
    // Register the window class once
    static HINSTANCE APP_INSTANCE = NULL;
    if (APP_INSTANCE == NULL)
    {
        APP_INSTANCE = GetModuleHandleW(NULL);
        m_hInstance = APP_INSTANCE;

        WNDCLASSW WC;
        WC.cbClsExtra = 0;
        WC.cbWndExtra = 0;
        WC.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
        WC.hCursor = LoadCursor(NULL, IDC_ARROW);
        WC.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        WC.hInstance = APP_INSTANCE;
        WC.lpfnWndProc = (WNDPROC)wndProcProxy;
        WC.lpszClassName = L"OpenGLClass";
        WC.lpszMenuName = 0;
        WC.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;

        if (!RegisterClassW(&WC))
        {
            return;
        }
    }

    // Set coordinates for window's area rectangle.
    RECT Rect;
    SetRect(&Rect,
        left, top,
        left + width, top + height);

    // Adjust window rectangle.
    AdjustWindowRect(&Rect, WS_OVERLAPPEDWINDOW, false);

    // Create window.
    m_hWnd = CreateWindow(L"OpenGLClass",
        L"Quaoar >>> 3D",
        WS_OVERLAPPEDWINDOW,
        Rect.left, Rect.top, // Adjusted x, y positions
        Rect.right - Rect.left, Rect.bottom - Rect.top, // Adjusted width and height
        NULL, NULL,
        m_hInstance,
        this);

    // Check if window has been created successfully.
    if (m_hWnd == NULL)
    {
        return;
    }

    // Show window finally.
    ShowWindow(m_hWnd, TRUE);

    HANDLE windowHandle = (HANDLE)m_hWnd;

    this->init(windowHandle);
}

//-----------------------------------------------------------------------------

void Viewer::AddShape(const TopoDS_Shape& shape)
{
    m_shapes.push_back(shape);
}


void Viewer::AddLabel(const Handle(AIS_TextLabel)& label)
{
    m_labels.push_back(label);
}
//-----------------------------------------------------------------------------

//! Starts message loop.
void Viewer::StartMessageLoop()
{
    for (auto sh : m_shapes)
    {
        Handle(AIS_Shape) shape = new AIS_Shape(sh);
        m_context->Display(shape, true);
        m_context->SetDisplayMode(shape, AIS_Shaded, true);

        // Adjust selection style.
        ::AdjustSelectionStyle(m_context);

        // Activate selection modes.
        m_context->Activate(4, true); // faces
        m_context->Activate(2, true); // edges
    }

    MSG Msg;
    while (!m_bQuit)
    {
        switch (::MsgWaitForMultipleObjectsEx(0, NULL, 12, QS_ALLINPUT, 0))
        {
        case WAIT_OBJECT_0:
        {
            while (::PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
            {
                if (Msg.message == WM_QUIT)
                    m_bQuit = true;// return;

                ::TranslateMessage(&Msg);
                ::DispatchMessage(&Msg);
            }
        }
        }
    }
}

//! Starts message loop.
void Viewer::StartMessageLoop2()
{
    for (auto sh : m_labels)
    {
        //Handle(AIS_Shape) shape = new AIS_Shape(sh);
        m_context->Display(sh,0);
        //m_context->SetDisplayMode(shape, AIS_Shaded, true);

        // Adjust selection style.
        ::AdjustSelectionStyle(m_context);

        // Activate selection modes.
        m_context->Activate(4, true); // faces
        m_context->Activate(2, true); // edges
    }

    MSG Msg;
    while (!m_bQuit)
    {
        switch (::MsgWaitForMultipleObjectsEx(0, NULL, 12, QS_ALLINPUT, 0))
        {
        case WAIT_OBJECT_0:
        {
            while (::PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
            {
                if (Msg.message == WM_QUIT)
                    m_bQuit = true;// return;

                ::TranslateMessage(&Msg);
                ::DispatchMessage(&Msg);
            }
        }
        }
    }
}

//-----------------------------------------------------------------------------

void Viewer::init(const HANDLE& windowHandle)
{
    static Handle(Aspect_DisplayConnection) displayConnection;
    //
    if (displayConnection.IsNull())
        displayConnection = new Aspect_DisplayConnection();

    HWND winHandle = (HWND)windowHandle;
    //
    if (winHandle == NULL)
        return;

    // Create OCCT viewer.
    Handle(OpenGl_GraphicDriver)
        graphicDriver = new OpenGl_GraphicDriver(displayConnection, false);

    m_viewer = new V3d_Viewer(graphicDriver);

    // Lightning.
    Handle(V3d_DirectionalLight) LightDir = new V3d_DirectionalLight(V3d_Zneg, Quantity_Color(Quantity_NOC_GRAY97), 1);
    Handle(V3d_AmbientLight)     LightAmb = new V3d_AmbientLight();
    //
    LightDir->SetDirection(1.0, -2.0, -10.0);
    //
    m_viewer->AddLight(LightDir);
    m_viewer->AddLight(LightAmb);
    m_viewer->SetLightOn(LightDir);
    m_viewer->SetLightOn(LightAmb);

    // AIS context.
    m_context = new AIS_InteractiveContext(m_viewer);

    // Configure some global props.
    const Handle(Prs3d_Drawer)& contextDrawer = m_context->DefaultDrawer();
    //
    if (!contextDrawer.IsNull())
    {
        const Handle(Prs3d_ShadingAspect)& SA = contextDrawer->ShadingAspect();
        const Handle(Graphic3d_AspectFillArea3d)& FA = SA->Aspect();
        contextDrawer->SetFaceBoundaryDraw(true); // Draw edges.
        FA->SetEdgeOff();

        // Fix for inifinite lines has been reduced to 1000 from its default value 500000.
        contextDrawer->SetMaximalParameterValue(1000);
    }

    // Main view creation.
    m_view = m_viewer->CreateView();
    m_view->SetImmediateUpdate(false);

    // Event manager is constructed when both contex and view become available.
    m_evtMgr = new ViewerInteractor(m_view, m_context);

    // Aspect window creation
    m_wntWindow = new WNT_Window(winHandle);
    m_view->SetWindow(m_wntWindow, nullptr);
    //
    if (!m_wntWindow->IsMapped())
    {
        m_wntWindow->Map();
    }
    m_view->MustBeResized();

    // View settings.
    m_view->SetShadingModel(V3d_PHONG);

    // Configure rendering parameters
    Graphic3d_RenderingParams& RenderParams = m_view->ChangeRenderingParams();
    RenderParams.IsAntialiasingEnabled = true;
    RenderParams.NbMsaaSamples = 8; // Anti-aliasing by multi-sampling
    RenderParams.IsShadowEnabled = false;
    RenderParams.CollectedStats = Graphic3d_RenderingParams::PerfCounters_NONE;
}

//-----------------------------------------------------------------------------

LRESULT WINAPI Viewer::wndProcProxy(HWND   hwnd,
    UINT   message,
    WPARAM wparam,
    LPARAM lparam)
{
    if (message == WM_CREATE)
    {
        // Save pointer to our class instance (sent on window create) to window storage.
        CREATESTRUCTW* pCreateStruct = (CREATESTRUCTW*)lparam;
        SetWindowLongPtr(hwnd, int(GWLP_USERDATA), (LONG_PTR)pCreateStruct->lpCreateParams);
    }

    // Get pointer to our class instance.
    Viewer* pThis = (Viewer*)GetWindowLongPtr(hwnd, int(GWLP_USERDATA));
    return (pThis != NULL) ? pThis->wndProc(hwnd, message, wparam, lparam)
        : DefWindowProcW(hwnd, message, wparam, lparam);
}

//-----------------------------------------------------------------------------

//! Window procedure.
LRESULT Viewer::wndProc(HWND   hwnd,
    UINT   message,
    WPARAM wparam,
    LPARAM lparam)
{
    if (m_view.IsNull())
        return DefWindowProc(hwnd, message, wparam, lparam);

    switch (message)
    {
    case WM_PAINT:
    {
        PAINTSTRUCT aPaint;
        BeginPaint(m_hWnd, &aPaint);
        EndPaint(m_hWnd, &aPaint);
        m_evtMgr->ProcessExpose();
        break;
    }
    case WM_SIZE:
    {
        m_evtMgr->ProcessConfigure();
        break;
    }
    case WM_MOVE:
    case WM_MOVING:
    case WM_SIZING:
    {
        switch (m_view->RenderingParams().StereoMode)
        {
        case Graphic3d_StereoMode_RowInterlaced:
        case Graphic3d_StereoMode_ColumnInterlaced:
        case Graphic3d_StereoMode_ChessBoard:
        {
            // track window moves to reverse stereo pair
            m_view->MustBeResized();
            m_view->Update();
            break;
        }
        default:
            break;
        }
        break;
    }
    case WM_KEYUP:
    case WM_KEYDOWN:
    {
        const Aspect_VKey vkey = WNT_Window::VirtualKeyFromNative((int)wparam);
        //
        if (vkey != Aspect_VKey_UNKNOWN)
        {
            const double timeStamp = m_evtMgr->EventTime();
            if (message == WM_KEYDOWN)
            {
                m_evtMgr->KeyDown(vkey, timeStamp);
            }
            else
            {
                m_evtMgr->KeyUp(vkey, timeStamp);
            }
        }
        break;
    }
    case WM_LBUTTONUP:
    case WM_MBUTTONUP:
    case WM_RBUTTONUP:
    case WM_LBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_RBUTTONDOWN:
    {
        const Graphic3d_Vec2i pos(LOWORD(lparam), HIWORD(lparam));
        const Aspect_VKeyFlags flags = WNT_Window::MouseKeyFlagsFromEvent(wparam);
        Aspect_VKeyMouse button = Aspect_VKeyMouse_NONE;
        //
        switch (message)
        {
        case WM_LBUTTONUP:
        case WM_LBUTTONDOWN:
            button = Aspect_VKeyMouse_LeftButton;
            break;
        case WM_MBUTTONUP:
        case WM_MBUTTONDOWN:
            button = Aspect_VKeyMouse_MiddleButton;
            break;
        case WM_RBUTTONUP:
        case WM_RBUTTONDOWN:
            button = Aspect_VKeyMouse_RightButton;
            break;
        }
        if (message == WM_LBUTTONDOWN
            || message == WM_MBUTTONDOWN
            || message == WM_RBUTTONDOWN)
        {
            SetFocus(hwnd);
            SetCapture(hwnd);

            if (!m_evtMgr.IsNull())
                m_evtMgr->PressMouseButton(pos, button, flags, false);
        }
        else
        {
            ReleaseCapture();

            if (!m_evtMgr.IsNull())
                m_evtMgr->ReleaseMouseButton(pos, button, flags, false);
        }

        m_evtMgr->FlushViewEvents(m_context, m_view, true);
        break;
    }
    case WM_MOUSEWHEEL:
    {
        const int    delta = GET_WHEEL_DELTA_WPARAM(wparam);
        const double deltaF = double(delta) / double(WHEEL_DELTA);
        //
        const Aspect_VKeyFlags flags = WNT_Window::MouseKeyFlagsFromEvent(wparam);
        //
        Graphic3d_Vec2i pos(int(short(LOWORD(lparam))), int(short(HIWORD(lparam))));
        POINT cursorPnt = { pos.x(), pos.y() };
        if (ScreenToClient(hwnd, &cursorPnt))
        {
            pos.SetValues(cursorPnt.x, cursorPnt.y);
        }

        if (!m_evtMgr.IsNull())
        {
            m_evtMgr->UpdateMouseScroll(Aspect_ScrollDelta(pos, deltaF, flags));
            m_evtMgr->FlushViewEvents(m_context, m_view, true);
        }
        break;
    }
    case WM_MOUSEMOVE:
    {
        Graphic3d_Vec2i pos(LOWORD(lparam), HIWORD(lparam));
        Aspect_VKeyMouse buttons = WNT_Window::MouseButtonsFromEvent(wparam);
        Aspect_VKeyFlags flags = WNT_Window::MouseKeyFlagsFromEvent(wparam);

        // don't make a slide-show from input events - fetch the actual mouse cursor position
        CURSORINFO cursor;
        cursor.cbSize = sizeof(cursor);
        if (::GetCursorInfo(&cursor) != FALSE)
        {
            POINT cursorPnt = { cursor.ptScreenPos.x, cursor.ptScreenPos.y };
            if (ScreenToClient(hwnd, &cursorPnt))
            {
                // as we override mouse position, we need overriding also mouse state
                pos.SetValues(cursorPnt.x, cursorPnt.y);
                buttons = WNT_Window::MouseButtonsAsync();
                flags = WNT_Window::MouseKeyFlagsAsync();
            }
        }

        if (m_wntWindow.IsNull() || (HWND)m_wntWindow->HWindow() != hwnd)
        {
            // mouse move events come also for inactive windows
            break;
        }

        if (!m_evtMgr.IsNull())
        {
            m_evtMgr->UpdateMousePosition(pos, buttons, flags, false);
            m_evtMgr->FlushViewEvents(m_context, m_view, true);
        }
        break;
    }
    default:
    {
        break;
    }

    case WM_DESTROY:
        m_bQuit = true;
    }
    return DefWindowProc(hwnd, message, wparam, lparam);
}

2、显示文本

OpenCasCade 你好啊

#include "TCollection_ExtendedString.hxx"#include "Resource_Unicode.hxx"#include "AIS_TextLabel.hxx"#include "AIS_InteractiveContext.hxx"#include"Viewer.h"int main() {    TCollection_ExtendedString tostr;    Standard_CString str = "OpenCasCade 你好啊";    Resource_Unicode::ConvertGBToUnicode(str, tostr);    Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();    aLabel->SetText(tostr);    aLabel->SetColor(Quantity_NOC_RED);    aLabel->SetFont("SimHei");    Viewer vout(50, 50, 500, 500);    vout << aLabel;    vout.StartMessageLoop2();    return 0;    }

霜吹花落

#include "TCollection_ExtendedString.hxx"#include "Resource_Unicode.hxx"#include "AIS_TextLabel.hxx"#include "AIS_InteractiveContext.hxx"#include"Viewer.h"int main() {    TCollection_ExtendedString tostr;    Standard_CString str = "霜吹花落";    Resource_Unicode::ConvertGBToUnicode(str, tostr);    Handle(AIS_TextLabel) aLabel = new AIS_TextLabel();    aLabel->SetPosition(gp_Pnt(0, 0, 0));    aLabel->SetText(tostr);    aLabel->SetHJustification(Graphic3d_HTA_CENTER);    aLabel->SetVJustification(Graphic3d_VTA_CENTER);    aLabel->SetHeight(50);    aLabel->SetZoomable(false);//如果允许缩放,你会发现放大后字太难看了    aLabel->SetAngle(0);    aLabel->SetColor(Quantity_NOC_YELLOW);    aLabel->SetFont("SimHei");//一定要设置合适的字体,不然不能实现功能    //如果有一天你需要鼠标选中文本时,下面代码有用,高亮文本    Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer(); // 获取高亮风格    aLabel->SetHilightAttributes(aStyle);    aStyle->SetMethod(Aspect_TOHM_COLOR);    aStyle->SetColor(Quantity_NOC_RED);    // 设置高亮颜色    aStyle->SetDisplayMode(1); // 整体高亮    aLabel->SetDynamicHilightAttributes(aStyle);    Viewer vout(50, 50, 500, 500);    vout << aLabel;    vout.StartMessageLoop2();    return 0;    }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1546912.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

随机链表的深拷贝

目录 一、何为深拷贝&#xff1f; 二、题目 三、思路 1.拷贝节点插入到原节点后面 2.控制拷贝节点的random 3.脱离原链表 : 尾插的思想 四、代码 五、附加 一、何为深拷贝&#xff1f; 一个引用对象一般来说由两个部分组成&#xff1a;一个具名的Handle&#xff0c;也就…

cinder学习小结

1 官方文档 翻译官方文档学习 链接Cinder Administration — cinder 22.1.0.dev97 documentation (openstack.org) 1.1 镜像压缩加速 在cinder.conf配allow_compression_on_image_upload True可打开开关 compression_format xxx可设置镜像压缩格式&#xff0c;可为gzip 1.2 …

SPP和SPPF的比较

SPP的结构是将输入并行通过多个不同大小的MaxPool层&#xff0c;然后做进一步融合&#xff0c;能在一定程度上解决多尺度问题。 而SPPF结构则是讲输入串行通过多个5*5的MaxPool层&#xff0c;这里需要注意两个5*5的MaxPool层和一个9*9的MaxPool的计算结果是一样的&#xff0c;而…

[蓝桥杯 2022 省 A] 求和

[蓝桥杯 2022 省 A] 求和 题目描述 给定 n n n 个整数 a 1 , a 2 , ⋯ , a n a_{1}, a_{2}, \cdots, a_{n} a1​,a2​,⋯,an​, 求它们两两相乘再相加的和&#xff0c;即 S a 1 ⋅ a 2 a 1 ⋅ a 3 ⋯ a 1 ⋅ a n a 2 ⋅ a 3 ⋯ a n − 2 ⋅ a n − 1 a n − 2 ⋅ a…

3、创建项目,什么是路由

一、创建项目 第一次全局安装脚手架 npm install -g vue/clivue create 项目名 二、什么是路由&#xff1f; 路由就是一组 key-value 的对应关系多个路由&#xff0c;需要经过路由器的管理 1、后端路由&#xff1a; 每个url地址都对应着不同的静态资源对于普通的网站。所有…

记录整合ssm项目时的报错java: Compilation failed: internal java compiler error

启动的时候报错java: Compilation failed: internal java compiler error&#xff0c;这说明是内部编译器错误。如下图所示&#xff1a; 大概率是jdk版本不兼容的问题&#xff0c;也有IDEA初始划分的堆内存不够的原因。 查阅了很多博客的解决方法也都是上述两种&#xff0c;但…

C++引用学习day2

思维导图 定义一个矩形类&#xff08;Rectangle&#xff09;&#xff0c;包含私有成员&#xff1a;长(length)、宽&#xff08;width&#xff09;, 定义成员函数&#xff1a; 设置长度&#xff1a;void set_l(int l) 设置宽度&#xff1a;void set_w(int w) 获取长度&#…

vscode 配置c++环境——3个文件搞定!!!

前提&#xff1a; 在vscode中安装了c扩展 创建文件settings.json {"files.associations": {"string": "cpp","vector": "cpp","array": "cpp","atomic": "cpp","*.tcc"…

Springboot快速整合bootstrap-table使用,接口对接

这个表格加持还是不错了&#xff0c;自带了全局搜索&#xff0c;分页&#xff0c;数据导出&#xff0c;卡片视图&#xff0c;等&#xff0c;本次整合添加了数据添加弹窗和编辑数据回显弹窗&#xff0c;附完整页面代码&#xff0c;只需要拿过来替换自己实际的接口即可。 效果图 …

轻松掌握C语言中的sqrt函数,快速计算平方根的魔法秘诀

C语言文章更新目录 C语言学习资源汇总&#xff0c;史上最全面总结&#xff0c;没有之一 C/C学习资源&#xff08;百度云盘链接&#xff09; 计算机二级资料&#xff08;过级专用&#xff09; C语言学习路线&#xff08;从入门到实战&#xff09; 编写C语言程序的7个步骤和编程…

ES6 字符串/数组/对象/函数扩展

文章目录 1. 模板字符串1.1 ${} 使用1.2 字符串扩展(1) ! includes() / startsWith() / endsWith()(2) repeat() 2. 数值扩展2.1 二进制 八进制写法2.2 ! Number.isFinite() / Number.isNaN()2.3 inInteger()2.4 ! 极小常量值Number.EPSILON2.5 Math.trunc()2.6 Math.sign() 3.…

力扣hot100:207. 课程表

这是一道拓扑排序问题&#xff0c;也可以使用DFS判断图中是否存在环。详情请见&#xff1a;官方的BFS算法请忽略&#xff0c;BFS将问题的实际意义给模糊了&#xff0c;不如用普通拓扑排序思想。 数据结构&#xff1a;图的拓扑排序与关键路径 拓扑排序&#xff1a; class Sol…

详解:写作和赚钱的 4 个关系!看完你一定会忍不住想开始写!

飞书文档的加密很强&#xff0c;也没有和自家的豆包大模型融合&#xff0c;所以只能通过其他方式获取文档的内容。 &#xff08;1&#xff09;将飞书文档转换为PDF&#xff0c;要用到浏览器插件&#xff1a; GoFullPage - Full Page Screen Capture - Microsoft Edge Addons …

ElasticSearch启动报错:Exception in thread “main“ SettingsException

Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]]; 这个报错说明elasticsearch.yml这个配…

垃圾回收:垃圾回收器

目录 垃圾回收器 评估GC的性能指标 7种典型的垃圾回收器 Serial回收器&#xff1a;串行回收 ParNew回收器&#xff1a;并行回收 Parallel回收器&#xff1a;吞吐量优先 CMS回收器&#xff1a;低延迟 G1回收器&#xff1a;区域化分代式 G1回收过程1-年轻代GC G1回收过程…

Java代码基础算法练习-报数问题-2024.03.26

任务描述&#xff1a; 有n个人围成一个圆圈分别编号1~n,从第1个到m循环报数&#xff0c;凡是报到m者离开&#xff0c;求n个 人离开圆圈的次序。 任务要求&#xff1a; 代码示例&#xff1a; package M0317_0331;import java.util.ArrayList; import java.util.List; import j…

档案室升级改造基建方面需要考虑哪些问题

升级和改造档案室可能需要以下材料&#xff1a; 1. 墙壁和地板材料&#xff1a;选择耐用、易于清洁的材料&#xff0c;如瓷砖、大理石、地板、木材或维护低的地毯等。 2. 墙体材料&#xff1a;可能需要新的墙壁材料来分隔出更多的空间&#xff0c;例如石膏板、砖块或玻璃隔断等…

基于RAG的大模型知识库搭建

什么是RAG RAG(Retrieval Augmented Generation)&#xff0c;即检索增强生成技术。 RAG优势 部分解决了幻觉问题。由于我们可以控制检索内容的可靠性&#xff0c;也算是部分解决了幻觉问题。可以更实时。同理&#xff0c;可以控制输入给大模型上下文内容的时效性&#xff0c…

【Java程序设计】【C00369】基于(JavaWeb)Springboot的笔记记录分享平台(有论文)

[TOC]() 博主介绍&#xff1a;java高级开发&#xff0c;从事互联网行业六年&#xff0c;已经做了六年的毕业设计程序开发&#xff0c;开发过上千套毕业设计程序&#xff0c;博客中有上百套程序可供参考&#xff0c;欢迎共同交流学习。 项目简介 项目获取 &#x1f345;文末点击…

PTA L2-034 口罩发放

为了抗击来势汹汹的 COVID19 新型冠状病毒&#xff0c;全国各地均启动了各项措施控制疫情发展&#xff0c;其中一个重要的环节是口罩的发放。 某市出于给市民发放口罩的需要&#xff0c;推出了一款小程序让市民填写信息&#xff0c;方便工作的开展。小程序收集了各种信息&…