OGG幾何內核-BRepBuilderAPI_MakeEdge學習

OGG幾何內核fork自OCCT 7.7.0,

BRepBuilderAPI_MakeEdge是幾何內核的一個重要和基礎的功能,也十分復雜,因為要支持line、circle、ellipse,parabola,hyperbola,circle,beziercurve,bsplinecurve。需要支持多種參數情況:

1、曲線。

2、曲線+始終長度。

3、曲線+始終角度。

4、曲線+兩點。

5、曲線+面。

代碼注釋如下:

Provides methods to build edges.

The?? methods have? the? following?? syntax, where TheCurve is one of Lin, Circ, ...

Create(C : TheCurve)

Makes an edge on? the whole curve.? Add vertices on finite curves.

Create(C : TheCurve; p1,p2 : Real)

Make an edge? on the curve between parameters p1 and p2. if p2 < p1 the edge will be REVERSED. If p1? or p2 is infinite the? curve will be open in that? direction. Vertices are created for finite values of p1 and p2.

Create(C : TheCurve; P1, P2 : Pnt from gp)

Make an edge on the curve? between the points P1 and P2. The? points are projected on?? the curve and the?? previous method is? used. An? error is raised if the points are not on the curve.

Create(C : TheCurve; V1, V2 : Vertex from TopoDS)

Make an edge? on the curve? between the vertices V1 and V2. Same as the? previous but no vertices are created. If a vertex is? Null the curve will be open in this direction.

