Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-15 08:23:53

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