Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-11 10:37:26

0001 // Created on: 1995-10-26
0002 // Created by: Yves FRICAUD
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 _BRepOffset_MakeOffset_HeaderFile
0018 #define _BRepOffset_MakeOffset_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopoDS_Shape.hxx>
0025 #include <TopoDS_Compound.hxx>
0026 #include <BRepOffset_Mode.hxx>
0027 #include <GeomAbs_JoinType.hxx>
0028 #include <TopTools_ShapeMapHasher.hxx>
0029 #include <NCollection_IndexedMap.hxx>
0030 #include <BRepOffset_Analyse.hxx>
0031 #include <BRepAlgo_Image.hxx>
0032 #include <NCollection_List.hxx>
0033 #include <BRepOffset_Error.hxx>
0034 #include <BRepOffset_MakeLoops.hxx>
0035 #include <NCollection_Map.hxx>
0036 #include <BRepOffset_Offset.hxx>
0037 #include <NCollection_DataMap.hxx>
0038 #include <NCollection_Array1.hxx>
0039 
0040 #include <Message_ProgressRange.hxx>
0041 class BRepAlgo_AsDes;
0042 class TopoDS_Face;
0043 class BRepOffset_Inter3d;
0044 
0045 class BRepOffset_MakeOffset
0046 {
0047 public:
0048   DEFINE_STANDARD_ALLOC
0049 
0050   Standard_EXPORT BRepOffset_MakeOffset();
0051 
0052   Standard_EXPORT BRepOffset_MakeOffset(
0053     const TopoDS_Shape&          S,
0054     const double                 Offset,
0055     const double                 Tol,
0056     const BRepOffset_Mode        Mode           = BRepOffset_Skin,
0057     const bool                   Intersection   = false,
0058     const bool                   SelfInter      = false,
0059     const GeomAbs_JoinType       Join           = GeomAbs_Arc,
0060     const bool                   Thickening     = false,
0061     const bool                   RemoveIntEdges = false,
0062     const Message_ProgressRange& theRange       = Message_ProgressRange());
0063 
0064   Standard_EXPORT void Initialize(const TopoDS_Shape&    S,
0065                                   const double           Offset,
0066                                   const double           Tol,
0067                                   const BRepOffset_Mode  Mode           = BRepOffset_Skin,
0068                                   const bool             Intersection   = false,
0069                                   const bool             SelfInter      = false,
0070                                   const GeomAbs_JoinType Join           = GeomAbs_Arc,
0071                                   const bool             Thickening     = false,
0072                                   const bool             RemoveIntEdges = false);
0073 
0074   Standard_EXPORT void Clear();
0075 
0076   //! Changes the flag allowing the linearization
0077   Standard_EXPORT void AllowLinearization(const bool theIsAllowed);
0078 
0079   //! Add Closing Faces, <F> has to be in the initial
0080   //! shape S.
0081   Standard_EXPORT void AddFace(const TopoDS_Face& F);
0082 
0083   //! set the offset <Off> on the Face <F>
0084   Standard_EXPORT void SetOffsetOnFace(const TopoDS_Face& F, const double Off);
0085 
0086   Standard_EXPORT void MakeOffsetShape(
0087     const Message_ProgressRange& theRange = Message_ProgressRange());
0088 
0089   Standard_EXPORT void MakeThickSolid(
0090     const Message_ProgressRange& theRange = Message_ProgressRange());
0091 
0092   Standard_EXPORT const BRepOffset_Analyse& GetAnalyse() const;
0093 
0094   Standard_EXPORT bool IsDone() const;
0095 
0096   Standard_EXPORT const TopoDS_Shape& Shape() const;
0097 
0098   const TopoDS_Shape& InitShape() const { return myInitialShape; }
0099 
0100   //! returns information about offset state.
0101   Standard_EXPORT BRepOffset_Error Error() const;
0102 
0103   //! Returns <Image> containing links between initials
0104   //! shapes and offset faces.
0105   Standard_EXPORT const BRepAlgo_Image& OffsetFacesFromShapes() const;
0106 
0107   //! Returns myJoin.
0108   Standard_EXPORT GeomAbs_JoinType GetJoinType() const;
0109 
0110   //! Returns <Image> containing links between initials
0111   //! shapes and offset edges.
0112   Standard_EXPORT const BRepAlgo_Image& OffsetEdgesFromShapes() const;
0113 
0114   //! Returns the list of closing faces stores by AddFace
0115   Standard_EXPORT const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>&
0116                         ClosingFaces() const;
0117 
0118   //! Makes pre analysis of possibility offset perform. Use method Error() to get more information.
0119   //! Finds first error. List of checks:
0120   //! 1) Check for existence object with non-null offset.
0121   //! 2) Check for connectivity in offset shell.
0122   //! 3) Check continuity of input surfaces.
0123   //! 4) Check for normals existence on grid.
0124   //! @return True if possible make computations and false otherwise.
0125   Standard_EXPORT bool CheckInputData(const Message_ProgressRange& theRange);
0126 
0127   //! Return bad shape, which obtained in CheckInputData.
0128   Standard_EXPORT const TopoDS_Shape& GetBadShape() const;
0129 
0130 public: //! @name History methods
0131   //! Returns the list of shapes generated from the shape <S>.
0132   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Generated(const TopoDS_Shape& theS);
0133 
0134   //! Returns the list of shapes modified from the shape <S>.
0135   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Modified(const TopoDS_Shape& theS);
0136 
0137   //! Returns true if the shape S has been deleted.
0138   Standard_EXPORT bool IsDeleted(const TopoDS_Shape& S);
0139 
0140 protected:
0141   //! Analyze progress steps of the whole operation.
0142   //! @param theWhole - sum of progress of all operations.
0143   //! @param theSteps - steps of the operations supported by PI
0144   Standard_EXPORT void analyzeProgress(const double                theWhole,
0145                                        NCollection_Array1<double>& theSteps) const;
0146 
0147 private:
0148   //! Check if shape consists of only planar faces
0149   //! If <myIsLinearizationAllowed> is TRUE, try to approximate images of faces
0150   //! by planar faces
0151   Standard_EXPORT bool IsPlanar();
0152 
0153   //! Set the faces that are to be removed
0154   Standard_EXPORT void SetFaces();
0155 
0156   //! Set the faces with special value of offset
0157   Standard_EXPORT void SetFacesWithOffset();
0158 
0159   Standard_EXPORT void BuildFaceComp();
0160 
0161   Standard_EXPORT void BuildOffsetByArc(const Message_ProgressRange& theRange);
0162 
0163   Standard_EXPORT void BuildOffsetByInter(const Message_ProgressRange& theRange);
0164 
0165   //! Make Offset faces
0166   Standard_EXPORT void MakeOffsetFaces(
0167     NCollection_DataMap<TopoDS_Shape, BRepOffset_Offset, TopTools_ShapeMapHasher>& theMapSF,
0168     const Message_ProgressRange&                                                   theRange);
0169 
0170   Standard_EXPORT void SelfInter(NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& Modif);
0171 
0172   Standard_EXPORT void Intersection3D(BRepOffset_Inter3d&          Inter,
0173                                       const Message_ProgressRange& theRange);
0174 
0175   Standard_EXPORT void Intersection2D(
0176     const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& Modif,
0177     const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& NewEdges,
0178     const Message_ProgressRange&                                         theRange);
0179 
0180   Standard_EXPORT void MakeLoops(
0181     NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& Modif,
0182     const Message_ProgressRange&                                   theRange);
0183 
0184   Standard_EXPORT void MakeLoopsOnContext(
0185     NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& Modif);
0186 
0187   Standard_EXPORT void MakeFaces(
0188     NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& Modif,
0189     const Message_ProgressRange&                                   theRange);
0190 
0191   Standard_EXPORT void MakeShells(const Message_ProgressRange& theRange);
0192 
0193   Standard_EXPORT void SelectShells();
0194 
0195   Standard_EXPORT void EncodeRegularity();
0196 
0197   //! Replace roots in history maps
0198   Standard_EXPORT void ReplaceRoots();
0199 
0200   Standard_EXPORT void MakeSolid(const Message_ProgressRange& theRange);
0201 
0202   Standard_EXPORT void ToContext(
0203     NCollection_DataMap<TopoDS_Shape, BRepOffset_Offset, TopTools_ShapeMapHasher>& MapSF);
0204 
0205   //! Private method use to update the map face<->offset
0206   Standard_EXPORT void UpdateFaceOffset();
0207 
0208   //! Private method used to correct degenerated edges on conical faces
0209   Standard_EXPORT void CorrectConicalFaces();
0210 
0211   //! Private method used to build walls for thickening the shell
0212   Standard_EXPORT void MakeMissingWalls(const Message_ProgressRange& theRange);
0213 
0214   //! Removes INTERNAL edges from the result
0215   Standard_EXPORT void RemoveInternalEdges();
0216 
0217   //! Intersects edges
0218   Standard_EXPORT void IntersectEdges(
0219     const NCollection_List<TopoDS_Shape>&                                          theFaces,
0220     NCollection_DataMap<TopoDS_Shape, BRepOffset_Offset, TopTools_ShapeMapHasher>& theMapSF,
0221     NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>&      theMES,
0222     NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>&      theBuild,
0223     occ::handle<BRepAlgo_AsDes>&                                                   theAsDes,
0224     occ::handle<BRepAlgo_AsDes>&                                                   theAsDes2d,
0225     const Message_ProgressRange&                                                   theRange);
0226 
0227   //! Building of the splits of the offset faces for mode Complete
0228   //! and joint type Intersection. This method is an advanced alternative
0229   //! for BRepOffset_MakeLoops::Build method.
0230   //! Currently the Complete intersection mode is limited to work only on planar cases.
0231   Standard_EXPORT void BuildSplitsOfExtendedFaces(
0232     const NCollection_List<TopoDS_Shape>& theLF,
0233     const BRepOffset_Analyse&             theAnalyse,
0234     const occ::handle<BRepAlgo_AsDes>&    theAsDes,
0235     NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>&
0236                                                                               theEdgesOrigins,
0237     NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>& theFacesOrigins,
0238     NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>& theETrimEInf,
0239     BRepAlgo_Image&                                                           theImage,
0240     const Message_ProgressRange&                                              theRange);
0241 
0242   //! Building of the splits of the already trimmed offset faces for mode Complete
0243   //! and joint type Intersection.
0244   Standard_EXPORT void BuildSplitsOfTrimmedFaces(const NCollection_List<TopoDS_Shape>& theLF,
0245                                                  const occ::handle<BRepAlgo_AsDes>&    theAsDes,
0246                                                  BRepAlgo_Image&                       theImage,
0247                                                  const Message_ProgressRange&          theRange);
0248 
0249   double                                                             myOffset;
0250   double                                                             myTol;
0251   TopoDS_Shape                                                       myInitialShape;
0252   TopoDS_Shape                                                       myShape;
0253   TopoDS_Compound                                                    myFaceComp;
0254   BRepOffset_Mode                                                    myMode;
0255   bool                                                               myIsLinearizationAllowed;
0256   bool                                                               myInter;
0257   bool                                                               mySelfInter;
0258   GeomAbs_JoinType                                                   myJoin;
0259   bool                                                               myThickening;
0260   bool                                                               myRemoveIntEdges;
0261   NCollection_DataMap<TopoDS_Shape, double, TopTools_ShapeMapHasher> myFaceOffset;
0262   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>      myFaces;
0263   NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>      myOriginalFaces;
0264   BRepOffset_Analyse                                                 myAnalyse;
0265   TopoDS_Shape                                                       myOffsetShape;
0266   BRepAlgo_Image                                                     myInitOffsetFace;
0267   BRepAlgo_Image                                                     myInitOffsetEdge;
0268   BRepAlgo_Image                                                     myImageOffset;
0269   BRepAlgo_Image                                                     myImageVV;
0270   NCollection_List<TopoDS_Shape>                                     myWalls;
0271   occ::handle<BRepAlgo_AsDes>                                        myAsDes;
0272   NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher>
0273                        myEdgeIntEdges;
0274   bool                 myDone;
0275   BRepOffset_Error     myError;
0276   BRepOffset_MakeLoops myMakeLoops;
0277   bool                 myIsPerformSewing; // Handle bad walls in thicksolid mode.
0278   bool                 myIsPlanar;
0279   TopoDS_Shape         myBadShape;
0280   NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher> myFacePlanfaceMap;
0281   NCollection_List<TopoDS_Shape>                                           myGenerated;
0282   NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>                   myResMap;
0283 };
0284 
0285 #endif // _BRepOffset_MakeOffset_HeaderFile