Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:21:42

0001 // Created on: 1998-06-03
0002 // Created by: data exchange team
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_ShapeTolerance_HeaderFile
0018 #define _ShapeAnalysis_ShapeTolerance_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <TopAbs_ShapeEnum.hxx>
0026 #include <TopoDS_Shape.hxx>
0027 #include <NCollection_Sequence.hxx>
0028 #include <NCollection_HSequence.hxx>
0029 class TopoDS_Shape;
0030 
0031 //! Tool for computing shape tolerances (minimal, maximal, average),
0032 //! finding shape with tolerance matching given criteria,
0033 //! setting or limitating tolerances.
0034 class ShapeAnalysis_ShapeTolerance
0035 {
0036 public:
0037   DEFINE_STANDARD_ALLOC
0038 
0039   //! Empty constructor
0040   Standard_EXPORT ShapeAnalysis_ShapeTolerance();
0041 
0042   //! Determines a tolerance from the ones stored in a shape
0043   //! Remark : calls InitTolerance and AddTolerance,
0044   //! hence, can be used to start a series for cumulating tolerance
0045   //! <mode> = 0 : returns the average value between sub-shapes,
0046   //! <mode> > 0 : returns the maximal found,
0047   //! <mode> < 0 : returns the minimal found.
0048   //! <type> defines what kinds of sub-shapes to consider:
0049   //! SHAPE (default) : all : VERTEX, EDGE, FACE,
0050   //! VERTEX : only vertices,
0051   //! EDGE   : only edges,
0052   //! FACE   : only faces,
0053   //! SHELL  : combined SHELL + FACE, for each face (and containing
0054   //! shell), also checks EDGE and VERTEX
0055   Standard_EXPORT double Tolerance(const TopoDS_Shape&    shape,
0056                                    const int              mode,
0057                                    const TopAbs_ShapeEnum type = TopAbs_SHAPE);
0058 
0059   //! Determines which shapes have a tolerance over the given value
0060   //! <type> is interpreted as in the method Tolerance
0061   Standard_EXPORT occ::handle<NCollection_HSequence<TopoDS_Shape>> OverTolerance(
0062     const TopoDS_Shape&    shape,
0063     const double           value,
0064     const TopAbs_ShapeEnum type = TopAbs_SHAPE) const;
0065 
0066   //! Determines which shapes have a tolerance within a given interval
0067   //! <type> is interpreted as in the method Tolerance
0068   Standard_EXPORT occ::handle<NCollection_HSequence<TopoDS_Shape>> InTolerance(
0069     const TopoDS_Shape&    shape,
0070     const double           valmin,
0071     const double           valmax,
0072     const TopAbs_ShapeEnum type = TopAbs_SHAPE) const;
0073 
0074   //! Initializes computation of cumulated tolerance
0075   Standard_EXPORT void InitTolerance();
0076 
0077   //! Adds data on new Shape to compute Cumulated Tolerance
0078   //! (prepares three computations : maximal, average, minimal)
0079   Standard_EXPORT void AddTolerance(const TopoDS_Shape&    shape,
0080                                     const TopAbs_ShapeEnum type = TopAbs_SHAPE);
0081 
0082   //! Returns the computed tolerance according to the <mode>
0083   //! <mode> = 0 : average
0084   //! <mode> > 0 : maximal
0085   //! <mode> < 0 : minimal
0086   Standard_EXPORT double GlobalTolerance(const int mode) const;
0087 
0088 private:
0089   double myTols[3];
0090   int    myNbTol;
0091 };
0092 
0093 #endif // _ShapeAnalysis_ShapeTolerance_HeaderFile