class BRepBuilderAPI_MakeEdge  : public BRepBuilderAPI_MakeShape
{
public:DEFINE_STANDARD_ALLOCStandard_EXPORT BRepBuilderAPI_MakeEdge();Standard_EXPORT BRepBuilderAPI_MakeEdge(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);//! The general method to directly create an edge is to give//! -      a 3D curve C as the support (geometric domain) of the edge,//! -      two vertices V1 and V2 to limit the curve (definition of the restriction of//! the edge), and//! -      two real values p1 and p2 which are the parameters for the vertices V1 and V2//! on the curve.//! The curve may be defined as a 2d curve in the parametric space of a surface: a//! pcurve. The surface on which the edge is built is then kept at the level of the edge.//! The default tolerance will be associated with this edge.//! Rules applied to the arguments://! For the curve://! -      The curve must not be a 'null handle'.//! -      If the curve is a trimmed curve the basis curve is used.//! For the vertices://! -      Vertices may be null shapes. When V1 or V2 is null the edge is open in the//! corresponding direction and the parameter value p1 or p2 must be infinite//! (remember that Precision::Infinite() defines an infinite value).//! -      The two vertices must be identical if they have the same 3D location.//! Identical vertices are used in particular when the curve is closed.//! For the parameters://! -      The parameters must be in the parametric range of the curve (or the basis//! curve if the curve is trimmed). If this condition is not satisfied the edge is not//! built, and the Error function will return BRepAPI_ParameterOutOfRange.//! -      Parameter values must not be equal. If this condition is not satisfied (i.e.//! if | p1 - p2 | ) the edge is not built, and the Error function will return//! BRepAPI_LineThroughIdenticPoints.//! Parameter values are expected to be given in increasing order://! C->FirstParameter()//! - If the parameter values are given in decreasing order the vertices are switched,//! i.e. the "first vertex" is on the point of parameter p2 and the "second vertex" is//! on the point of parameter p1. In such a case, to keep the original intent of the//! construction, the edge will be oriented "reversed".//! - On a periodic curve the parameter values p1 and p2 are adjusted by adding or//! subtracting the period to obtain p1 in the parametric range of the curve, and p2]//! such that [ p1 , where Period is the period of the curve.//! - A parameter value may be infinite. The edge is open in the corresponding//! direction. However the corresponding vertex must be a null shape. If this condition//! is not satisfied the edge is not built, and the Error function will return//! BRepAPI_PointWithInfiniteParameter.//! - The distance between the vertex and the point evaluated on the curve with the//! parameter, must be lower than the precision of the vertex. If this condition is not//! satisfied the edge is not built, and the Error function will return//! BRepAPI_DifferentsPointAndParameter.//! Other edge constructions//! - The parameter values can be omitted, they will be computed by projecting the//! vertices on the curve. Note that projection is the only way to evaluate the//! parameter values of the vertices on the curve: vertices must be given on the curve,//! i.e. the distance from a vertex to the curve must be less than or equal to the//! precision of the vertex. If this condition is not satisfied the edge is not built,//! and the Error function will return BRepAPI_PointProjectionFailed.//! -      3D points can be given in place of vertices. Vertices will be created from the//! points (with the default topological precision Precision::Confusion()).//! Note://! -      Giving vertices is useful when creating a connected edge.//! -      If the parameter values correspond to the extremities of a closed curve,//! points must be identical, or at least coincident. If this condition is not//! satisfied the edge is not built, and the Error function will return//! BRepAPI_DifferentPointsOnClosedCurve.//! -      The vertices or points can be omitted if the parameter values are given. The//! points will be computed from the parameters on the curve.//! The vertices or points and the parameter values can be omitted. The first and last//! parameters of the curve will then be used.//!//! Auxiliary methodsStandard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const Standard_Real p1, const Standard_Real p2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);//! Defines or redefines the arguments for the construction of an edge.//! This function is currently used after the empty constructor BRepAPI_MakeEdge().Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);protected:private:BRepLib_MakeEdge myMakeEdge;};

從最后幾行代碼,結合可以發現,BRepBuilderAPI_MakeEdge是BRepLib_MakeEdge的包裝,實際功能由BRepLib_MakeEdge實現。

為了能更深入理解BRepBuilderAPI_MakeEdge,可以研究分析一下測試命令mkedge的代碼。

static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const char** a)
{if (n < 3) return 1;Handle(Geom_Curve)   C   = DrawTrSurf::GetCurve(a[2]);Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);if (C.IsNull() && C2d.IsNull()) {//std::cout << a[2] << " is not a curve" << std::endl;di << a[2] << " is not a curve\n";return 1;}TopoDS_Edge edge;if (n == 3) {if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C);else               edge = BRepBuilderAPI_MakeEdge2d(C2d);}else {Handle(Geom_Surface) S;Standard_Integer i = 0;if (!C2d.IsNull()) {S = DrawTrSurf::GetSurface(a[3]);if (!S.IsNull()) i = 1;}TopoDS_Shape aLocalShape(DBRep::Get(a[3+i],TopAbs_VERTEX));TopoDS_Vertex V1 = TopoDS::Vertex(aLocalShape);
//    TopoDS_Vertex V1 = TopoDS::Vertex(DBRep::Get(a[3+i],TopAbs_VERTEX));if (n == 5+i) {if (V1.IsNull()) {if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C,Draw::Atof(a[3]),Draw::Atof(a[4]));else if (S.IsNull())              edge = BRepBuilderAPI_MakeEdge2d(C2d,Draw::Atof(a[3]),Draw::Atof(a[4]));elseedge = BRepBuilderAPI_MakeEdge(C2d,S,Draw::Atof(a[4]),Draw::Atof(a[5]));}else {aLocalShape = DBRep::Get(a[4+i],TopAbs_VERTEX);TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape);
//  TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[4+i],TopAbs_VERTEX));if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C,V1,V2);else if (S.IsNull())              edge = BRepBuilderAPI_MakeEdge2d(C2d,V1,V2);elseedge = BRepBuilderAPI_MakeEdge(C2d,S,V1,V2);}}  else if (n == 7+i) {aLocalShape = DBRep::Get(a[5+i],TopAbs_VERTEX);TopoDS_Vertex V2 = TopoDS::Vertex(aLocalShape);
//      TopoDS_Vertex V2 = TopoDS::Vertex(DBRep::Get(a[5+i],TopAbs_VERTEX));if (!C.IsNull())   edge = BRepBuilderAPI_MakeEdge(C,V1,V2,Draw::Atof(a[4]),Draw::Atof(a[6]));else if (S.IsNull())         edge = BRepBuilderAPI_MakeEdge2d(C2d,V1,V2,Draw::Atof(a[4]),Draw::Atof(a[6]));else              edge = BRepBuilderAPI_MakeEdge(C2d,S,V1,V2,Draw::Atof(a[5]),Draw::Atof(a[7]));}elsereturn 1;}DBRep::Set(a[1],edge);return 0;
}

以下是各種曲線生成及參數測試:

