OCCT3D OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    BOPAlgo_RemoveFeatures Class Reference

    The RemoveFeatures algorithm is intended for reconstruction of the shape by removal of the unwanted parts from it. These parts can be holes, protrusions, spikes, fillets etc. The shape itself is not modified, the new shape is built in the result. More...

    #include <BOPAlgo_RemoveFeatures.hxx>

    Inheritance diagram for BOPAlgo_RemoveFeatures:

    Public Member Functions

    Constructors

    Empty constructor

     BOPAlgo_RemoveFeatures ()=default
    Setting input data for the algorithm

    Sets the shape for processing.

    Parameters
    [in]theShapeThe shape to remove the faces from. It should either be the SOLID, COMPSOLID or COMPOUND of Solids.
    void SetShape (const TopoDS_Shape &theShape)
     Returns the input shape.
    const TopoDS_ShapeInputShape () const
     Returns the input shape.
    void AddFaceToRemove (const TopoDS_Shape &theFace)
     Adds the face to remove from the input shape.
    void AddFacesToRemove (const NCollection_List< TopoDS_Shape > &theFaces)
     Adds the faces to remove from the input shape.
    const NCollection_List< TopoDS_Shape > & FacesToRemove () const
     Returns the list of faces which have been requested for removal from the input shape.
    Performing the operation

    Performs the operation

    void Perform (const Message_ProgressRange &theRange=Message_ProgressRange()) override
     The main method to implement the operation Providing the range allows to enable Progress indicator User break functionalities.
    Clearing the contents of the algorithm

    Clears the contents of the algorithm from previous run, allowing reusing it for following removals.

    void Clear () override
     Clears all warnings and errors, and any data cached by the algorithm. User defined options are not cleared.
    Public Member Functions inherited from BOPAlgo_BuilderShape
    const TopoDS_ShapeShape () const
    const NCollection_List< TopoDS_Shape > & Modified (const TopoDS_Shape &theS)
     Returns the list of shapes Generated from the shape theS.
    const NCollection_List< TopoDS_Shape > & Generated (const TopoDS_Shape &theS)
     Returns the list of shapes Generated from the shape theS.
    bool IsDeleted (const TopoDS_Shape &theS)
     Returns true if the shape theS has been deleted. In this case the shape will have no Modified elements, but can have Generated elements.
    bool HasModified () const
     Returns true if any of the input shapes has been modified during operation.
    bool HasGenerated () const
     Returns true if any of the input shapes has generated shapes during operation.
    bool HasDeleted () const
     Returns true if any of the input shapes has been deleted during operation.
    occ::handle< BRepTools_HistoryHistory ()
     History Tool.
    void SetToFillHistory (const bool theHistFlag)
     Returns flag of history availability.
    bool HasHistory () const
     Returns flag of history availability.
    Public Member Functions inherited from BOPAlgo_Options
     BOPAlgo_Options ()
     Empty constructor.
     BOPAlgo_Options (const occ::handle< NCollection_BaseAllocator > &theAllocator)
     Constructor with allocator.
    virtual ~BOPAlgo_Options ()
     Destructor.
    const occ::handle< NCollection_BaseAllocator > & Allocator () const
     Returns allocator.
    void AddError (const occ::handle< Message_Alert > &theAlert)
     Adds the alert as error (fail).
    void AddWarning (const occ::handle< Message_Alert > &theAlert)
     Adds the alert as warning.
    bool HasErrors () const
     Returns true if algorithm has failed.
    bool HasError (const occ::handle< Standard_Type > &theType) const
     Returns true if algorithm has generated error of specified type.
    bool HasWarnings () const
     Returns true if algorithm has generated some warning alerts.
    bool HasWarning (const occ::handle< Standard_Type > &theType) const
     Returns true if algorithm has generated warning of specified type.
    const occ::handle< Message_Report > & GetReport () const
     Returns report collecting all errors and warnings.
    void DumpErrors (Standard_OStream &theOS) const
     Dumps the error status into the given stream.
    void DumpWarnings (Standard_OStream &theOS) const
     Dumps the warning statuses into the given stream.
    void ClearWarnings ()
     Clears the warnings of the algorithm.
    void SetFuzzyValue (const double theFuzz)
     Sets the additional tolerance.
    double FuzzyValue () const
     Returns the additional tolerance.
    void SetUseOBB (const bool theUseOBB)
     Enables/Disables the usage of OBB.
    bool UseOBB () const
     Returns the flag defining usage of OBB.
    void SetRunParallel (const bool theFlag)
     Set the flag of parallel processing if <theFlag> is true the parallel processing is switched on if <theFlag> is false the parallel processing is switched off.
    bool RunParallel () const
     Returns the flag of parallel processing.

    Protected Member Functions

    Protected methods performing the removal

    Checks the input data on validity for the algorithm:

    • The input shape must be either a SOLID, COMPSOLID or COMPOUND of Solids. If the input shape is not a solid, the method looks for the solids in <myInputShape> and uses only them. All other shapes are simply removed. If no solids were found, the Error of unsupported type is returned.
    void CheckData () override
     Prepares the faces to remove:
    void PrepareFeatures (const Message_ProgressRange &theRange)
     Prepares the faces to remove:
    void RemoveFeatures (const Message_ProgressRange &theRange)
     Removes the features and fills the created gaps by extension of the adjacent faces. Processes each feature separately.
    void RemoveFeature (const TopoDS_Shape &theFeature, const NCollection_IndexedMap< TopoDS_Shape, TopTools_ShapeMapHasher > &theSolids, const NCollection_Map< TopoDS_Shape, TopTools_ShapeMapHasher > &theFeatureFacesMap, const bool theHasAdjacentFaces, const NCollection_IndexedDataMap< TopoDS_Shape, NCollection_List< TopoDS_Shape >, TopTools_ShapeMapHasher > &theAdjFaces, const occ::handle< BRepTools_History > &theAdjFacesHistory, const bool theSolidsHistoryNeeded, const Message_ProgressRange &theRange)
     Remove the single feature from the shape.
    void UpdateHistory (const Message_ProgressRange &theRange)
     Updates history with the removed features.
    void SimplifyResult (const Message_ProgressRange &theRange)
     Simplifies the result by removing extra edges and vertices created during removal of the features.
    void PostTreat ()
     Post treatment - restore the type of the initial shape.
    void fillPIConstants (const double theWhole, BOPAlgo_PISteps &theSteps) const override
     Filling steps for constant operations.
    Protected Member Functions inherited from BOPAlgo_BuilderShape
     BOPAlgo_BuilderShape ()
     Constructor with allocator.
     BOPAlgo_BuilderShape (const occ::handle< NCollection_BaseAllocator > &theAllocator)
     Constructor with allocator.
    Protected Member Functions inherited from BOPAlgo_Algo
     BOPAlgo_Algo ()
     Default constructor.
     ~BOPAlgo_Algo () override
     BOPAlgo_Algo (const occ::handle< NCollection_BaseAllocator > &theAllocator)
    virtual void CheckResult ()
     Checks the obtained result.
    void analyzeProgress (const double theWhole, BOPAlgo_PISteps &theSteps) const
     Fills the values for constant operations - the operations having constant relative running time.
    virtual void fillPISteps (BOPAlgo_PISteps &theSteps) const
     Fills the values for the operations dependent on the inputs. Filled values may not be normalized to represent percentage of total running time. The values should just correlate to each other. E.g. if progress depends on the number of input shapes, the values may look like this: step1 = number_of_input_vertices; step2 = 2 * number_of_input_edges; step3 = 10 * number_of_input_faces. Normalization of these values will be done automatically in analyzeProgress() method.
    bool UserBreak (const Message_ProgressScope &thePS)
     Adds error to the report if the break signal was caught. Returns true in this case, false otherwise.

    Protected Attributes

    Fields
    TopoDS_Shape myInputShape
     Input shape.
    NCollection_List< TopoDS_ShapemyFacesToRemove
     Faces to remove.
    NCollection_List< TopoDS_ShapemyFeatures
     List of not connected features to remove (each feature is a compound of faces).
    NCollection_IndexedMap< TopoDS_Shape, TopTools_ShapeMapHashermyInputsMap
     Map of all sub-shapes of the input shape.
    Protected Attributes inherited from BOPAlgo_BuilderShape
    TopoDS_Shape myShape
     Result of the operation.
    NCollection_List< TopoDS_ShapemyHistShapes
     Storer for the history shapes.
    NCollection_Map< TopoDS_Shape, TopTools_ShapeMapHashermyMapShape
     cached map of all arguments shapes
    bool myFillHistory
     Controls the history filling.
    occ::handle< BRepTools_HistorymyHistory
     History tool.
    occ::handle< NCollection_BaseAllocatormyAllocator
     Enables/Disables the usage of OBB.
    occ::handle< Message_ReportmyReport
     Enables/Disables the usage of OBB.
    bool myRunParallel
     Enables/Disables the usage of OBB.
    double myFuzzyValue
     Enables/Disables the usage of OBB.
    bool myUseOBB
     Enables/Disables the usage of OBB.

    Additional Inherited Members

    static bool GetParallelMode ()
     Gets the global parallel mode.
    static void SetParallelMode (const bool theNewMode)
     Sets the global parallel mode.

    Detailed Description

    The RemoveFeatures algorithm is intended for reconstruction of the shape by removal of the unwanted parts from it. These parts can be holes, protrusions, spikes, fillets etc. The shape itself is not modified, the new shape is built in the result.

    Currently, only the shapes of type SOLID, COMPSOLID, and COMPOUND of Solids are supported. And only the FACEs can be removed from the shape.

    On the input the algorithm accepts the shape itself and the faces which have to be removed. It does not matter how the faces are given. It could be the separate faces or the collections of faces. The faces should belong to the initial shape, and those that do not belong will be ignored. Before reconstructing the shape, the algorithm will sort all the given faces on the connected blocks (features).

    The features will be removed from the shape one by one. It will allow removing all possible features even if there were problems with the removal of some of them.

    The removed feature is filled by the extension of the faces adjacent to the feature. In general, the algorithm of removing of the single feature from the shape looks as follows:

    • Find the faces adjacent to the feature;
    • Extend the adjacent faces to cover the feature;
    • Trim the extended faces by the bounds of original face (except for bounds common with the feature), so it will cover the feature only;
    • Rebuild the solids with reconstructed adjacent faces avoiding the faces from the feature.

    If the removal is successful, the result is overwritten with the new shape and the next feature is treated. Otherwise, the warning will be given.

    The algorithm has the following options:

    • History support;

    and the options available from base class:

    • Error/Warning reporting system;
    • Parallel processing mode.

    Please note that the other options of the base class are not supported here and will have no effect.

    History support allows tracking modification of the input shape in terms of Modified, IsDeleted and Generated. The history is available through the methods of the history tool BRepTools_History, which can be accessed here through the method History(). By default, the history is collected, but it is possible to disable it using the method SetToFillHistory(false);

    Error/Warning reporting system - allows obtaining the extended overview of the Errors/Warnings occurred during the operation. As soon as any error appears the algorithm stops working. The warnings allow continuing the job, informing the user that something went wrong. The algorithm returns the following errors/warnings:

    • BOPAlgo_AlertTooFewArguments - the error alert is given if the input shape does not contain any solids;
    • BOPAlgo_AlertUnsupportedType - the warning alert is given if the input shape contains not only solids, but also other shapes;
    • BOPAlgo_AlertNoFacesToRemove - the error alert is given in case there are no faces to remove from the shape (nothing to do);
    • BOPAlgo_AlertUnableToRemoveTheFeature - the warning alert is given to inform the user the removal of the feature is not possible. The algorithm will still try to remove the other features;
    • BOPAlgo_AlertRemoveFeaturesFailed - the error alert is given in case if the operation was aborted by the unknown reason.

    Parallel processing mode - allows running the algorithm in parallel mode obtaining the result faster.

    The algorithm has certain limitations:

    • Intersection of the connected faces adjacent to the feature should not be empty. It means, that such faces should not be tangent to each other. If the intersection of the adjacent faces will be empty, the algorithm will be unable to trim the faces correctly and, most likely, the feature will not be removed.
    • The algorithm does not process the INTERNAL parts of the solids, they are simply removed during reconstruction.

    Note that for successful removal of the feature, the extended faces adjacent to the feature should cover the feature completely, otherwise the solids will not be rebuild.

    Here is the example of usage of the algorithm:

    TopoDS_Shape aSolid = ...; // Input shape to remove the features from
    NCollection_List<TopoDS_Shape> aFaces = ...; // Faces to remove from the shape
    bool bRunParallel = ...; // Parallel processing mode
    bool isHistoryNeeded = ...; // History support
    BOPAlgo_RemoveFeatures aRF; // Feature removal algorithm
    aRF.SetShape(aSolid); // Set the shape
    aRF.AddFacesToRemove(aFaces); // Add faces to remove
    aRF.SetRunParallel(bRunParallel); // Define the processing mode (parallel or single)
    aRF.SetToFillHistory(isHistoryNeeded); // Define whether to track the shapes modifications
    aRF.Perform(); // Perform the operation
    if (aRF.HasErrors()) // Check for the errors
    {
    // error treatment
    return;
    }
    if (aRF.HasWarnings()) // Check for the warnings
    {
    // warnings treatment
    }
    const TopoDS_Shape& aResult = aRF.Shape(); // Result shape
    const TopoDS_Shape & Shape() const
    Definition BOPAlgo_BuilderShape.hxx:48
    void SetToFillHistory(const bool theHistFlag)
    Returns flag of history availability.
    Definition BOPAlgo_BuilderShape.hxx:114
    bool HasErrors() const
    Returns true if algorithm has failed.
    Definition BOPAlgo_Options.hxx:73
    bool HasWarnings() const
    Returns true if algorithm has generated some warning alerts.
    Definition BOPAlgo_Options.hxx:82
    void SetRunParallel(const bool theFlag)
    Set the flag of parallel processing if <theFlag> is true the parallel processing is switched on if <t...
    Definition BOPAlgo_Options.hxx:114
    void Perform(const Message_ProgressRange &theRange=Message_ProgressRange()) override
    The main method to implement the operation Providing the range allows to enable Progress indicator Us...
    BOPAlgo_RemoveFeatures()=default
    void SetShape(const TopoDS_Shape &theShape)
    Returns the input shape.
    Definition BOPAlgo_RemoveFeatures.hxx:163
    void AddFacesToRemove(const NCollection_List< TopoDS_Shape > &theFaces)
    Adds the faces to remove from the input shape.
    Definition BOPAlgo_RemoveFeatures.hxx:174
    Definition NCollection_List.hxx:33
    Describes a shape which.
    Definition TopoDS_Shape.hxx:41

    The algorithm preserves the type of the input shape in the result shape. Thus, if the input shape is a COMPSOLID, the resulting solids will also be put into a COMPSOLID.

    When all possible features are removed, the shape is simplified by removing extra edges and vertices, created during operation, from the result shape.

    Constructor & Destructor Documentation

    ◆ BOPAlgo_RemoveFeatures()

    BOPAlgo_RemoveFeatures::BOPAlgo_RemoveFeatures ( )
    default

    Member Function Documentation

    ◆ AddFacesToRemove()

    void BOPAlgo_RemoveFeatures::AddFacesToRemove ( const NCollection_List< TopoDS_Shape > & theFaces)
    inline

    Adds the faces to remove from the input shape.

    Parameters
    [in]theFacesThe list of shapes to extract the faces for removal.

    ◆ AddFaceToRemove()

    void BOPAlgo_RemoveFeatures::AddFaceToRemove ( const TopoDS_Shape & theFace)
    inline

    Adds the face to remove from the input shape.

    Parameters
    [in]theFaceThe shape to extract the faces for removal.

    ◆ CheckData()

    void BOPAlgo_RemoveFeatures::CheckData ( )
    overrideprotectedvirtual

    Prepares the faces to remove:

    • Gets only faces contained in the input solids;
    • Builds connected blocks of faces creating separate features to remove.

    Reimplemented from BOPAlgo_Algo.

    ◆ Clear()

    void BOPAlgo_RemoveFeatures::Clear ( )
    inlineoverridevirtual

    Clears all warnings and errors, and any data cached by the algorithm. User defined options are not cleared.

    Reimplemented from BOPAlgo_BuilderShape.

    ◆ FacesToRemove()

    const NCollection_List< TopoDS_Shape > & BOPAlgo_RemoveFeatures::FacesToRemove ( ) const
    inline

    Returns the list of faces which have been requested for removal from the input shape.

    ◆ fillPIConstants()

    void BOPAlgo_RemoveFeatures::fillPIConstants ( const double theWhole,
    BOPAlgo_PISteps & theSteps ) const
    overrideprotectedvirtual

    Filling steps for constant operations.

    Reimplemented from BOPAlgo_Algo.

    ◆ InputShape()

    const TopoDS_Shape & BOPAlgo_RemoveFeatures::InputShape ( ) const
    inline

    Returns the input shape.

    ◆ Perform()

    void BOPAlgo_RemoveFeatures::Perform ( const Message_ProgressRange & theRange = Message_ProgressRange())
    overridevirtual

    The main method to implement the operation Providing the range allows to enable Progress indicator User break functionalities.

    Implements BOPAlgo_Algo.

    ◆ PostTreat()

    void BOPAlgo_RemoveFeatures::PostTreat ( )
    protected

    Post treatment - restore the type of the initial shape.

    ◆ PrepareFeatures()

    void BOPAlgo_RemoveFeatures::PrepareFeatures ( const Message_ProgressRange & theRange)
    protected

    Prepares the faces to remove:

    • Gets only faces contained in the input solids;
    • Builds connected blocks of faces creating separate features to remove.

    ◆ RemoveFeature()

    void BOPAlgo_RemoveFeatures::RemoveFeature ( const TopoDS_Shape & theFeature,
    const NCollection_IndexedMap< TopoDS_Shape, TopTools_ShapeMapHasher > & theSolids,
    const NCollection_Map< TopoDS_Shape, TopTools_ShapeMapHasher > & theFeatureFacesMap,
    const bool theHasAdjacentFaces,
    const NCollection_IndexedDataMap< TopoDS_Shape, NCollection_List< TopoDS_Shape >, TopTools_ShapeMapHasher > & theAdjFaces,
    const occ::handle< BRepTools_History > & theAdjFacesHistory,
    const bool theSolidsHistoryNeeded,
    const Message_ProgressRange & theRange )
    protected

    Remove the single feature from the shape.

    Parameters
    [in]theFeatureThe feature to remove;
    [in]theSolidsThe solids to be reconstructed after feature removal;
    [in]theFeatureFacesMapThe map of feature faces;
    [in]theHasAdjacentFacesShows whether the adjacent faces have been found for the feature or not;
    [in]theAdjFacesThe reconstructed adjacent faces covering the feature;
    [in]theAdjFacesHistoryThe history of the adjacent faces reconstruction;
    [in]theSolidsHistoryNeededDefines whether the history of solids modifications should be tracked or not.

    ◆ RemoveFeatures()

    void BOPAlgo_RemoveFeatures::RemoveFeatures ( const Message_ProgressRange & theRange)
    protected

    Removes the features and fills the created gaps by extension of the adjacent faces. Processes each feature separately.

    ◆ SetShape()

    void BOPAlgo_RemoveFeatures::SetShape ( const TopoDS_Shape & theShape)
    inline

    Returns the input shape.

    ◆ SimplifyResult()

    void BOPAlgo_RemoveFeatures::SimplifyResult ( const Message_ProgressRange & theRange)
    protected

    Simplifies the result by removing extra edges and vertices created during removal of the features.

    ◆ UpdateHistory()

    void BOPAlgo_RemoveFeatures::UpdateHistory ( const Message_ProgressRange & theRange)
    protected

    Updates history with the removed features.

    Field Documentation

    ◆ myFacesToRemove

    NCollection_List<TopoDS_Shape> BOPAlgo_RemoveFeatures::myFacesToRemove
    protected

    Faces to remove.

    ◆ myFeatures

    NCollection_List<TopoDS_Shape> BOPAlgo_RemoveFeatures::myFeatures
    protected

    List of not connected features to remove (each feature is a compound of faces).

    ◆ myInputShape

    TopoDS_Shape BOPAlgo_RemoveFeatures::myInputShape
    protected

    Input shape.

    ◆ myInputsMap

    NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> BOPAlgo_RemoveFeatures::myInputsMap
    protected

    Map of all sub-shapes of the input shape.


    The documentation for this class was generated from the following file: