Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:09

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 
0032 //! Describes functions to build polygonal wires. A
0033 //! polygonal wire can be built from any number of points
0034 //! or vertices, and consists of a sequence of connected
0035 //! rectilinear edges.
0036 //! When a point or vertex is added to the  polygon if
0037 //! it is identic  to the previous  point no  edge  is
0038 //! built. The method added can be used to test it.
0039 //! Construction of a Polygonal Wire
0040 //! You can construct:
0041 //! -   a complete polygonal wire by defining all its points
0042 //! or vertices (limited to four), or
0043 //! -   an empty polygonal wire and add its points or
0044 //! vertices in sequence (unlimited number).
0045 //! A MakePolygon object provides a framework for:
0046 //! -   initializing the construction of a polygonal wire,
0047 //! -   adding points or vertices to the polygonal wire under construction, and
0048 //! -   consulting the result.
0049 class BRepBuilderAPI_MakePolygon  : public BRepBuilderAPI_MakeShape
0050 {
0051 public:
0052 
0053   DEFINE_STANDARD_ALLOC
0054 
0055   
0056   //! Initializes an empty polygonal wire, to which points or
0057   //! vertices are added using the Add function.
0058   //! As soon as the polygonal wire under construction
0059   //! contains vertices, it can be consulted using the Wire function.
0060   Standard_EXPORT BRepBuilderAPI_MakePolygon();
0061   
0062   Standard_EXPORT BRepBuilderAPI_MakePolygon(const gp_Pnt& P1, const gp_Pnt& P2);
0063   
0064   Standard_EXPORT BRepBuilderAPI_MakePolygon(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3, const Standard_Boolean Close = Standard_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, const gp_Pnt& P2, const gp_Pnt& P3, const gp_Pnt& P4, const Standard_Boolean Close = Standard_False);
0082   
0083   Standard_EXPORT BRepBuilderAPI_MakePolygon(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
0084   
0085   Standard_EXPORT BRepBuilderAPI_MakePolygon(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const TopoDS_Vertex& V3, const Standard_Boolean Close = Standard_False);
0086   
0087   //! Constructs a polygonal wire from
0088   //! 2, 3 or 4 vertices. The polygonal wire is closed if Close is true;
0089   //! otherwise it is open (default value). Further vertices can be
0090   //! added using the Add function. The polygonal wire under
0091   //! construction can be consulted at any time by using the Wire function.
0092   //! Example
0093   //! //a closed triangle from three vertices
0094   //! TopoDS_Wire W = BRepBuilderAPI_MakePolygon(V1,V2,V3,Standard_True);
0095   //! Warning
0096   //! The process is equivalent to:
0097   //! -      initializing an empty polygonal wire,
0098   //! -      then adding the given points in sequence.
0099   //! So be careful, as when using this function, you could create a
0100   //! polygonal wire with two consecutive coincident edges if
0101   //! the sequence of vertices v1 - v2 - v1 is found among the
0102   //! constructor's arguments.
0103   Standard_EXPORT BRepBuilderAPI_MakePolygon(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const TopoDS_Vertex& V3, const TopoDS_Vertex& V4, const Standard_Boolean Close = Standard_False);
0104   
0105   Standard_EXPORT void Add (const gp_Pnt& P);
0106   
0107 
0108   //! Adds the point P or the vertex V at the end of the
0109   //! polygonal wire under construction. A vertex is
0110   //! automatically created on the point P.
0111   //! Warning
0112   //! -   When P or V is coincident to the previous vertex,
0113   //! no edge is built. The method Added can be used to
0114   //! test for this. Neither P nor V is checked to verify
0115   //! that it is coincident with another vertex than the last
0116   //! one, of the polygonal wire under construction. It is
0117   //! also possible to add vertices on a closed polygon
0118   //! (built for example by using a constructor which
0119   //! declares the polygon closed, or after the use of the Close function).
0120   //! Consequently, be careful using this function: you might create:
0121   //! -      a polygonal wire with two consecutive coincident edges, or
0122   //! -      a non manifold polygonal wire.
0123   //! -      P or V is not checked to verify if it is
0124   //! coincident with another vertex but the last one, of
0125   //! the polygonal wire under construction. It is also
0126   //! possible to add vertices on a closed polygon (built
0127   //! for example by using a constructor which declares
0128   //! the polygon closed, or after the use of the Close function).
0129   //! Consequently, be careful when using this function: you might create:
0130   //! -   a polygonal wire with two consecutive coincident edges, or
0131   //! -   a non-manifold polygonal wire.
0132   Standard_EXPORT void Add (const TopoDS_Vertex& V);
0133   
0134   //! Returns true if the last vertex added to the constructed
0135   //! polygonal wire is not coincident with the previous one.
0136   Standard_EXPORT Standard_Boolean Added() const;
0137   
0138   //! Closes the polygonal wire under construction. Note - this
0139   //! is equivalent to adding the first vertex to the polygonal
0140   //! wire under construction.
0141   Standard_EXPORT void Close();
0142   
0143   Standard_EXPORT const TopoDS_Vertex& FirstVertex() const;
0144   
0145   //! Returns the first or the last vertex of the polygonal wire under construction.
0146   //! If the constructed polygonal wire is closed, the first and the last vertices are identical.
0147   Standard_EXPORT const TopoDS_Vertex& LastVertex() const;
0148   
0149 
0150   //! Returns true if this algorithm contains a valid polygonal
0151   //! wire (i.e. if there is at least one edge).
0152   //! IsDone returns false if fewer than two vertices have
0153   //! been chained together by this construction algorithm.
0154   Standard_EXPORT virtual Standard_Boolean IsDone() const Standard_OVERRIDE;
0155   
0156   //! Returns the edge built between the last two points or
0157   //! vertices added to the constructed polygonal wire under construction.
0158   //! Warning
0159   //! If there is only one vertex in the polygonal wire, the result is a null edge.
0160   Standard_EXPORT const TopoDS_Edge& Edge() const;
0161 Standard_EXPORT operator TopoDS_Edge() const;
0162   
0163 
0164   //! Returns the constructed polygonal wire, or the already
0165   //! built part of the polygonal wire under construction.
0166   //! Exceptions
0167   //! StdFail_NotDone if the wire is not built, i.e. if fewer than
0168   //! two vertices have been chained together by this construction algorithm.
0169   Standard_EXPORT const TopoDS_Wire& Wire();
0170   Standard_EXPORT operator TopoDS_Wire();
0171 
0172 
0173 
0174 
0175 protected:
0176 
0177 
0178 
0179 
0180 
0181 private:
0182 
0183 
0184 
0185   BRepLib_MakePolygon myMakePolygon;
0186 
0187 
0188 };
0189 
0190 
0191 
0192 
0193 
0194 
0195 
0196 #endif // _BRepBuilderAPI_MakePolygon_HeaderFile