Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:09

0001 // Created on: 1995-12-08
0002 // Created by: Jacques GOUSSARD
0003 // Copyright (c) 1995-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 _BRepCheck_Analyzer_HeaderFile
0018 #define _BRepCheck_Analyzer_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopoDS_Shape.hxx>
0025 #include <BRepCheck_IndexedDataMapOfShapeResult.hxx>
0026 #include <TopAbs_ShapeEnum.hxx>
0027 class BRepCheck_Result;
0028 
0029 //! A framework to check the overall
0030 //! validity of a shape. For a shape to be valid in Open
0031 //! CASCADE, it - or its component subshapes - must respect certain
0032 //! criteria. These criteria are checked by the function IsValid.
0033 //! Once you have determined whether a shape is valid or not, you can
0034 //! diagnose its specific anomalies and correct them using the services of
0035 //! the ShapeAnalysis, ShapeUpgrade, and ShapeFix packages.
0036 class BRepCheck_Analyzer 
0037 {
0038 public:
0039 
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Constructs a shape validation object defined by the shape S.
0043   //! <S> is the  shape  to control.  <GeomControls>  If
0044   //! False   only topological informaions  are checked.
0045   //! The geometricals controls are
0046   //! For a Vertex :
0047   //! BRepCheck_InvalidToleranceValue  NYI
0048   //! For an Edge :
0049   //! BRepCheck_InvalidCurveOnClosedSurface,
0050   //! BRepCheck_InvalidCurveOnSurface,
0051   //! BRepCheck_InvalidSameParameterFlag,
0052   //! BRepCheck_InvalidToleranceValue  NYI
0053   //! For a face :
0054   //! BRepCheck_UnorientableShape,
0055   //! BRepCheck_IntersectingWires,
0056   //! BRepCheck_InvalidToleranceValue  NYI
0057   //! For a wire :
0058   //! BRepCheck_SelfIntersectingWire
0059   BRepCheck_Analyzer (const TopoDS_Shape& S,
0060                       const Standard_Boolean GeomControls = Standard_True,
0061                       const Standard_Boolean theIsParallel = Standard_False,
0062                       const Standard_Boolean theIsExact = Standard_False)
0063     : myIsParallel(theIsParallel),
0064       myIsExact(theIsExact)
0065   {
0066     Init (S, GeomControls);
0067   }
0068 
0069   //! <S> is the  shape  to control.  <GeomControls>  If
0070   //! False   only topological informaions  are checked.
0071   //! The geometricals controls are
0072   //! For a Vertex :
0073   //! BRepCheck_InvalidTolerance  NYI
0074   //! For an Edge :
0075   //! BRepCheck_InvalidCurveOnClosedSurface,
0076   //! BRepCheck_InvalidCurveOnSurface,
0077   //! BRepCheck_InvalidSameParameterFlag,
0078   //! BRepCheck_InvalidTolerance  NYI
0079   //! For a face :
0080   //! BRepCheck_UnorientableShape,
0081   //! BRepCheck_IntersectingWires,
0082   //! BRepCheck_InvalidTolerance  NYI
0083   //! For a wire :
0084   //! BRepCheck_SelfIntersectingWire
0085   Standard_EXPORT void Init (const TopoDS_Shape& S,
0086                              const Standard_Boolean GeomControls = Standard_True);
0087 
0088   //! Sets method to calculate distance: Calculating in finite number of points (if theIsExact
0089   //! is false, faster, but possible not correct result) or exact calculating by using 
0090   //! BRepLib_CheckCurveOnSurface class (if theIsExact is true, slowly, but more correctly).
0091   //! Exact method is used only when edge is SameParameter.
0092   //! Default method is calculating in finite number of points
0093   void SetExactMethod(const Standard_Boolean theIsExact)
0094   {
0095     myIsExact = theIsExact;
0096   }
0097 
0098   //! Returns true if exact method selected
0099   Standard_Boolean IsExactMethod()
0100   {
0101     return myIsExact;
0102   }
0103 
0104   //! Sets parallel flag
0105   void SetParallel(const Standard_Boolean theIsParallel)
0106   {
0107     myIsParallel = theIsParallel;
0108   }
0109 
0110   //! Returns true if parallel flag is set
0111   Standard_Boolean IsParallel()
0112   {
0113     return myIsParallel;
0114   }
0115 
0116   //! <S> is a  subshape of the  original shape. Returns
0117   //! <STandard_True> if no default has been detected on
0118   //! <S> and any of its subshape.
0119   Standard_EXPORT Standard_Boolean IsValid (const TopoDS_Shape& S) const;
0120   
0121   //! Returns true if no defect is
0122   //! detected on the shape S or any of its subshapes.
0123   //! Returns true if the shape S is valid.
0124   //! This function checks whether a given shape is valid by checking that:
0125   //! -      the topology is correct
0126   //! -      parameterization of edges in particular is correct.
0127   //! For the topology to be correct, the following conditions must be satisfied:
0128   //! -      edges should have at least two vertices if they are not
0129   //! degenerate edges. The vertices should be within the range of
0130   //! the bounding edges at the tolerance specified in the vertex,
0131   //! -      edges should share at least one face. The representation of
0132   //! the edges should be within the tolerance criterion assigned to them.
0133   //! -      wires defining a face should not self-intersect and should be closed,
0134   //! - there should be one wire which contains all other wires inside a face,
0135   //! -      wires should be correctly oriented with respect to each of the edges,
0136   //! -      faces should be correctly oriented, in particular with
0137   //! respect to adjacent faces if these faces define a solid,
0138   //! -      shells defining a solid should be closed. There should
0139   //! be one enclosing shell if the shape is a solid;
0140   //! To check parameterization of edge, there are 2 approaches depending on
0141   //! the edge?s contextual situation.
0142   //! -      if the edge is either single, or it is in the context
0143   //! of a wire or a compound, its parameterization is defined by
0144   //! the parameterization of its 3D curve and is considered as    valid.
0145   //! -      If the edge is in the context of a face, it should
0146   //! have SameParameter and SameRange flags set to Standard_True. To
0147   //! check these flags, you should call the function
0148   //! BRep_Tool::SameParameter and BRep_Tool::SameRange for an
0149   //! edge. If at least one of these flags is set to Standard_False,
0150   //! the edge is considered as invalid without any additional check.
0151   //! If the edge is contained by a face, and it has SameParameter and
0152   //! SameRange flags set to Standard_True, IsValid checks
0153   //! whether representation of the edge on face, in context of which the
0154   //! edge is considered, has the same parameterization up to the
0155   //! tolerance value coded on the edge. For a given parameter t on the edge
0156   //! having C as a 3D curve and one PCurve P on a surface S (base
0157   //! surface of the reference face), this checks that |C(t) - S(P(t))|
0158   //! is less than or equal to tolerance, where tolerance is the tolerance
0159   //! value coded on the edge.
0160   Standard_Boolean IsValid() const
0161   {
0162     return IsValid (myShape);
0163   }
0164 
0165   const Handle(BRepCheck_Result)& Result (const TopoDS_Shape& theSubS) const
0166   {
0167     return myMap.FindFromKey (theSubS);
0168   }
0169 
0170 private:
0171 
0172   Standard_EXPORT void Put (const TopoDS_Shape& S,
0173                             const Standard_Boolean Gctrl);
0174 
0175   Standard_EXPORT void Perform();
0176 
0177   Standard_EXPORT Standard_Boolean ValidSub (const TopoDS_Shape& S, const TopAbs_ShapeEnum SubType) const;
0178 
0179 private:
0180 
0181   TopoDS_Shape myShape;
0182   BRepCheck_IndexedDataMapOfShapeResult myMap;
0183   Standard_Boolean myIsParallel;
0184   Standard_Boolean myIsExact;
0185 
0186 };
0187 
0188 #endif // _BRepCheck_Analyzer_HeaderFile