Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:17:59

0001 // Created on: 1998-06-03
0002 // Created by: Daniel RISSER
0003 // Copyright (c) 1998-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 _ShapeAnalysis_FreeBounds_HeaderFile
0018 #define _ShapeAnalysis_FreeBounds_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopoDS_Compound.hxx>
0025 #include <TopTools_HSequenceOfShape.hxx>
0026 #include <TopTools_DataMapOfShapeShape.hxx>
0027 class TopoDS_Shape;
0028 
0029 //! This class is intended to output free bounds of the shape.
0030 //!
0031 //! Free bounds are the wires consisting of edges referenced by the faces of the shape
0032 //! only once; these are the edges composing the outer boundary of the face or shell
0033 //! (as opposed to internal edges between the faces in the shell or seam edges on closed faces).
0034 //!
0035 //! This class works on two distinct types of shapes when analyzing
0036 //! their free bounds:
0037 //! 1. compound of faces.
0038 //! Analyzer of sewing algorithm (BRepAlgo_Sewing) is used for
0039 //! for forecasting free bounds that would be obtained after
0040 //! performing sewing
0041 //! 2. compound of shells.
0042 //! Actual free bounds (edges shared by the only face in the shell)
0043 //! are output in this case. ShapeAnalysis_Shell is used for that.
0044 //!
0045 //! When connecting edges into the wires algorithm tries to build
0046 //! wires of maximum length. Two options are provided for a user
0047 //! to extract closed sub-contours out of closed and/or open contours.
0048 //!
0049 //! Free bounds are returned as two compounds, one for closed and one
0050 //! for open wires.
0051 //!
0052 //! This class also provides some static methods for advanced use:
0053 //! connecting edges/wires to wires, extracting closed sub-wires out
0054 //! of wires, dispatching wires into compounds for closed and open
0055 //! wires.
0056 //! NOTE. Ends of the edge or wire mean hereafter their end vertices.
0057 class ShapeAnalysis_FreeBounds
0058 {
0059 public:
0060   DEFINE_STANDARD_ALLOC
0061 
0062   //! Empty constructor
0063   Standard_EXPORT ShapeAnalysis_FreeBounds();
0064 
0065   //! Builds forecasting free bounds of the <shape>.
0066   //! <shape> should be a compound of faces.
0067   //! This constructor is to be used for forecasting free edges
0068   //! with help of sewing analyzer BRepAlgo_Sewing which is called
0069   //! with tolerance <toler>.
0070   //! Free edges are connected into wires only when their ends are
0071   //! at distance less than <toler>.
0072   //! If <splitclosed> is True extracts closed sub-wires out of
0073   //! built closed wires.
0074   //! If <splitopen> is True extracts closed sub-wires out of
0075   //! built open wires.
0076   Standard_EXPORT ShapeAnalysis_FreeBounds(const TopoDS_Shape&    shape,
0077                                            const Standard_Real    toler,
0078                                            const Standard_Boolean splitclosed = Standard_False,
0079                                            const Standard_Boolean splitopen   = Standard_True);
0080 
0081   //! Builds actual free bounds of the <shape>.
0082   //! <shape> should be a compound of shells.
0083   //! This constructor is to be used for getting free edges (ones
0084   //! referenced by the only face) with help of analyzer
0085   //! ShapeAnalysis_Shell.
0086   //! Free edges are connected into wires only when they share the
0087   //! same vertex.
0088   //! If <splitclosed> is True extracts closed sub-wires out of
0089   //! built closed wires.
0090   //! If <splitopen> is True extracts closed sub-wires out of
0091   //! built open wires.
0092   Standard_EXPORT ShapeAnalysis_FreeBounds(
0093     const TopoDS_Shape&    shape,
0094     const Standard_Boolean splitclosed        = Standard_False,
0095     const Standard_Boolean splitopen          = Standard_True,
0096     const Standard_Boolean checkinternaledges = Standard_False);
0097 
0098   //! Returns compound of closed wires out of free edges.
0099   const TopoDS_Compound& GetClosedWires() const;
0100 
0101   //! Returns compound of open wires out of free edges.
0102   const TopoDS_Compound& GetOpenWires() const;
0103 
0104   //! Builds sequence of <wires> out of sequence of not sorted
0105   //! <edges>.
0106   //! Tries to build wires of maximum length. Building a wire is
0107   //! stopped when no edges can be connected to it at its head or
0108   //! at its tail.
0109   //!
0110   //! Orientation of the edge can change when connecting.
0111   //! If <shared> is True connection is performed only when
0112   //! adjacent edges share the same vertex.
0113   //! If <shared> is False connection is performed only when
0114   //! ends of adjacent edges are at distance less than <toler>.
0115   Standard_EXPORT static void ConnectEdgesToWires(Handle(TopTools_HSequenceOfShape)& edges,
0116                                                   const Standard_Real                toler,
0117                                                   const Standard_Boolean             shared,
0118                                                   Handle(TopTools_HSequenceOfShape)& wires);
0119 
0120   Standard_EXPORT static void ConnectWiresToWires(Handle(TopTools_HSequenceOfShape)& iwires,
0121                                                   const Standard_Real                toler,
0122                                                   const Standard_Boolean             shared,
0123                                                   Handle(TopTools_HSequenceOfShape)& owires);
0124 
0125   //! Builds sequence of <owires> out of sequence of not sorted
0126   //! <iwires>.
0127   //! Tries to build wires of maximum length. Building a wire is
0128   //! stopped when no wires can be connected to it at its head or
0129   //! at its tail.
0130   //!
0131   //! Orientation of the wire can change when connecting.
0132   //! If <shared> is True connection is performed only when
0133   //! adjacent wires share the same vertex.
0134   //! If <shared> is False connection is performed only when
0135   //! ends of adjacent wires are at distance less than <toler>.
0136   //! Map <vertices> stores the correspondence between original
0137   //! end vertices of the wires and new connecting vertices.
0138   Standard_EXPORT static void ConnectWiresToWires(Handle(TopTools_HSequenceOfShape)& iwires,
0139                                                   const Standard_Real                toler,
0140                                                   const Standard_Boolean             shared,
0141                                                   Handle(TopTools_HSequenceOfShape)& owires,
0142                                                   TopTools_DataMapOfShapeShape&      vertices);
0143 
0144   //! Extracts closed sub-wires out of <wires> and adds them
0145   //! to <closed>, open wires remained after extraction are put
0146   //! into <open>.
0147   //! If <shared> is True extraction is performed only when
0148   //! edges share the same vertex.
0149   //! If <shared> is False connection is performed only when
0150   //! ends of the edges are at distance less than <toler>.
0151   Standard_EXPORT static void SplitWires(const Handle(TopTools_HSequenceOfShape)& wires,
0152                                          const Standard_Real                      toler,
0153                                          const Standard_Boolean                   shared,
0154                                          Handle(TopTools_HSequenceOfShape)&       closed,
0155                                          Handle(TopTools_HSequenceOfShape)&       open);
0156 
0157   //! Dispatches sequence of <wires> into two compounds
0158   //! <closed> for closed wires and <open> for open wires.
0159   //! If a compound is not empty wires are added into it.
0160   Standard_EXPORT static void DispatchWires(const Handle(TopTools_HSequenceOfShape)& wires,
0161                                             TopoDS_Compound&                         closed,
0162                                             TopoDS_Compound&                         open);
0163 
0164 protected:
0165 private:
0166   Standard_EXPORT void SplitWires();
0167 
0168   TopoDS_Compound  myWires;
0169   TopoDS_Compound  myEdges;
0170   Standard_Real    myTolerance;
0171   Standard_Boolean myShared;
0172   Standard_Boolean mySplitClosed;
0173   Standard_Boolean mySplitOpen;
0174 };
0175 
0176 #include <ShapeAnalysis_FreeBounds.lxx>
0177 
0178 #endif // _ShapeAnalysis_FreeBounds_HeaderFile