Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1993-07-08
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 _BRepLib_MakeWire_HeaderFile
0018 #define _BRepLib_MakeWire_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <BRepLib_WireError.hxx>
0024 #include <TopoDS_Edge.hxx>
0025 #include <TopoDS_Vertex.hxx>
0026 #include <TopTools_DataMapOfShapeShape.hxx>
0027 #include <TopTools_IndexedMapOfShape.hxx>
0028 #include <BRepLib_MakeShape.hxx>
0029 #include <TopTools_ListOfShape.hxx>
0030 #include <Bnd_Box.hxx>
0031 #include <NCollection_UBTree.hxx>
0032 
0033 class TopoDS_Wire;
0034 
0035 //! Provides methods to build wires.
0036 //!
0037 //! A wire may be built :
0038 //!
0039 //! * From a single edge.
0040 //!
0041 //! * From a wire and an edge.
0042 //!
0043 //! - A new wire  is created with the edges  of  the
0044 //! wire + the edge.
0045 //!
0046 //! - If the edge is not connected  to the wire the
0047 //! flag NotDone   is set and  the  method Wire will
0048 //! raise an error.
0049 //!
0050 //! - The connection may be :
0051 //!
0052 //! . Through an existing vertex. The edge is shared.
0053 //!
0054 //! . Through a geometric coincidence of vertices.
0055 //! The edge is  copied  and the vertices from the
0056 //! edge are  replaced  by  the vertices from  the
0057 //! wire.
0058 //!
0059 //! . The new edge and the connection vertices are
0060 //! kept by the algorithm.
0061 //!
0062 //! * From 2, 3, 4 edges.
0063 //!
0064 //! - A wire is  created from  the first edge, the
0065 //! following edges are added.
0066 //!
0067 //! * From many edges.
0068 //!
0069 //! - The following syntax may be used :
0070 //!
0071 //! BRepLib_MakeWire MW;
0072 //!
0073 //! // for all the edges ...
0074 //! MW.Add(anEdge);
0075 //!
0076 //! TopoDS_Wire W = MW;
0077 
0078 class BRepLib_MakeWire  : public BRepLib_MakeShape
0079 {
0080 public:
0081 
0082   DEFINE_STANDARD_ALLOC
0083 
0084   
0085   //! NotDone MakeWire.
0086   Standard_EXPORT BRepLib_MakeWire();
0087   
0088   //! Make a Wire from an edge.
0089   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E);
0090   
0091   //! Make a Wire from two edges.
0092   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2);
0093   
0094   //! Make a Wire from three edges.
0095   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& E3);
0096   
0097   //! Make a Wire from four edges.
0098   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& E3, const TopoDS_Edge& E4);
0099   
0100   //! Make a Wire from a Wire. Useful for adding later.
0101   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Wire& W);
0102   
0103   //! Add an edge to a wire.
0104   Standard_EXPORT BRepLib_MakeWire(const TopoDS_Wire& W, const TopoDS_Edge& E);
0105   
0106   //! Add the edge <E> to the current wire.
0107   Standard_EXPORT void Add (const TopoDS_Edge& E);
0108   
0109   //! Add the edges of <W> to the current wire.
0110   Standard_EXPORT void Add (const TopoDS_Wire& W);
0111   
0112   //! Add the edges of <L> to the current wire.
0113   //! The edges are not to be consecutive.  But they are
0114   //! to be all connected geometrically or topologically.
0115   Standard_EXPORT void Add (const TopTools_ListOfShape& L);
0116   
0117   Standard_EXPORT BRepLib_WireError Error() const;
0118   
0119   //! Returns the new wire.
0120   Standard_EXPORT const TopoDS_Wire& Wire();
0121   Standard_EXPORT operator TopoDS_Wire();
0122   
0123   //! Returns the last edge added to the wire.
0124   Standard_EXPORT const TopoDS_Edge& Edge() const;
0125   
0126   //! Returns the last connecting vertex.
0127   Standard_EXPORT const TopoDS_Vertex& Vertex() const;
0128 
0129 private:
0130   class BRepLib_BndBoxVertexSelector : public NCollection_UBTree <Standard_Integer,Bnd_Box>::Selector
0131   {
0132   public:
0133     BRepLib_BndBoxVertexSelector(const TopTools_IndexedMapOfShape& theMapOfShape)
0134     : BRepLib_BndBoxVertexSelector::Selector(),
0135       myMapOfShape (theMapOfShape),
0136       myTolP(0.0),
0137       myVInd(0)
0138     {
0139     }
0140 
0141     Standard_Boolean Reject (const Bnd_Box& theBox) const
0142     {
0143       return theBox.IsOut(myVBox);
0144     }
0145 
0146     Standard_Boolean Accept (const Standard_Integer& theObj);
0147 
0148     void SetCurrentVertex (const gp_Pnt& theP, Standard_Real theTol, 
0149                            Standard_Integer theVInd);
0150 
0151     const NCollection_List<Standard_Integer>& GetResultInds () const
0152     { 
0153       return myResultInd;
0154     }
0155 
0156     void ClearResInds()
0157     { 
0158       myResultInd.Clear();
0159     }
0160 
0161   private:
0162 
0163     BRepLib_BndBoxVertexSelector(const BRepLib_BndBoxVertexSelector& );
0164     BRepLib_BndBoxVertexSelector& operator=(const BRepLib_BndBoxVertexSelector& );
0165 
0166     const TopTools_IndexedMapOfShape& myMapOfShape; //vertices
0167     gp_Pnt myP;
0168     Standard_Real myTolP;
0169     Standard_Integer myVInd;
0170     Bnd_Box myVBox;
0171     NCollection_List<Standard_Integer> myResultInd; 
0172   };
0173 
0174   void CollectCoincidentVertices(const TopTools_ListOfShape& theL,
0175                                  NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
0176 
0177   void CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL, 
0178                          TopTools_DataMapOfShapeShape& theO2NV);
0179 
0180   void CreateNewListOfEdges(const TopTools_ListOfShape& theL,
0181                             const TopTools_DataMapOfShapeShape& theO2NV,
0182                             TopTools_ListOfShape& theNewEList);
0183 
0184   void Add(const TopoDS_Edge& E, Standard_Boolean IsCheckGeometryProximity);
0185 
0186 
0187 
0188 protected:
0189 
0190 
0191 
0192 private:
0193 
0194   BRepLib_WireError myError;
0195   TopoDS_Edge myEdge;
0196   TopoDS_Vertex myVertex;
0197   TopTools_IndexedMapOfShape myVertices;
0198   TopoDS_Vertex FirstVertex;
0199   TopoDS_Vertex VF;
0200   TopoDS_Vertex VL;
0201 
0202 };
0203 
0204 
0205 
0206 
0207 
0208 
0209 
0210 #endif // _BRepLib_MakeWire_HeaderFile