Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-19 10:51:34

0001 // Created on: 1998-07-30
0002 // Created by: Pavel DURANDIN <pdn@nnov.matra-dtv.fr>
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_FreeBoundsProperties_HeaderFile
0018 #define _ShapeAnalysis_FreeBoundsProperties_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopoDS_Shape.hxx>
0025 #include <ShapeAnalysis_FreeBoundData.hxx>
0026 #include <NCollection_Sequence.hxx>
0027 #include <NCollection_HSequence.hxx>
0028 #include <Standard_Integer.hxx>
0029 class ShapeAnalysis_FreeBoundData;
0030 class TopoDS_Wire;
0031 
0032 //! This class is intended to calculate shape free bounds
0033 //! properties.
0034 //! This class provides the following functionalities:
0035 //! - calculates area of the contour,
0036 //! - calculates perimeter of the contour,
0037 //! - calculates ratio of average length to average width of the
0038 //! contour,
0039 //! - estimates average width of contour,
0040 //! - finds the notches (narrow 'V'-like sub-contour) on the
0041 //! contour.
0042 //!
0043 //! For getting free bounds this class uses
0044 //! ShapeAnalysis_FreeBounds class.
0045 //!
0046 //! For description of parameters used for initializing this
0047 //! class refer to CDL of ShapeAnalysis_FreeBounds.
0048 //!
0049 //! Properties of each contour are stored in the data structure
0050 //! ShapeAnalysis_FreeBoundData.
0051 class ShapeAnalysis_FreeBoundsProperties
0052 {
0053 public:
0054   DEFINE_STANDARD_ALLOC
0055 
0056   //! Empty constructor
0057   Standard_EXPORT ShapeAnalysis_FreeBoundsProperties();
0058 
0059   //! Creates the object and calls corresponding Init.
0060   //! <shape> should be a compound of faces.
0061   Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape,
0062                                                      const double        tolerance,
0063                                                      const bool          splitclosed = false,
0064                                                      const bool          splitopen   = false);
0065 
0066   //! Creates the object and calls corresponding Init.
0067   //! <shape> should be a compound of shells.
0068   Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape,
0069                                                      const bool          splitclosed = false,
0070                                                      const bool          splitopen   = false);
0071 
0072   //! Initializes the object with given parameters.
0073   //! <shape> should be a compound of faces.
0074   Standard_EXPORT void Init(const TopoDS_Shape& shape,
0075                             const double        tolerance,
0076                             const bool          splitclosed = false,
0077                             const bool          splitopen   = false);
0078 
0079   //! Initializes the object with given parameters.
0080   //! <shape> should be a compound of shells.
0081   Standard_EXPORT void Init(const TopoDS_Shape& shape,
0082                             const bool          splitclosed = false,
0083                             const bool          splitopen   = false);
0084 
0085   //! Builds and analyzes free bounds of the shape.
0086   //! First calls ShapeAnalysis_FreeBounds for building free
0087   //! bounds.
0088   //! Then on each free bound computes its properties:
0089   //! - area of the contour,
0090   //! - perimeter of the contour,
0091   //! - ratio of average length to average width of the contour,
0092   //! - average width of contour,
0093   //! - notches on the contour and for each notch
0094   //! - maximum width of the notch.
0095   Standard_EXPORT bool Perform();
0096 
0097   //! Returns True if shape is loaded
0098   bool IsLoaded() const;
0099 
0100   //! Returns shape
0101   TopoDS_Shape Shape() const;
0102 
0103   //! Returns tolerance
0104   double Tolerance() const;
0105 
0106   //! Returns number of free bounds
0107   int NbFreeBounds() const;
0108 
0109   //! Returns number of closed free bounds
0110   int NbClosedFreeBounds() const;
0111 
0112   //! Returns number of open free bounds
0113   int NbOpenFreeBounds() const;
0114 
0115   //! Returns all closed free bounds
0116   occ::handle<NCollection_HSequence<occ::handle<ShapeAnalysis_FreeBoundData>>> ClosedFreeBounds()
0117     const;
0118 
0119   //! Returns all open free bounds
0120   occ::handle<NCollection_HSequence<occ::handle<ShapeAnalysis_FreeBoundData>>> OpenFreeBounds()
0121     const;
0122 
0123   //! Returns properties of closed free bound specified by its rank
0124   //! number
0125   occ::handle<ShapeAnalysis_FreeBoundData> ClosedFreeBound(const int index) const;
0126 
0127   //! Returns properties of open free bound specified by its rank
0128   //! number
0129   occ::handle<ShapeAnalysis_FreeBoundData> OpenFreeBound(const int index) const;
0130 
0131   Standard_EXPORT bool DispatchBounds();
0132 
0133   Standard_EXPORT bool CheckContours(const double prec = 0.0);
0134 
0135   Standard_EXPORT bool CheckNotches(const double prec = 0.0);
0136 
0137   Standard_EXPORT bool CheckNotches(occ::handle<ShapeAnalysis_FreeBoundData>& fbData,
0138                                     const double                              prec = 0.0);
0139 
0140   Standard_EXPORT bool CheckNotches(const TopoDS_Wire& freebound,
0141                                     const int          num,
0142                                     TopoDS_Wire&       notch,
0143                                     double&            distMax,
0144                                     const double       prec = 0.0);
0145 
0146   Standard_EXPORT bool FillProperties(occ::handle<ShapeAnalysis_FreeBoundData>& fbData,
0147                                       const double                              prec = 0.0);
0148 
0149 private:
0150   TopoDS_Shape                                                                 myShape;
0151   double                                                                       myTolerance;
0152   bool                                                                         mySplitClosed;
0153   bool                                                                         mySplitOpen;
0154   occ::handle<NCollection_HSequence<occ::handle<ShapeAnalysis_FreeBoundData>>> myClosedFreeBounds;
0155   occ::handle<NCollection_HSequence<occ::handle<ShapeAnalysis_FreeBoundData>>> myOpenFreeBounds;
0156 };
0157 
0158 #include <ShapeAnalysis_FreeBoundsProperties.lxx>
0159 
0160 #endif // _ShapeAnalysis_FreeBoundsProperties_HeaderFile