Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2016-10-13
0002 // Created by: Alexander MALYSHEV
0003 // Copyright (c) 1999-2016 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 _BRepOffset_MakeSimpleOffset_HeaderFile
0017 #define _BRepOffset_MakeSimpleOffset_HeaderFile
0018 
0019 #include <BRepTools_Modifier.hxx>
0020 #include <ShapeBuild_ReShape.hxx>
0021 #include <NCollection_DataMap.hxx>
0022 #include <Standard_Macro.hxx>
0023 #include <Standard_Real.hxx>
0024 #include <TCollection_AsciiString.hxx>
0025 #include <TopoDS_Edge.hxx>
0026 #include <TopoDS_Face.hxx>
0027 #include <TopoDS_Vertex.hxx>
0028 #include <TopoDS_Shape.hxx>
0029 
0030 
0031 enum BRepOffsetSimple_Status
0032 {
0033   BRepOffsetSimple_OK,
0034   BRepOffsetSimple_NullInputShape,
0035   BRepOffsetSimple_ErrorOffsetComputation,
0036   BRepOffsetSimple_ErrorWallFaceComputation,
0037   BRepOffsetSimple_ErrorInvalidNbShells,
0038   BRepOffsetSimple_ErrorNonClosedShell
0039 };
0040 
0041 //! This class represents simple offset algorithm itself. It builds simple offset without intersection.
0042 //! Solid can be created using SetBuildSolidFlag method (set flag to true). By default shell will be constructed.
0043 //!
0044 //! Algorithm:
0045 //! 1. Build source-image maps for vertices, edges and faces.BRepTools_Modification class will be used
0046 //!    to store this information. An image of a shared edge can be constructed from the corresponding edge
0047 //!    of the first iterated face.
0048 //! 2. Run BRepTools_Modifier to obtain offset shape.
0049 //  3. Ensure topological integrity of the output shape.
0050 //!
0051 //! Limitations:
0052 //! According to the algorithm nature result depends on the smoothness of input data. Smooth (G1-continuity) input shape
0053 //! will lead to the good result.
0054 //!
0055 //! The possible drawback of the simple algorithm is that it leads, in general case, to tolerance increasing.
0056 //! The tolerances have to grow in order to cover the gaps between the neighbor faces in the output.
0057 //! It should be noted that the actual tolerance growth depends on the offset distance and the quality of 
0058 //! joints between the input faces. Anyway the good input shell (smooth connections between adjacent faces)
0059 //! will lead to good result.
0060 class BRepOffset_MakeSimpleOffset
0061 {
0062 public:
0063 
0064 
0065   //! Constructor. Does nothing.
0066   Standard_EXPORT BRepOffset_MakeSimpleOffset();
0067 
0068   //! Constructor.
0069   Standard_EXPORT BRepOffset_MakeSimpleOffset(const TopoDS_Shape& theInputShape,
0070                                               const Standard_Real theOffsetValue);
0071 
0072   //! Initialies shape for modifications.
0073   Standard_EXPORT void Initialize(const TopoDS_Shape& theInputShape,
0074                                   const Standard_Real theOffsetValue);
0075 
0076   //! Computes offset shape.
0077   Standard_EXPORT void Perform();
0078 
0079   //! Gets error message.
0080   Standard_EXPORT TCollection_AsciiString GetErrorMessage() const;
0081 
0082   //! Gets error code.
0083   BRepOffsetSimple_Status GetError() const { return myError; }
0084 
0085   // Inline methods.
0086   //! Gets solid building flag.
0087   Standard_Boolean GetBuildSolidFlag() const { return myIsBuildSolid; }
0088 
0089   //! Sets solid building flag.
0090   void SetBuildSolidFlag(const Standard_Boolean theBuildFlag) { myIsBuildSolid = theBuildFlag; }
0091 
0092   //! Gets offset value.
0093   Standard_Real GetOffsetValue() const { return myOffsetValue; }
0094 
0095   //! Sets offset value.
0096   void SetOffsetValue(const Standard_Real theOffsetValue) { myOffsetValue = theOffsetValue; }
0097 
0098   //! Gets tolerance (used for handling singularities).
0099   Standard_Real GetTolerance() const { return myTolerance; }
0100 
0101   //! Sets tolerance (used for handling singularities).
0102   void SetTolerance (const Standard_Real theValue) { myTolerance = theValue; }
0103 
0104   //! Gets done state.
0105   Standard_Boolean IsDone() const { return myIsDone; } 
0106 
0107   //! Returns result shape.
0108   const TopoDS_Shape& GetResultShape() const { return myResShape; }
0109 
0110   //! Computes max safe offset value for the given tolerance.
0111   Standard_Real GetSafeOffset(const Standard_Real theExpectedToler);
0112 
0113   //! Returns result shape for the given one (if exists).
0114   Standard_EXPORT const TopoDS_Shape Generated(const TopoDS_Shape& theShape) const;
0115 
0116   //! Returns modified shape for the given one (if exists).
0117   Standard_EXPORT const TopoDS_Shape Modified(const TopoDS_Shape& theShape) const;
0118 
0119 protected:
0120 
0121   //! Computes max angle in faces junction.
0122   void ComputeMaxAngle();
0123 
0124   //! Clears previous result.
0125   void Clear();
0126 
0127 private:
0128 
0129   //! Builds face on specified wall.
0130   TopoDS_Face BuildWallFace(const TopoDS_Edge& theOrigEdge);
0131 
0132   //! Builds missing walls.
0133   Standard_Boolean BuildMissingWalls();
0134 
0135   // Input data.
0136 
0137   //! Input shape.
0138   TopoDS_Shape myInputShape;
0139 
0140   //! Offset value.
0141   Standard_Real myOffsetValue;
0142 
0143   //! Tolerance (for singularities)
0144   Standard_Real myTolerance;
0145 
0146   //! Solid building flag. True means solid construction.
0147   Standard_Boolean myIsBuildSolid;
0148 
0149   // Internal data.
0150 
0151   //! Maximal angle in faces junction. This value helps to estimate result tolerance.
0152   Standard_Real myMaxAngle;
0153 
0154   //! Error message.
0155   BRepOffsetSimple_Status myError;
0156 
0157   //! Done state.
0158   Standard_Boolean myIsDone;
0159 
0160   //! Map of vertex - wall edge.
0161   //! Used to build shared edge between adjacent wall faces.
0162   NCollection_DataMap<TopoDS_Vertex, TopoDS_Edge> myMapVE;
0163 
0164   //! Used for histrory support.
0165   BRepTools_Modifier myBuilder;
0166 
0167   //! Used for history support.
0168   Handle(ShapeBuild_ReShape) myReShape;
0169 
0170   // Output data.
0171 
0172   //! Result shape.
0173   TopoDS_Shape myResShape;
0174 
0175 };
0176 
0177 #endif // _BRepOffset_MakeSimpleOffset_HeaderFile