Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0044 class BRepOffset_MakeOffset 
0045 {
0046 public:
0047 
0048   DEFINE_STANDARD_ALLOC
0049 
0050   Standard_EXPORT BRepOffset_MakeOffset();
0051   
0052   Standard_EXPORT BRepOffset_MakeOffset(const TopoDS_Shape& S,
0053                                         const Standard_Real Offset,
0054                                         const Standard_Real Tol,
0055                                         const BRepOffset_Mode Mode = BRepOffset_Skin,
0056                                         const Standard_Boolean Intersection = Standard_False,
0057                                         const Standard_Boolean SelfInter = Standard_False,
0058                                         const GeomAbs_JoinType Join = GeomAbs_Arc,
0059                                         const Standard_Boolean Thickening = Standard_False,
0060                                         const Standard_Boolean RemoveIntEdges = Standard_False,
0061                                         const Message_ProgressRange& theRange = Message_ProgressRange());
0062   
0063   Standard_EXPORT void Initialize (const TopoDS_Shape& S,
0064                                    const Standard_Real Offset,
0065                                    const Standard_Real Tol,
0066                                    const BRepOffset_Mode Mode = BRepOffset_Skin,
0067                                    const Standard_Boolean Intersection = Standard_False,
0068                                    const Standard_Boolean SelfInter = Standard_False,
0069                                    const GeomAbs_JoinType Join = GeomAbs_Arc,
0070                                    const Standard_Boolean Thickening = Standard_False,
0071                                    const Standard_Boolean RemoveIntEdges = Standard_False);
0072   
0073   Standard_EXPORT void Clear();
0074   
0075   //! Changes the flag allowing the linearization
0076   Standard_EXPORT void AllowLinearization (const Standard_Boolean theIsAllowed);
0077   
0078   //! Add Closing Faces,  <F>  has to be  in  the initial
0079   //! shape S.
0080   Standard_EXPORT void AddFace (const TopoDS_Face& F);
0081   
0082   //! set the offset <Off> on the Face <F>
0083   Standard_EXPORT void SetOffsetOnFace (const TopoDS_Face& F, const Standard_Real Off);
0084   
0085   Standard_EXPORT void MakeOffsetShape(const Message_ProgressRange& theRange = Message_ProgressRange());
0086   
0087   Standard_EXPORT void MakeThickSolid(const Message_ProgressRange& theRange = Message_ProgressRange());
0088   
0089   Standard_EXPORT const BRepOffset_Analyse& GetAnalyse() const;
0090   
0091   Standard_EXPORT Standard_Boolean IsDone() const;
0092   
0093   Standard_EXPORT const TopoDS_Shape& Shape() const;
0094   
0095   const TopoDS_Shape& InitShape() const
0096   {
0097     return myInitialShape;
0098   }
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 TopTools_IndexedMapOfShape& ClosingFaces() const;
0116 
0117   //! Makes pre analysis of possibility offset perform. Use method Error() to get more information.
0118   //! Finds first error. List of checks:
0119   //! 1) Check for existence object with non-null offset.
0120   //! 2) Check for connectivity in offset shell.
0121   //! 3) Check continuity of input surfaces.
0122   //! 4) Check for normals existence on grid.
0123   //! @return True if possible make computations and false otherwise.
0124   Standard_EXPORT Standard_Boolean CheckInputData(const Message_ProgressRange& theRange);
0125 
0126   //! Return bad shape, which obtained in CheckInputData.
0127   Standard_EXPORT const TopoDS_Shape& GetBadShape() const;
0128 
0129 public: //! @name History methods
0130 
0131   //! Returns the  list of shapes generated from the shape <S>.
0132   Standard_EXPORT const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS);
0133   
0134   //! Returns the list of shapes modified from the shape <S>.
0135   Standard_EXPORT const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS);
0136   
0137   //! Returns true if the shape S has been deleted.
0138   Standard_EXPORT Standard_Boolean IsDeleted (const TopoDS_Shape& S);
0139 
0140 
0141 protected:
0142   //! Analyze progress steps of the whole operation.
0143   //! @param theWhole - sum of progress of all operations.
0144   //! @oaram theSteps - steps of the operations supported by PI
0145   Standard_EXPORT void analyzeProgress (const Standard_Real theWhole,
0146                                         TColStd_Array1OfReal& theSteps) const;
0147 
0148 private:
0149 
0150   //! Check if shape consists of only planar faces
0151   //! If <myIsLinearizationAllowed> is TRUE, try to approximate images of faces
0152   //! by planar faces
0153   Standard_EXPORT Standard_Boolean IsPlanar();
0154   
0155   //! Set the faces that are to be removed
0156   Standard_EXPORT void SetFaces();
0157   
0158   //! Set the faces with special value of offset
0159   Standard_EXPORT void SetFacesWithOffset();
0160   
0161   Standard_EXPORT void BuildFaceComp();
0162   
0163   Standard_EXPORT void BuildOffsetByArc(const Message_ProgressRange& theRange);
0164   
0165   Standard_EXPORT void BuildOffsetByInter(const Message_ProgressRange& theRange);
0166 
0167   //! Make Offset faces
0168   Standard_EXPORT void MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& theMapSF, const Message_ProgressRange& theRange);
0169 
0170   Standard_EXPORT void SelfInter (TopTools_MapOfShape& Modif);
0171   
0172   Standard_EXPORT void Intersection3D (BRepOffset_Inter3d& Inter, const Message_ProgressRange& theRange);
0173   
0174   Standard_EXPORT void Intersection2D (const TopTools_IndexedMapOfShape& Modif, 
0175                                        const TopTools_IndexedMapOfShape& NewEdges, 
0176                                        const Message_ProgressRange& theRange);
0177   
0178   Standard_EXPORT void MakeLoops (TopTools_IndexedMapOfShape& Modif, const Message_ProgressRange& theRange);
0179   
0180   Standard_EXPORT void MakeLoopsOnContext (TopTools_MapOfShape& Modif);
0181   
0182   Standard_EXPORT void MakeFaces (TopTools_IndexedMapOfShape& Modif, const Message_ProgressRange& theRange);
0183   
0184   Standard_EXPORT void MakeShells(const Message_ProgressRange& theRange);
0185   
0186   Standard_EXPORT void SelectShells();
0187   
0188   Standard_EXPORT void EncodeRegularity();
0189   
0190   //! Replace roots in history maps
0191   Standard_EXPORT void ReplaceRoots();
0192 
0193   Standard_EXPORT void MakeSolid(const Message_ProgressRange& theRange);
0194   
0195   Standard_EXPORT void ToContext (BRepOffset_DataMapOfShapeOffset& MapSF);
0196   
0197   //! Private method use to update the map face<->offset
0198   Standard_EXPORT void UpdateFaceOffset();
0199   
0200   //! Private method used to correct degenerated edges on conical faces
0201   Standard_EXPORT void CorrectConicalFaces();
0202   
0203   //! Private method used to build walls for thickening the shell
0204   Standard_EXPORT void MakeMissingWalls(const Message_ProgressRange& theRange);
0205 
0206   //! Removes INTERNAL edges from the result
0207   Standard_EXPORT void RemoveInternalEdges();
0208 
0209   //! Intersects edges
0210   Standard_EXPORT void IntersectEdges (const TopTools_ListOfShape& theFaces,
0211                                        BRepOffset_DataMapOfShapeOffset& theMapSF,
0212                                        TopTools_DataMapOfShapeShape& theMES,
0213                                        TopTools_DataMapOfShapeShape& theBuild,
0214                                        Handle(BRepAlgo_AsDes)& theAsDes,
0215                                        Handle(BRepAlgo_AsDes)& theAsDes2d,
0216                                        const Message_ProgressRange& theRange);
0217 
0218   //! Building of the splits of the offset faces for mode Complete
0219   //! and joint type Intersection. This method is an advanced alternative
0220   //! for BRepOffset_MakeLoops::Build method.
0221   //! Currently the Complete intersection mode is limited to work only on planar cases.
0222   Standard_EXPORT void BuildSplitsOfExtendedFaces(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