Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:59:15

0001 // Created on: 1999-08-24
0002 // Created by: Sergei ZERTCHANINOV
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 _ShapeFix_Wireframe_HeaderFile
0018 #define _ShapeFix_Wireframe_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TopoDS_Shape.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <ShapeFix_Root.hxx>
0026 #include <TopTools_ShapeMapHasher.hxx>
0027 #include <NCollection_Map.hxx>
0028 #include <NCollection_List.hxx>
0029 #include <NCollection_DataMap.hxx>
0030 #include <ShapeExtend_Status.hxx>
0031 
0032 //! Provides methods for fixing wireframe of shape
0033 class ShapeFix_Wireframe : public ShapeFix_Root
0034 {
0035 
0036 public:
0037   Standard_EXPORT ShapeFix_Wireframe();
0038 
0039   Standard_EXPORT ShapeFix_Wireframe(const TopoDS_Shape& shape);
0040 
0041   //! Clears all statuses
0042   Standard_EXPORT virtual void ClearStatuses();
0043 
0044   //! Loads a shape, resets statuses
0045   Standard_EXPORT void Load(const TopoDS_Shape& shape);
0046 
0047   //! Fixes gaps between ends of curves of adjacent edges
0048   //! (both 3d and pcurves) in wires
0049   //! If precision is 0.0, uses Precision::Confusion().
0050   Standard_EXPORT bool FixWireGaps();
0051 
0052   //! Fixes small edges in shape by merging adjacent edges
0053   //! If precision is 0.0, uses Precision::Confusion().
0054   Standard_EXPORT bool FixSmallEdges();
0055 
0056   //! Auxiliary tool for FixSmallEdges which checks for small edges and fills the maps.
0057   //! Returns True if at least one small edge has been found.
0058   Standard_EXPORT bool CheckSmallEdges(
0059     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& theSmallEdges,
0060     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>&
0061       theEdgeToFaces,
0062     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>&
0063                                                             theFaceWithSmall,
0064     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& theMultyEdges);
0065 
0066   //! Auxiliary tool for FixSmallEdges which merges small edges.
0067   //! If theModeDrop is equal to true then small edges,
0068   //! which cannot be connected with adjacent edges are dropped.
0069   //! Otherwise they are kept.
0070   //! theLimitAngle specifies maximum allowed tangency
0071   //! discontinuity between adjacent edges.
0072   //! If theLimitAngle is equal to -1, this angle is not taken into account.
0073   Standard_EXPORT bool MergeSmallEdges(
0074     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& theSmallEdges,
0075     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>&
0076       theEdgeToFaces,
0077     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>&
0078                                                             theFaceWithSmall,
0079     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& theMultyEdges,
0080     const bool                                              theModeDrop   = false,
0081     const double                                            theLimitAngle = -1);
0082 
0083   //! Decodes the status of the last FixWireGaps.
0084   //! OK - No gaps were found
0085   //! DONE1 - Some gaps in 3D were fixed
0086   //! DONE2 - Some gaps in 2D were fixed
0087   //! FAIL1 - Failed to fix some gaps in 3D
0088   //! FAIL2 - Failed to fix some gaps in 2D
0089   bool StatusWireGaps(const ShapeExtend_Status status) const;
0090 
0091   //! Decodes the status of the last FixSmallEdges.
0092   //! OK - No small edges were found
0093   //! DONE1 - Some small edges were fixed
0094   //! FAIL1 - Failed to fix some small edges
0095   bool StatusSmallEdges(const ShapeExtend_Status status) const;
0096 
0097   TopoDS_Shape Shape();
0098 
0099   //! Returns mode managing removing small edges.
0100   bool& ModeDropSmallEdges();
0101 
0102   //! Set limit angle for merging edges.
0103   void SetLimitAngle(const double theLimitAngle);
0104 
0105   //! Get limit angle for merging edges.
0106   double LimitAngle() const;
0107 
0108   DEFINE_STANDARD_RTTIEXT(ShapeFix_Wireframe, ShapeFix_Root)
0109 
0110 protected:
0111   TopoDS_Shape myShape;
0112 
0113 private:
0114   bool   myModeDrop;
0115   double myLimitAngle;
0116   int    myStatusWireGaps;
0117   int    myStatusSmallEdges;
0118 };
0119 
0120 #include <ShapeFix_Wireframe.lxx>
0121 
0122 #endif // _ShapeFix_Wireframe_HeaderFile