vertex a 0 0 0
vertex b 6 0 0
vertex c 6 1 0
vertex d 6 0 0
edge l a b
mkcurve curve1 l
mkedge l1 curve1 1 2
mkedge l2 curve1 a b
mkedge l3 curve1 a c
mkedge l4 curve1 a dcircle c 0 0 0 10
mkedge c1 c 0 pi/4
mkedge c1 c 0 pi/2
mkedge c1 c 0 pi
mkedge c1 c 0 2*pi
mkedge c1 c 0 2pi
mkedge c1 c -pi pi
mkedge c1 c -pi/2 0mkedge e1 a bparabola w1 0 0 0 1 0 0 0 0 1 50
mkedge p1 w1 -100 100beziercurve w2 5 0 0 0 20 0 0 20 5 0 25 10 0 10 20 0
mkedge b1 w2 
mkedge b1 w2 0 0.5
mkedge b1 w2 0 0.9
mkedge b1 w2 0 1
mkedge b1 w2 0 2bsplinecurve w3 3 2  -1.0 4   1.0 4  0 0 0 1  2 10 0 1  4 6 0 1  10 0 0 1
mkedge b2 w3
mkedge b2 w3  0 0.5

通過這些測試命令,可以觀察看到線的方向,以及OCCT對不同類型的線生成的edge的處理方式不同。

拋物線和雙曲線:

beziercurve和bsplinecurve

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/13709.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/13709.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/13709.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

springboot常用的注解

啟動注解(Spring Boot 應用的入口注解)@SpringBootApplication @SpringBootApplication 是一個注解,它是 Spring Boot 應用的入口注解,用于表示一個應用程序的主類。這個注解通常被放置在包含 main() 方法的類上。@SpringBootApplication 是一個組合注解,整合了以下三個注…

亞馬遜測評還能做嗎?

只能說測評不是唯一的手段&#xff0c;但是推銷量的一把好手。首先測評能讓listing快速成長&#xff0c;短期內有望成為爆款&#xff0c;速度快&#xff0c;利潤高&#xff0c;回款快。相對其他推廣&#xff0c;測評無疑是有效&#xff0c;省培養listing的方法。其次新品前期太…

設計模式六大原則

開閉原則&#xff1a;對修改封閉&#xff0c;對拓展開放。 單一職責原則&#xff1a;類的功能要專一。 里氏代換原則&#xff1a;子類繼承父類的時候&#xff0c;除添加新的方法完成新增功能外&#xff0c;盡量不要重寫父類方法。 依賴倒轉原則&#xff1a;類要依賴接口&…

Hsql每日一題 | day01

前言 就一直向前走吧&#xff0c;沿途的花終將綻放~ 題目&#xff1a;找出連續活躍3天及以上的用戶 create table t_useractive(uid string,dt string );insert into t_useractive values(A,2023-10-01),(A,2023-10-02),(A,2023-10-03),(A,2023-10-04),(B,2023-10-01),(B…

代碼隨想錄打卡第38天:動態規劃解決編輯距離和回文串

1.72編輯距離 1.問題描述 找到其中需要進行操作的最少次數。 2.問題轉換 大體思路可以參照前面的兩個字符串的刪除操作。添加操作可以將其看做是一個另類的刪除操作&#xff0c;所以最后全部都可以看做是一個刪除操作 3.解題思路 每一個位置的word1[i]和word2[j]都有兩種…

RTOS原理和應用總結

RTOS的作用 RTOS一般應用在中低端處理器當中&#xff0c;這里舉一個筆者日常開發遇到的案例來說明RTOS的作用。 假設你有一個設備&#xff0c;這個設備的外圍硬件很多&#xff0c;假設有LED、一個網口、若干RS232等等。 在沒有RTOS的時候&#xff0c;我們用裸機編程來寫&…

HTML5 多媒體應用技術

目錄 多媒體元素 audio元素video元素多媒體事件與JavaScript交互音頻和視頻軌道(Track)媒體API MediaElement APIMediaSource Extensions (MSE)Encrypted Media Extensions (EME)Web Audio API

數據庫同步軟件,天不生PanguSync萬古如長夜

在信息時代的海洋中&#xff0c;數據是那永不熄滅的燈塔&#xff0c;照亮了科技發展的航道。然而&#xff0c;隨著數據的膨脹和應用場景的多樣化&#xff0c;如何確保這些寶貴資源在不同平臺、不同設備間實時更新、保持一致性&#xff0c;便成了一道亟待解決的難題。于是&#…

Android File Transfer for mac(強大的安卓文件傳輸工具) 直裝版

Android File Transfer是一款專門為Mac用戶設計的軟件&#xff0c;它用于在Android設備與Mac之間傳輸文件。這款軟件提供了簡單直觀的操作界面&#xff0c;使用戶能夠輕松地在Android設備和Mac之間傳輸和管理文件。 下載地址&#xff1a;https://www.macz.com/mac/7099.html?i…

