Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:13:52

0001 // Created on: 1993-07-29
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _BRepBuilderAPI_MakePolygon_HeaderFile
0018 #define _BRepBuilderAPI_MakePolygon_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <BRepLib_MakePolygon.hxx>
0025 #include <BRepBuilderAPI_MakeShape.hxx>
0026 class gp_Pnt;
0027 class TopoDS_Vertex;
0028 class TopoDS_Edge;
0029 class TopoDS_Wire;
0030 
0031 //! Describes functions to build polygonal wires. A
0032 //! polygonal wire can be built from any number of points
0033 //! or vertices, and consists of a sequence of connected
0034 //! rectilinear edges.
0035 //! When a point or vertex is added to the polygon if
0036 //! it is identic to the previous point no edge is
0037 //! built. The method added can be used to test it.
0038 //! Construction of a Polygonal Wire
0039 //! You can construct:
0040 //! -   a complete polygonal wire by defining all its points
0041 //! or vertices (limited to four), or
0042 //! -   an empty polygonal wire and add its points or
0043 //! vertices in sequence (unlimited number).
0044 //! A MakePolygon object provides a framework for:
0045 //! -   initializing the construction of a polygonal wire,
0046 //! -   adding points or vertices to the polygonal wire under construction, and
0047 //! -   consulting the result.
0048 class BRepBuilderAPI_MakePolygon : public BRepBuilderAPI_MakeShape
0049 {
0050 public:
0051   DEFINE_STANDARD_ALLOC
0052 
0053   //! Initializes an empty polygonal wire, to which points or
0054   //! vertices are added using the Add function.
0055   //! As soon as the polygonal wire under construction
0056   //! contains vertices, it can be consulted using the Wire function.
0057   Standard_EXPORT BRepBuilderAPI_MakePolygon();
0058 
0059   Standard_EXPORT BRepBuilderAPI_MakePolygon(const gp_Pnt& P1, const gp_Pnt& P2);
0060 
0061   Standard_EXPORT BRepBuilderAPI_MakePolygon(const gp_Pnt& P1,
0062                                              const gp_Pnt& P2,
0063                                              const gp_Pnt& P3,
0064                                              const bool    Close = false);
0065 
0066   //! Constructs a polygonal wire from 2, 3 or 4 points. Vertices are
0067   //! automatically created on the given points. The polygonal wire is
0068   //! closed if Close is true; otherwise it is open. Further vertices can
0069   //! be added using the Add function. The polygonal wire under
0070   //! construction can be consulted at any time by using the Wire function.
0071   //! Example
0072   //! //an open polygon from four points
0073   //! TopoDS_Wire W = BRepBuilderAPI_MakePolygon(P1,P2,P3,P4);
0074   //! Warning: The process is equivalent to:
0075   //! - initializing an empty polygonal wire,
0076   //! - and adding the given points in sequence.
0077   //! Consequently, be careful when using this function: if the
0078   //! sequence of points p1 - p2 - p1 is found among the arguments of the
0079   //! constructor, you will create a polygonal wire with two
0080   //! consecutive coincident edges.
0081   Standard_EXPORT BRepBuilderAPI_MakePolygon(const gp_Pnt& P1,
0082                                              const gp_Pnt& P2,
0083                                              const gp_Pnt& P3,
0084                                              const gp_Pnt& P4,
0085                                              const bool    Close = false);
0086 
0087   Standard_EXPORT BRepBuilderAPI_MakePolygon(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
0088 
0089   Standard_EXPORT BRepBuilderAPI_MakePolygon(const TopoDS_Vertex& V1,
0090                                              const TopoDS_Vertex& V2,
0091                                              const TopoDS_Vertex& V3,
0092                                              const bool           Close = false);
0093 
0094   //! Constructs a polygonal wire from
0095   //! 2, 3 or 4 vertices. The polygonal wire is closed if Close is true;
0096   //! otherwise it is open (default value). Further vertices can be
0097   //! added using the Add function. The polygonal wire under
0098   //! construction can be consulted at any time by using the Wire function.
0099   //! Example
0100   //! //a closed triangle from three vertices
0101   //! TopoDS_Wire W = BRepBuilderAPI_MakePolygon(V1,V2,V3,true);
0102   //! Warning
0103   //! The process is equivalent to:
0104   //! -      initializing an empty polygonal wire,
0105   //! -      then adding the given points in sequence.
0106   //! So be careful, as when using this function, you could create a
0107   //! polygonal wire with two consecutive coincident edges if
0108   //! the sequence of vertices v1 - v2 - v1 is found among the
0109   //! constructor's arguments.
0110   Standard_EXPORT BRepBuilderAPI_MakePolygon(const TopoDS_Vertex& V1,
0111                                              const TopoDS_Vertex& V2,
0112                                              const TopoDS_Vertex& V3,
0113                                              const TopoDS_Vertex& V4,
0114                                              const bool           Close = false);
0115 
0116   Standard_EXPORT void Add(const gp_Pnt& P);
0117 
0118   //! Adds the point P or the vertex V at the end of the
0119   //! polygonal wire under construction. A vertex is
0120   //! automatically created on the point P.
0121   //! Warning
0122   //! -   When P or V is coincident to the previous vertex,
0123   //! no edge is built. The method Added can be used to
0124   //! test for this. Neither P nor V is checked to verify
0125   //! that it is coincident with another vertex than the last
0126   //! one, of the polygonal wire under construction. It is
0127   //! also possible to add vertices on a closed polygon
0128   //! (built for example by using a constructor which
0129   //! declares the polygon closed, or after the use of the Close function).
0130   //! Consequently, be careful using this function: you might create:
0131   //! -      a polygonal wire with two consecutive coincident edges, or
0132   //! -      a non manifold polygonal wire.
0133   //! -      P or V is not checked to verify if it is
0134   //! coincident with another vertex but the last one, of
0135   //! the polygonal wire under construction. It is also
0136   //! possible to add vertices on a closed polygon (built
0137   //! for example by using a constructor which declares
0138   //! the polygon closed, or after the use of the Close function).
0139   //! Consequently, be careful when using this function: you might create:
0140   //! -   a polygonal wire with two consecutive coincident edges, or
0141   //! -   a non-manifold polygonal wire.
0142   Standard_EXPORT void Add(const TopoDS_Vertex& V);
0143 
0144   //! Returns true if the last vertex added to the constructed
0145   //! polygonal wire is not coincident with the previous one.
0146   Standard_EXPORT bool Added() const;
0147 
0148   //! Closes the polygonal wire under construction. Note - this
0149   //! is equivalent to adding the first vertex to the polygonal
0150   //! wire under construction.
0151   Standard_EXPORT void Close();
0152 
0153   Standard_EXPORT const TopoDS_Vertex& FirstVertex() const;
0154 
0155   //! Returns the first or the last vertex of the polygonal wire under construction.
0156   //! If the constructed polygonal wire is closed, the first and the last vertices are identical.
0157   Standard_EXPORT const TopoDS_Vertex& LastVertex() const;
0158 
0159   //! Returns true if this algorithm contains a valid polygonal
0160   //! wire (i.e. if there is at least one edge).
0161   //! IsDone returns false if fewer than two vertices have
0162   //! been chained together by this construction algorithm.
0163   Standard_EXPORT bool IsDone() const override;
0164 
0165   //! Returns the edge built between the last two points or
0166   //! vertices added to the constructed polygonal wire under construction.
0167   //! Warning
0168   //! If there is only one vertex in the polygonal wire, the result is a null edge.
0169   Standard_EXPORT const TopoDS_Edge& Edge() const;
0170   Standard_EXPORT                    operator TopoDS_Edge() const;
0171 
0172   //! Returns the constructed polygonal wire, or the already
0173   //! built part of the polygonal wire under construction.
0174   //! Exceptions
0175   //! StdFail_NotDone if the wire is not built, i.e. if fewer than
0176   //! two vertices have been chained together by this construction algorithm.
0177   Standard_EXPORT const TopoDS_Wire& Wire();
0178   Standard_EXPORT                    operator TopoDS_Wire();
0179 
0180 private:
0181   BRepLib_MakePolygon myMakePolygon;
0182 };
0183 
0184 #endif // _BRepBuilderAPI_MakePolygon_HeaderFile