Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:18:59

0001 // Created on: 2006-08-10
0002 // Created by: Galina KULIKOVA
0003 // Copyright (c) 2006-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _ShapeUpgrade_RemoveInternalWires_HeaderFile
0017 #define _ShapeUpgrade_RemoveInternalWires_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_Type.hxx>
0021 
0022 #include <TopoDS_Shape.hxx>
0023 #include <NCollection_List.hxx>
0024 #include <TopTools_ShapeMapHasher.hxx>
0025 #include <NCollection_IndexedDataMap.hxx>
0026 #include <NCollection_DataMap.hxx>
0027 #include <NCollection_Sequence.hxx>
0028 #include <Standard_Integer.hxx>
0029 #include <ShapeUpgrade_Tool.hxx>
0030 #include <ShapeExtend_Status.hxx>
0031 
0032 // resolve name collisions with X11 headers
0033 #ifdef Status
0034   #undef Status
0035 #endif
0036 
0037 //! Removes all internal wires having area less than specified min area
0038 class ShapeUpgrade_RemoveInternalWires : public ShapeUpgrade_Tool
0039 {
0040 
0041 public:
0042   //! Creates empty constructor.
0043   Standard_EXPORT ShapeUpgrade_RemoveInternalWires();
0044 
0045   Standard_EXPORT ShapeUpgrade_RemoveInternalWires(const TopoDS_Shape& theShape);
0046 
0047   //! Initialize by a Shape.
0048   Standard_EXPORT void Init(const TopoDS_Shape& theShape);
0049 
0050   //! Removes all internal wires having area less than area specified as minimal allowed area
0051   Standard_EXPORT bool Perform();
0052 
0053   //! If specified sequence of shape contains -
0054   //! 1.wires then these wires will be removed if they have area less than allowed min area.
0055   //! 2.faces than internal wires from these faces will be removed if they have area less than
0056   //! allowed min area.
0057   Standard_EXPORT bool Perform(const NCollection_Sequence<TopoDS_Shape>& theSeqShapes);
0058 
0059   //! Get result shape
0060   TopoDS_Shape GetResult() const;
0061 
0062   //! Set min area allowed for holes( all holes having area less than mi area will be removed)
0063   double& MinArea();
0064 
0065   //! Set mode which manage removing faces which have outer wires consisting only from edges
0066   //! belonginig to removed internal wires.
0067   //! By default it is equal to true.
0068   bool& RemoveFaceMode();
0069 
0070   //! Returns sequence of removed faces.
0071   const NCollection_Sequence<TopoDS_Shape>& RemovedFaces() const;
0072 
0073   //! Returns sequence of removed faces.
0074   const NCollection_Sequence<TopoDS_Shape>& RemovedWires() const;
0075 
0076   //! Queries status of last call to Perform()
0077   //! : OK - nothing was done
0078   //! :DONE1 - internal wires were removed
0079   //! :DONE2 - small faces were removed.
0080   //! :FAIL1 - initial shape is not specified
0081   //! :FAIL2 - specified sub-shape is not belonged to inotial shape.
0082   bool Status(const ShapeExtend_Status theStatus) const;
0083 
0084   DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_RemoveInternalWires, ShapeUpgrade_Tool)
0085 
0086 protected:
0087   //! Clear all sequences and temporary map;
0088   Standard_EXPORT void Clear();
0089 
0090   int myStatus;
0091 
0092 private:
0093   //! Removes internal wires having area of contour less than specified MinArea
0094   Standard_EXPORT void removeSmallWire(const TopoDS_Shape& theFace, const TopoDS_Shape& theWire);
0095 
0096   //! Removes faces having outer wire consisting
0097   //! from removed edges(belonging small internal wires)
0098   Standard_EXPORT void removeSmallFaces();
0099 
0100   TopoDS_Shape myShape;
0101   TopoDS_Shape myResult;
0102   double       myMinArea;
0103   bool         myRemoveFacesMode;
0104   NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0105     myEdgeFaces;
0106   NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0107                                      myRemoveEdges;
0108   NCollection_Sequence<TopoDS_Shape> myRemovedFaces;
0109   NCollection_Sequence<TopoDS_Shape> myRemoveWires;
0110 };
0111 
0112 #include <ShapeUpgrade_RemoveInternalWires.lxx>
0113 
0114 #endif // _ShapeUpgrade_RemoveInternalWires_HeaderFile