使用python實現socket進行消息傳輸-demo

Socket 是什么 Socket 是一種在計算機網絡中用于實現進程間通信的一種機制。它是網絡編程中的重要概念&#xff0c;通過它可以在不同的計算機之間進行數據傳輸和通信。Socket 可以用于實現各種網絡應用&#xff0c;包括客戶端-服務器模型、P2P 應用等。基本上&#xff0c;Sock…

自動駕駛決策規劃算法——二次規劃

自動駕駛決策規劃算法第二章第二節(中) 參考線算法_嗶哩嗶哩_bilibili 動態規劃開辟的凸空間如下&#xff0c;兩條橙色線之間&#xff1a; 黃色的點就意味著L的上下界&#xff0c;物理意義是當軌跡ss1時&#xff0c;L的范圍應該是(Lmin1,Lmax1)之間&#xff0c;這個范圍就是開辟…

學習日記.1

今天就是配置了droidbot的環境。主要的知識來源是GitHub - xieincz/droidbot: A lightweight test input generator for Android. Similar to Monkey, but with more intelligence and cool features! 看readme&#xff0c;注意只需要platform就好&#xff0c;sdk太大不用下載…

《Ai企業知識庫》-模型實踐-rasa開源學習框架-基礎理論-02

rasa官網 Conversational AI Platform | Superior Customer Experiences Start Here rasa簡介&#xff1a; Rasa是一個開源的機器學習框架&#xff0c;專門用于構建自動化的文本和語音對話系統&#xff0c;即聊天機器人。它允許開發者和企業創建定制化的對話體驗&#xff0c…

ubuntu設置root開機登錄,允許root用戶ssh遠程登錄

ubuntu與centos系統不同&#xff0c;默認root開機不能登錄。 1、輸入一下命令創建root密碼&#xff0c;根據提示輸入新密碼 sudo passwd root 2、打開gdm-autologin文件&#xff0c;將auth required pam_succeed_if.so user ! root quiet_success這行注釋掉&#xff0c;這行就…

el-upload 上傳多個視頻

<el-form-item label"視頻" prop"video_url"><el-uploadclass"upload-demo"ref"uploadRef":multiple"true":on-change"handleChange":before-remove"beforeRemove":before-upload"before…

Flutter 中的 EditableText 小部件:全面指南

Flutter 中的 EditableText 小部件&#xff1a;全面指南 在Flutter中&#xff0c;EditableText是一個低級別的文本編輯組件&#xff0c;它提供了構建自定義文本編輯界面的能力。與TextField和TextFormField不同&#xff0c;EditableText提供了更多的靈活性&#xff0c;允許開發…

【LinuxC語言】鏈接文件

文章目錄 前言一、inode索引節點inode的作用為什么inode重要 二、文件鏈接的定義文件鏈接是什么硬鏈接&#xff08;Hard Link&#xff09;軟鏈接&#xff08;符號鏈接&#xff0c;Symbolic Link&#xff09;硬鏈接圖示&#xff1a;軟鏈接圖示&#xff1a; 硬鏈接應用場景限制和…

五步定位性能瓶頸

一、著手測試前的準備&#xff1a;優化數據流向與系統架構分析 在進行性能測試或系統優化之前&#xff0c;明確數據流向和系統架構的細節是至關重要的步驟。這不僅能夠幫助識別潛在的瓶頸&#xff0c;還能確保測試用例設計的全面性與針對性。以下是關鍵步驟和方法&#xff1a;…

實現本地訪問云主機,以及在云主機搭建FTP站點

前言 云計算是一種基于互聯網的計算模式&#xff0c;通過網絡提供按需訪問的計算資源和服務。核心概念是把計算能力視作一種公共資源&#xff0c;用戶可以根據自身需求動態分配和管理這些資源。 云主機 ECS (Elastic Compute Server)是一種按需獲取的云端服務器&#xff0c;提…

142.棧和隊列:用棧實現隊列(力扣)

題目描述 代碼解決 class MyQueue { public:stack<int> stIn; // 輸入棧&#xff0c;用于push操作stack<int> stOut; // 輸出棧&#xff0c;用于pop和peek操作MyQueue() {}void push(int x) {stIn.push(x); // 將元素壓入輸入棧}int pop() {// 如果輸出棧為空&…