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