|
||||
File indexing completed on 2025-01-18 10:03:04
0001 // Created by: Eugeny MALTCHIKOV 0002 // Copyright (c) 2018 OPEN CASCADE SAS 0003 // 0004 // This file is part of Open CASCADE Technology software library. 0005 // 0006 // This library is free software; you can redistribute it and/or modify it under 0007 // the terms of the GNU Lesser General Public License version 2.1 as published 0008 // by the Free Software Foundation, with special exception defined in the file 0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0010 // distribution for complete text of the license and disclaimer of any warranty. 0011 // 0012 // Alternatively, this file may be used under the terms of Open CASCADE 0013 // commercial license or contractual agreement. 0014 0015 #ifndef _BOPAlgo_RemoveFeatures_HeaderFile 0016 #define _BOPAlgo_RemoveFeatures_HeaderFile 0017 0018 #include <Standard.hxx> 0019 #include <Standard_DefineAlloc.hxx> 0020 #include <Standard_Handle.hxx> 0021 0022 #include <BOPAlgo_BuilderShape.hxx> 0023 #include <BRepTools_History.hxx> 0024 #include <TopoDS_Shape.hxx> 0025 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> 0026 #include <TopTools_IndexedMapOfShape.hxx> 0027 #include <TopTools_ListOfShape.hxx> 0028 #include <TopTools_MapOfShape.hxx> 0029 0030 //! The RemoveFeatures algorithm is intended for reconstruction of 0031 //! the shape by removal of the unwanted parts from it. These parts can 0032 //! be holes, protrusions, spikes, fillets etc. 0033 //! The shape itself is not modified, the new shape is built in 0034 //! the result. 0035 //! 0036 //! Currently, only the shapes of type SOLID, COMPSOLID, and 0037 //! COMPOUND of Solids are supported. And only the FACEs can be 0038 //! removed from the shape. 0039 //! 0040 //! On the input the algorithm accepts the shape itself and the 0041 //! faces which have to be removed. It does not matter how the faces 0042 //! are given. It could be the separate faces or the collections of faces. 0043 //! The faces should belong to the initial shape, and those that 0044 //! do not belong will be ignored. 0045 //! Before reconstructing the shape, the algorithm will sort all 0046 //! the given faces on the connected blocks (features). 0047 //! 0048 //! The features will be removed from the shape one by one. 0049 //! It will allow removing all possible features even if there 0050 //! were problems with the removal of some of them. 0051 //! 0052 //! The removed feature is filled by the extension of the faces adjacent 0053 //! to the feature. In general, the algorithm of removing of the single 0054 //! feature from the shape looks as follows: 0055 //! - Find the faces adjacent to the feature; 0056 //! - Extend the adjacent faces to cover the feature; 0057 //! - Trim the extended faces by the bounds of original face 0058 //! (except for bounds common with the feature), so it will cover 0059 //! the feature only; 0060 //! - Rebuild the solids with reconstructed adjacent faces 0061 //! avoiding the faces from the feature. 0062 //! 0063 //! If the removal is successful, the result is overwritten with the 0064 //! new shape and the next feature is treated. Otherwise, the warning 0065 //! will be given. 0066 //! 0067 //! The algorithm has the following options: 0068 //! - History support; 0069 //! 0070 //! and the options available from base class: 0071 //! - Error/Warning reporting system; 0072 //! - Parallel processing mode. 0073 //! 0074 //! Please note that the other options of the base class are not supported 0075 //! here and will have no effect. 0076 //! 0077 //! <b>History support</b> allows tracking modification of the input shape 0078 //! in terms of Modified, IsDeleted and Generated. The history is 0079 //! available through the methods of the history tool *BRepTools_History*, 0080 //! which can be accessed here through the method *History()*. 0081 //! By default, the history is collected, but it is possible to disable it 0082 //! using the method *SetToFillHistory(false)*; 0083 //! 0084 //! <b>Error/Warning reporting system</b> - allows obtaining the extended overview 0085 //! of the Errors/Warnings occurred during the operation. As soon as any error 0086 //! appears the algorithm stops working. The warnings allow continuing the job, 0087 //! informing the user that something went wrong. 0088 //! The algorithm returns the following errors/warnings: 0089 //! - *BOPAlgo_AlertTooFewArguments* - the error alert is given if the input 0090 //! shape does not contain any solids; 0091 //! - *BOPAlgo_AlertUnsupportedType* - the warning alert is given if the input 0092 //! shape contains not only solids, but also other shapes; 0093 //! - *BOPAlgo_AlertNoFacesToRemove* - the error alert is given in case 0094 //! there are no faces to remove from the shape (nothing to do); 0095 //! - *BOPAlgo_AlertUnableToRemoveTheFeature* - the warning alert is given to 0096 //! inform the user the removal of the feature is not possible. The algorithm 0097 //! will still try to remove the other features; 0098 //! - *BOPAlgo_AlertRemoveFeaturesFailed* - the error alert is given in case if 0099 //! the operation was aborted by the unknown reason. 0100 //! 0101 //! <b>Parallel processing mode</b> - allows running the algorithm in parallel mode 0102 //! obtaining the result faster. 0103 //! 0104 //! The algorithm has certain limitations: 0105 //! - Intersection of the connected faces adjacent to the feature should not be empty. 0106 //! It means, that such faces should not be tangent to each other. 0107 //! If the intersection of the adjacent faces will be empty, the algorithm will 0108 //! be unable to trim the faces correctly and, most likely, the feature will not be removed. 0109 //! - The algorithm does not process the INTERNAL parts of the solids, they are simply 0110 //! removed during reconstruction. 0111 //! 0112 //! Note that for successful removal of the feature, the extended faces adjacent 0113 //! to the feature should cover the feature completely, otherwise the solids will 0114 //! not be rebuild. 0115 //! 0116 //! Here is the example of usage of the algorithm: 0117 //! ~~~~ 0118 //! TopoDS_Shape aSolid = ...; // Input shape to remove the features from 0119 //! TopTools_ListOfShape aFaces = ...; // Faces to remove from the shape 0120 //! Standard_Boolean bRunParallel = ...; // Parallel processing mode 0121 //! Standard_Boolean isHistoryNeeded = ...; // History support 0122 //! 0123 //! BOPAlgo_RemoveFeatures aRF; // Feature removal algorithm 0124 //! aRF.SetShape(aSolid); // Set the shape 0125 //! aRF.AddFacesToRemove(aFaces); // Add faces to remove 0126 //! aRF.SetRunParallel(bRunParallel); // Define the processing mode (parallel or single) 0127 //! aRF.SetToFillHistory(isHistoryNeeded); // Define whether to track the shapes modifications 0128 //! aRF.Perform(); // Perform the operation 0129 //! if (aRF.HasErrors()) // Check for the errors 0130 //! { 0131 //! // error treatment 0132 //! return; 0133 //! } 0134 //! if (aRF.HasWarnings()) // Check for the warnings 0135 //! { 0136 //! // warnings treatment 0137 //! } 0138 //! const TopoDS_Shape& aResult = aRF.Shape(); // Result shape 0139 //! ~~~~ 0140 //! 0141 //! The algorithm preserves the type of the input shape in the result shape. Thus, 0142 //! if the input shape is a COMPSOLID, the resulting solids will also be put into a COMPSOLID. 0143 //! 0144 //! When all possible features are removed, the shape is simplified by 0145 //! removing extra edges and vertices, created during operation, from the result shape. 0146 //! 0147 class BOPAlgo_RemoveFeatures: public BOPAlgo_BuilderShape 0148 { 0149 public: 0150 DEFINE_STANDARD_ALLOC 0151 0152 public: //! @name Constructors 0153 0154 //! Empty constructor 0155 BOPAlgo_RemoveFeatures() 0156 : 0157 BOPAlgo_BuilderShape() 0158 {} 0159 0160 0161 public: //! @name Setting input data for the algorithm 0162 0163 //! Sets the shape for processing. 0164 //! @param theShape [in] The shape to remove the faces from. 0165 //! It should either be the SOLID, COMPSOLID or COMPOUND of Solids. 0166 void SetShape(const TopoDS_Shape& theShape) 0167 { 0168 myInputShape = theShape; 0169 } 0170 0171 //! Returns the input shape 0172 const TopoDS_Shape& InputShape() const 0173 { 0174 return myInputShape; 0175 } 0176 0177 //! Adds the face to remove from the input shape. 0178 //! @param theFace [in] The shape to extract the faces for removal. 0179 void AddFaceToRemove(const TopoDS_Shape& theFace) 0180 { 0181 myFacesToRemove.Append(theFace); 0182 } 0183 0184 //! Adds the faces to remove from the input shape. 0185 //! @param theFaces [in] The list of shapes to extract the faces for removal. 0186 void AddFacesToRemove(const TopTools_ListOfShape& theFaces) 0187 { 0188 TopTools_ListIteratorOfListOfShape it(theFaces); 0189 for (; it.More(); it.Next()) 0190 myFacesToRemove.Append(it.Value()); 0191 } 0192 0193 //! Returns the list of faces which have been requested for removal 0194 //! from the input shape. 0195 const TopTools_ListOfShape& FacesToRemove() const 0196 { 0197 return myFacesToRemove; 0198 } 0199 0200 0201 public: //! @name Performing the operation 0202 0203 //! Performs the operation 0204 Standard_EXPORT virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE; 0205 0206 0207 public: //! @name Clearing the contents of the algorithm 0208 0209 //! Clears the contents of the algorithm from previous run, 0210 //! allowing reusing it for following removals. 0211 virtual void Clear() Standard_OVERRIDE 0212 { 0213 BOPAlgo_BuilderShape::Clear(); 0214 myInputShape.Nullify(); 0215 myShape.Nullify(); 0216 myFacesToRemove.Clear(); 0217 myFeatures.Clear(); 0218 myInputsMap.Clear(); 0219 } 0220 0221 0222 protected: //! @name Protected methods performing the removal 0223 0224 //! Checks the input data on validity for the algorithm: 0225 //! - The input shape must be either a SOLID, COMPSOLID or COMPOUND of Solids. 0226 //! If the input shape is not a solid, the method looks for the solids 0227 //! in <myInputShape> and uses only them. All other shapes are simply removed. 0228 //! If no solids were found, the Error of unsupported type is returned. 0229 Standard_EXPORT virtual void CheckData() Standard_OVERRIDE; 0230 0231 //! Prepares the faces to remove: 0232 //! - Gets only faces contained in the input solids; 0233 //! - Builds connected blocks of faces creating separate features to remove. 0234 Standard_EXPORT void PrepareFeatures(const Message_ProgressRange& theRange); 0235 0236 //! Removes the features and fills the created gaps by extension of the adjacent faces. 0237 //! Processes each feature separately. 0238 Standard_EXPORT void RemoveFeatures(const Message_ProgressRange& theRange); 0239 0240 //! Remove the single feature from the shape. 0241 //! @param theFeature [in] The feature to remove; 0242 //! @param theSolids [in] The solids to be reconstructed after feature removal; 0243 //! @param theFeatureFacesMap [in] The map of feature faces; 0244 //! @param theHasAdjacentFaces [in] Shows whether the adjacent faces have been 0245 //! found for the feature or not; 0246 //! @param theAdjFaces [in] The reconstructed adjacent faces covering the feature; 0247 //! @param theAdjFacesHistory [in] The history of the adjacent faces reconstruction; 0248 //! @param theSolidsHistoryNeeded [in] Defines whether the history of solids 0249 //! modifications should be tracked or not. 0250 Standard_EXPORT void RemoveFeature(const TopoDS_Shape& theFeature, 0251 const TopTools_IndexedMapOfShape& theSolids, 0252 const TopTools_MapOfShape& theFeatureFacesMap, 0253 const Standard_Boolean theHasAdjacentFaces, 0254 const TopTools_IndexedDataMapOfShapeListOfShape& theAdjFaces, 0255 const Handle(BRepTools_History)& theAdjFacesHistory, 0256 const Standard_Boolean theSolidsHistoryNeeded, 0257 const Message_ProgressRange& theRange); 0258 0259 //! Updates history with the removed features 0260 Standard_EXPORT void UpdateHistory(const Message_ProgressRange& theRange); 0261 0262 //! Simplifies the result by removing extra edges and vertices created 0263 //! during removal of the features. 0264 Standard_EXPORT void SimplifyResult(const Message_ProgressRange& theRange); 0265 0266 //! Post treatment - restore the type of the initial shape 0267 Standard_EXPORT void PostTreat(); 0268 0269 //! Filling steps for constant operations 0270 Standard_EXPORT void fillPIConstants(const Standard_Real theWhole, BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE; 0271 0272 protected: //! @name Fields 0273 0274 // Inputs 0275 TopoDS_Shape myInputShape; //!< Input shape 0276 TopTools_ListOfShape myFacesToRemove; //!< Faces to remove 0277 0278 // Intermediate 0279 TopTools_ListOfShape myFeatures; //!< List of not connected features to remove 0280 //! (each feature is a compound of faces) 0281 TopTools_IndexedMapOfShape myInputsMap; //!< Map of all sub-shapes of the input shape 0282 }; 0283 0284 #endif // _BOPAlgo_RemoveFeatures_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |