Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:16:56

0001 // Created on: 1999-09-13
0002 // Created by: data exchange team
0003 // Copyright (c) 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_CheckSmallFace_HeaderFile
0018 #define _ShapeAnalysis_CheckSmallFace_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <TopoDS_Shape.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <NCollection_List.hxx>
0026 #include <TopTools_ShapeMapHasher.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <ShapeExtend_Status.hxx>
0029 class TopoDS_Face;
0030 class gp_Pnt;
0031 class TopoDS_Edge;
0032 class TopoDS_Compound;
0033 
0034 // resolve name collisions with X11 headers
0035 #ifdef Status
0036   #undef Status
0037 #endif
0038 
0039 //! Analysis of the face size
0040 class ShapeAnalysis_CheckSmallFace
0041 {
0042 public:
0043   DEFINE_STANDARD_ALLOC
0044 
0045   //! Creates an empty tool
0046   //! Checks a Shape i.e. each of its faces, records checks as
0047   //! diagnostics in the <infos>
0048   //!
0049   //! If <infos> has not been set before, no check is done
0050   //!
0051   //! For faces which are in a Shell, topological data are recorded
0052   //! to allow recovering connectivities after fixing or removing
0053   //! the small faces or parts of faces
0054   //! Enchains various checks on a face
0055   //! inshell : to compute more information, relevant to topology
0056   Standard_EXPORT ShapeAnalysis_CheckSmallFace();
0057 
0058   //! Checks if a Face is as a Spot
0059   //! Returns 0 if not, 1 if yes, 2 if yes and all vertices are the
0060   //! same
0061   //! By default, considers the tolerance zone of its vertices
0062   //! A given value <tol> may be given to check a spot of this size
0063   //! If a Face is a Spot, its location is returned in <spot>, and
0064   //! <spotol> returns an equivalent tolerance, which is computed as
0065   //! half of max dimension of min-max box of the face
0066   Standard_EXPORT int IsSpotFace(const TopoDS_Face& F,
0067                                  gp_Pnt&            spot,
0068                                  double&            spotol,
0069                                  const double       tol = -1.0) const;
0070 
0071   //! Acts as IsSpotFace, but records in <infos> a diagnostic
0072   //! "SpotFace" with the Pnt as value (data "Location")
0073   Standard_EXPORT bool CheckSpotFace(const TopoDS_Face& F, const double tol = -1.0);
0074 
0075   //! Checks if a Face lies on a Surface which is a strip
0076   //! So the Face is a strip. But a Face may be a strip elsewhere ..
0077   //!
0078   //! A given value <tol> may be given to check max width
0079   //! By default, considers the tolerance zone of its edges
0080   //! Returns 0 if not a strip support, 1 strip in U, 2 strip in V
0081   Standard_EXPORT bool IsStripSupport(const TopoDS_Face& F, const double tol = -1.0);
0082 
0083   //! Checks if two edges define a strip, i.e. distance maxi below
0084   //! tolerance, given or some of those of E1 and E2
0085   Standard_EXPORT bool CheckStripEdges(const TopoDS_Edge& E1,
0086                                        const TopoDS_Edge& E2,
0087                                        const double       tol,
0088                                        double&            dmax) const;
0089 
0090   //! Searches for two and only two edges up tolerance
0091   //! Returns True if OK, false if not 2 edges
0092   //! If True, returns the two edges and their maximum distance
0093   Standard_EXPORT bool FindStripEdges(const TopoDS_Face& F,
0094                                       TopoDS_Edge&       E1,
0095                                       TopoDS_Edge&       E2,
0096                                       const double       tol,
0097                                       double&            dmax);
0098 
0099   //! Checks if a Face is a single strip, i.e. brings two great
0100   //! edges which are confused on their whole length, possible other
0101   //! edges are small or null length
0102   //!
0103   //! Returns 0 if not a strip support, 1 strip in U, 2 strip in V
0104   //! Records diagnostic in info if it is a single strip
0105   Standard_EXPORT bool CheckSingleStrip(const TopoDS_Face& F,
0106                                         TopoDS_Edge&       E1,
0107                                         TopoDS_Edge&       E2,
0108                                         const double       tol = -1.0);
0109 
0110   //! Checks if a Face is as a Strip
0111   //! Returns 0 if not or non determined, 1 if in U, 2 if in V
0112   //! By default, considers the tolerance zone of its edges
0113   //! A given value <tol> may be given to check a strip of max this width
0114   //!
0115   //! If a Face is determined as a Strip, it is delinited by two
0116   //! lists of edges. These lists are recorded in diagnostic
0117   //! Diagnostic "StripFace" brings data "Direction" (U or V),
0118   //! "List1" , "List2" (if they could be computed)
0119   Standard_EXPORT bool CheckStripFace(const TopoDS_Face& F,
0120                                       TopoDS_Edge&       E1,
0121                                       TopoDS_Edge&       E2,
0122                                       const double       tol = -1.0);
0123 
0124   //! Checks if a Face brings vertices which split it, either
0125   //! confused with non adjacent vertices, or confused with their
0126   //! projection on non adjacent edges
0127   //! Returns the count of found splitting vertices
0128   //! Each vertex then brings a diagnostic "SplittingVertex",
0129   //! with data : "Face" for the face, "Edge" for the split edge
0130   Standard_EXPORT int CheckSplittingVertices(
0131     const TopoDS_Face& F,
0132     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>&
0133                                                                                           MapEdges,
0134     NCollection_DataMap<TopoDS_Shape, NCollection_List<double>, TopTools_ShapeMapHasher>& MapParam,
0135     TopoDS_Compound& theAllVert);
0136 
0137   //! Checks if a Face has a pin, which can be edited
0138   //! No singularity : no pin, returns 0
0139   //! If there is a pin, checked topics, with returned value :
0140   //! - 0 : nothing to do more
0141   //! - 1 : "smooth", i.e. not a really sharp pin
0142   //! -> diagnostic "SmoothPin"
0143   //! - 2 : stretched pin, i.e. is possible to relimit the face by
0144   //! another vertex, so that this vertex still gives a pin
0145   //! -> diagnostic "StretchedPin" with location of vertex (Pnt)
0146   Standard_EXPORT bool CheckPin(const TopoDS_Face& F, int& whatrow, int& sence);
0147 
0148   //! Checks if a Face is twisted (apart from checking Pin, i.e. it
0149   //! does not give information on pin, only "it is twisted")
0150   Standard_EXPORT bool CheckTwisted(const TopoDS_Face& F, double& paramu, double& paramv);
0151 
0152   Standard_EXPORT bool CheckPinFace(
0153     const TopoDS_Face&                                                        F,
0154     NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>& mapEdges,
0155     const double                                                              toler = -1.0);
0156 
0157   Standard_EXPORT bool CheckPinEdges(const TopoDS_Edge& theFirstEdge,
0158                                      const TopoDS_Edge& theSecondEdge,
0159                                      const double       coef1,
0160                                      const double       coef2,
0161                                      const double       toler) const;
0162 
0163   //! Returns the status of last call to Perform()
0164   //! ShapeExtend_OK   : face was OK, nothing done
0165   //! ShapeExtend_DONE1: some wires are fixed
0166   //! ShapeExtend_DONE2: orientation of wires fixed
0167   //! ShapeExtend_DONE3: missing seam added
0168   //! ShapeExtend_DONE4: small area wire removed
0169   //! ShapeExtend_DONE5: natural bounds added
0170   //! ShapeExtend_FAIL1: some fails during fixing wires
0171   //! ShapeExtend_FAIL2: cannot fix orientation of wires
0172   //! ShapeExtend_FAIL3: cannot add missing seam
0173   //! ShapeExtend_FAIL4: cannot remove small area wire
0174   bool Status(const ShapeExtend_Status status) const;
0175 
0176   //! Sets a fixed Tolerance to check small face
0177   //! By default, local tolerance zone is considered
0178   //! Sets a fixed MaxTolerance to check small face
0179   //! Sets a fixed Tolerance to check small face
0180   //! By default, local tolerance zone is considered
0181   //! Unset fixed tolerance, comes back to local tolerance zones
0182   //! Unset fixed tolerance, comes back to local tolerance zones
0183   void SetTolerance(const double tol);
0184 
0185   //! Returns the tolerance to check small faces, negative value if
0186   //! local tolerances zones are to be considered
0187   double Tolerance() const;
0188 
0189   bool StatusSpot(const ShapeExtend_Status status) const;
0190 
0191   bool StatusStrip(const ShapeExtend_Status status) const;
0192 
0193   bool StatusPin(const ShapeExtend_Status status) const;
0194 
0195   bool StatusTwisted(const ShapeExtend_Status status) const;
0196 
0197   bool StatusSplitVert(const ShapeExtend_Status status) const;
0198 
0199   bool StatusPinFace(const ShapeExtend_Status status) const;
0200 
0201   bool StatusPinEdges(const ShapeExtend_Status status) const;
0202 
0203 private:
0204   TopoDS_Shape myComp;
0205   int          myStatus;
0206   int          myStatusSpot;
0207   int          myStatusStrip;
0208   int          myStatusPin;
0209   int          myStatusTwisted;
0210   int          myStatusSplitVert;
0211   int          myStatusPinFace;
0212   int          myStatusPinEdges;
0213   double       myPrecision;
0214 };
0215 
0216 #include <ShapeAnalysis_CheckSmallFace.lxx>
0217 
0218 #endif // _ShapeAnalysis_CheckSmallFace_HeaderFile