Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:54

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