Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 08:17:50

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_HSequenceOfFreeBounds.hxx>
0026 #include <Standard_Integer.hxx>
0027 class ShapeAnalysis_FreeBoundData;
0028 class TopoDS_Wire;
0029 
0030 //! This class is intended to calculate shape free bounds
0031 //! properties.
0032 //! This class provides the following functionalities:
0033 //! - calculates area of the contour,
0034 //! - calculates perimeter of the contour,
0035 //! - calculates ratio of average length to average width of the
0036 //! contour,
0037 //! - estimates average width of contour,
0038 //! - finds the notches (narrow 'V'-like sub-contour) on the
0039 //! contour.
0040 //!
0041 //! For getting free bounds this class uses
0042 //! ShapeAnalysis_FreeBounds class.
0043 //!
0044 //! For description of parameters used for initializing this
0045 //! class refer to CDL of ShapeAnalysis_FreeBounds.
0046 //!
0047 //! Properties of each contour are stored in the data structure
0048 //! ShapeAnalysis_FreeBoundData.
0049 class ShapeAnalysis_FreeBoundsProperties
0050 {
0051 public:
0052   DEFINE_STANDARD_ALLOC
0053 
0054   //! Empty constructor
0055   Standard_EXPORT ShapeAnalysis_FreeBoundsProperties();
0056 
0057   //! Creates the object and calls corresponding Init.
0058   //! <shape> should be a compound of faces.
0059   Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(
0060     const TopoDS_Shape&    shape,
0061     const Standard_Real    tolerance,
0062     const Standard_Boolean splitclosed = Standard_False,
0063     const Standard_Boolean splitopen   = Standard_False);
0064 
0065   //! Creates the object and calls corresponding Init.
0066   //! <shape> should be a compound of shells.
0067   Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(
0068     const TopoDS_Shape&    shape,
0069     const Standard_Boolean splitclosed = Standard_False,
0070     const Standard_Boolean splitopen   = Standard_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 Standard_Real    tolerance,
0076                             const Standard_Boolean splitclosed = Standard_False,
0077                             const Standard_Boolean splitopen   = Standard_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 Standard_Boolean splitclosed = Standard_False,
0083                             const Standard_Boolean splitopen   = Standard_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 Standard_Boolean Perform();
0096 
0097   //! Returns True if shape is loaded
0098   Standard_Boolean IsLoaded() const;
0099 
0100   //! Returns shape
0101   TopoDS_Shape Shape() const;
0102 
0103   //! Returns tolerance
0104   Standard_Real Tolerance() const;
0105 
0106   //! Returns number of free bounds
0107   Standard_Integer NbFreeBounds() const;
0108 
0109   //! Returns number of closed free bounds
0110   Standard_Integer NbClosedFreeBounds() const;
0111 
0112   //! Returns number of open free bounds
0113   Standard_Integer NbOpenFreeBounds() const;
0114 
0115   //! Returns all closed free bounds
0116   Handle(ShapeAnalysis_HSequenceOfFreeBounds) ClosedFreeBounds() const;
0117 
0118   //! Returns all open free bounds
0119   Handle(ShapeAnalysis_HSequenceOfFreeBounds) OpenFreeBounds() const;
0120 
0121   //! Returns properties of closed free bound specified by its rank
0122   //! number
0123   Handle(ShapeAnalysis_FreeBoundData) ClosedFreeBound(const Standard_Integer index) const;
0124 
0125   //! Returns properties of open free bound specified by its rank
0126   //! number
0127   Handle(ShapeAnalysis_FreeBoundData) OpenFreeBound(const Standard_Integer index) const;
0128 
0129   Standard_EXPORT Standard_Boolean DispatchBounds();
0130 
0131   Standard_EXPORT Standard_Boolean CheckContours(const Standard_Real prec = 0.0);
0132 
0133   Standard_EXPORT Standard_Boolean CheckNotches(const Standard_Real prec = 0.0);
0134 
0135   Standard_EXPORT Standard_Boolean CheckNotches(Handle(ShapeAnalysis_FreeBoundData)& fbData,
0136                                                 const Standard_Real                  prec = 0.0);
0137 
0138   Standard_EXPORT Standard_Boolean CheckNotches(const TopoDS_Wire&     freebound,
0139                                                 const Standard_Integer num,
0140                                                 TopoDS_Wire&           notch,
0141                                                 Standard_Real&         distMax,
0142                                                 const Standard_Real    prec = 0.0);
0143 
0144   Standard_EXPORT Standard_Boolean FillProperties(Handle(ShapeAnalysis_FreeBoundData)& fbData,
0145                                                   const Standard_Real                  prec = 0.0);
0146 
0147 protected:
0148 private:
0149   TopoDS_Shape                                myShape;
0150   Standard_Real                               myTolerance;
0151   Standard_Boolean                            mySplitClosed;
0152   Standard_Boolean                            mySplitOpen;
0153   Handle(ShapeAnalysis_HSequenceOfFreeBounds) myClosedFreeBounds;
0154   Handle(ShapeAnalysis_HSequenceOfFreeBounds) myOpenFreeBounds;
0155 };
0156 
0157 #include <ShapeAnalysis_FreeBoundsProperties.lxx>
0158 
0159 #endif // _ShapeAnalysis_FreeBoundsProperties_HeaderFile