OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    BRepTools_ReShape Class Reference

    Rebuilds a Shape by making pre-defined substitutions on some of its components. More...

    #include <BRepTools_ReShape.hxx>

    Inheritance diagram for BRepTools_ReShape:

    Public Member Functions

     BRepTools_ReShape ()
     Returns an empty Reshape.
    virtual void Clear ()
     Clears all substitutions requests.
    virtual void Remove (const TopoDS_Shape &shape)
     Sets a request to Remove a Shape whatever the orientation.
    virtual void Replace (const TopoDS_Shape &shape, const TopoDS_Shape &newshape)
     Sets a request to Replace a Shape by a new one.
    template<typename TCollection>
    void Merge (const TCollection &theParts, const TopoDS_Shape &theProduct)
     Merges the parts to the single product. The first part is replaced by the product. The other parts are removed. The history of the merged shapes is presented by equal ways.
    virtual bool IsRecorded (const TopoDS_Shape &shape) const
     Tells if a shape is recorded for Replace/Remove.
    virtual TopoDS_Shape Value (const TopoDS_Shape &shape) const
     Returns the new value for an individual shape If not recorded, returns the original shape itself If to be Removed, returns a Null Shape Else, returns the replacing item.
    TopoDS_Shape ValueLeaf (const TopoDS_Shape &theShape) const
     Follows the replacement chain for theShape to its leaf without descending into sub-shapes. Iterates Value() until a fixpoint is reached. Unlike Apply(), this does not rebuild the shape from its children, so it is safe to call on edges/wires whose sub-shapes have their own pending replacements (avoids cascading sub-shape re-expansion).
    virtual int Status (const TopoDS_Shape &shape, TopoDS_Shape &newsh, const bool last=false)
     Returns a complete substitution status for a shape 0 : not recorded, <newsh> = original <shape> < 0: to be removed, <newsh> is NULL.
    virtual TopoDS_Shape Apply (const TopoDS_Shape &theShape, const TopAbs_ShapeEnum theUntil=TopAbs_SHAPE)
     Applies the substitutions requests to a shape.
    virtual bool & ModeConsiderLocation ()
     Returns (modifiable) the flag which defines whether Location of shape take into account during replacing shapes.
    TopoDS_Vertex CopyVertex (const TopoDS_Vertex &theV, const double theTol=-1.0)
     Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise.
    TopoDS_Vertex CopyVertex (const TopoDS_Vertex &theV, const gp_Pnt &theNewPos, const double aTol)
     Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise.
    bool IsNewShape (const TopoDS_Shape &theShape) const
     Checks if shape has been recorded by reshaper as a value.
    occ::handle< BRepTools_History > History () const
     Returns the history of the substituted shapes.
    Public Member Functions inherited from Standard_Transient
     Standard_Transient ()
     Empty constructor.
     Standard_Transient (const Standard_Transient &)
     Copy constructor – does nothing.
    Standard_Transient & operator= (const Standard_Transient &)
     Assignment operator, needed to avoid copying reference counter.
    virtual ~Standard_Transient ()=default
     Destructor must be virtual.
    virtual const opencascade::handle< Standard_Type > & DynamicType () const
     Returns a type descriptor about this object.
    bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
     Returns a true value if this is an instance of Type.
    bool IsInstance (const char *const theTypeName) const
     Returns a true value if this is an instance of TypeName.
    bool IsKind (const opencascade::handle< Standard_Type > &theType) const
     Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
    bool IsKind (const char *const theTypeName) const
     Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
    Standard_Transient * This () const
     Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
    int GetRefCount () const noexcept
     Get the reference counter of this object.
    void IncrementRefCounter () noexcept
     Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
    int DecrementRefCounter () noexcept
     Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
    virtual void Delete () const
     Memory deallocator for transient classes.

    Protected Types

    enum  TReplacementKind { TReplacementKind_Remove = 1 , TReplacementKind_Modify = 2 , TReplacementKind_Merge_Main = 4 , TReplacementKind_Merge_Ordinary = 8 }
     The kinds of the replacements. More...

    Protected Member Functions

    virtual void replace (const TopoDS_Shape &shape, const TopoDS_Shape &newshape, const TReplacementKind theKind)
     Replaces the first shape by the second one after the following reorientation.
    TopoDS_Shape applyImpl (const TopoDS_Shape &theShape, const TopAbs_ShapeEnum theUntil, NCollection_Map< occ::handle< TopoDS_TShape > > &theInFlight)
     Recursive worker for Apply with a DFS in-flight set keyed by TShape handle. Prevents unbounded descent when a replacement is a compound that transitively contains the original shape as a sub-shape (cyclic containment, distinct from cycles in the replacement map itself).

    Protected Attributes

    NCollection_Map< TopoDS_Shape, TopTools_ShapeMapHasher > myNewShapes
    int myStatus

    Additional Inherited Members

    typedef void base_type
     Returns a type descriptor about this object.
    static constexpr const char * get_type_name ()
     Returns a type descriptor about this object.
    static const opencascade::handle< Standard_Type > & get_type_descriptor ()
     Returns type descriptor of Standard_Transient class.

    Detailed Description

    Rebuilds a Shape by making pre-defined substitutions on some of its components.

    In a first phase, it records requests to replace or remove some individual shapes For each shape, the last given request is recorded Requests may be applied "Oriented" (i.e. only to an item with the SAME orientation) or not (the orientation of replacing shape is respectful of that of the original one)

    Then, these requests may be applied to any shape which may contain one or more of these individual shapes

    Supports the 'BRepTools_History' history by method 'History'.

    Member Enumeration Documentation

    ◆ TReplacementKind

    The kinds of the replacements.

    Enumerator
    TReplacementKind_Remove 
    TReplacementKind_Modify 
    TReplacementKind_Merge_Main 
    TReplacementKind_Merge_Ordinary 

    Constructor & Destructor Documentation

    ◆ BRepTools_ReShape()

    BRepTools_ReShape::BRepTools_ReShape ( )

    Returns an empty Reshape.

    Member Function Documentation

    ◆ Apply()

    virtual TopoDS_Shape BRepTools_ReShape::Apply ( const TopoDS_Shape & theShape,
    const TopAbs_ShapeEnum theUntil = TopAbs_SHAPE )
    virtual

    Applies the substitutions requests to a shape.

    theUntil gives the level of type until which requests are taken into account. For subshapes of the type <until> no rebuild and further exploring are done.

    NOTE: each subshape can be replaced by shape of the same type or by shape containing only shapes of that type (for example, TopoDS_Edge can be replaced by TopoDS_Edge, TopoDS_Wire or TopoDS_Compound containing TopoDS_Edges). If incompatible shape type is encountered, it is ignored and flag FAIL1 is set in Status.

    Reimplemented in ShapeBuild_ReShape.

    ◆ applyImpl()

    TopoDS_Shape BRepTools_ReShape::applyImpl ( const TopoDS_Shape & theShape,
    const TopAbs_ShapeEnum theUntil,
    NCollection_Map< occ::handle< TopoDS_TShape > > & theInFlight )
    protected

    Recursive worker for Apply with a DFS in-flight set keyed by TShape handle. Prevents unbounded descent when a replacement is a compound that transitively contains the original shape as a sub-shape (cyclic containment, distinct from cycles in the replacement map itself).

    ◆ Clear()

    virtual void BRepTools_ReShape::Clear ( )
    virtual

    Clears all substitutions requests.

    ◆ CopyVertex() [1/2]

    TopoDS_Vertex BRepTools_ReShape::CopyVertex ( const TopoDS_Vertex & theV,
    const double theTol = -1.0 )

    Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise.

    ◆ CopyVertex() [2/2]

    TopoDS_Vertex BRepTools_ReShape::CopyVertex ( const TopoDS_Vertex & theV,
    const gp_Pnt & theNewPos,
    const double aTol )

    Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise.

    ◆ History()

    occ::handle< BRepTools_History > BRepTools_ReShape::History ( ) const

    Returns the history of the substituted shapes.

    ◆ IsNewShape()

    bool BRepTools_ReShape::IsNewShape ( const TopoDS_Shape & theShape) const

    Checks if shape has been recorded by reshaper as a value.

    ◆ IsRecorded()

    virtual bool BRepTools_ReShape::IsRecorded ( const TopoDS_Shape & shape) const
    virtual

    Tells if a shape is recorded for Replace/Remove.

    ◆ Merge()

    template<typename TCollection>
    void BRepTools_ReShape::Merge ( const TCollection & theParts,
    const TopoDS_Shape & theProduct )
    inline

    Merges the parts to the single product. The first part is replaced by the product. The other parts are removed. The history of the merged shapes is presented by equal ways.

    ◆ ModeConsiderLocation()

    virtual bool & BRepTools_ReShape::ModeConsiderLocation ( )
    inlinevirtual

    Returns (modifiable) the flag which defines whether Location of shape take into account during replacing shapes.

    ◆ Remove()

    virtual void BRepTools_ReShape::Remove ( const TopoDS_Shape & shape)
    virtual

    Sets a request to Remove a Shape whatever the orientation.

    ◆ Replace()

    virtual void BRepTools_ReShape::Replace ( const TopoDS_Shape & shape,
    const TopoDS_Shape & newshape )
    inlinevirtual

    Sets a request to Replace a Shape by a new one.

    ◆ replace()

    virtual void BRepTools_ReShape::replace ( const TopoDS_Shape & shape,
    const TopoDS_Shape & newshape,
    const TReplacementKind theKind )
    protectedvirtual

    Replaces the first shape by the second one after the following reorientation.

    If the first shape has the reversed orientation then the both shapes are reversed. If the first shape has the internal or external orientation then:

    • the second shape is oriented forward (reversed) if it's orientation is equal (not equal) to the orientation of the first shape;
    • the first shape is oriented forward.

    ◆ Status()

    virtual int BRepTools_ReShape::Status ( const TopoDS_Shape & shape,
    TopoDS_Shape & newsh,
    const bool last = false )
    virtual

    Returns a complete substitution status for a shape 0 : not recorded, <newsh> = original <shape> < 0: to be removed, <newsh> is NULL.

    0: to be replaced, <newsh> is a new item If <last> is False, returns status and new shape recorded in the map directly for the shape, if True and status > 0 then recursively searches for the last status and new shape.

    Reimplemented in ShapeBuild_ReShape.

    ◆ Value()

    virtual TopoDS_Shape BRepTools_ReShape::Value ( const TopoDS_Shape & shape) const
    virtual

    Returns the new value for an individual shape If not recorded, returns the original shape itself If to be Removed, returns a Null Shape Else, returns the replacing item.

    ◆ ValueLeaf()

    TopoDS_Shape BRepTools_ReShape::ValueLeaf ( const TopoDS_Shape & theShape) const

    Follows the replacement chain for theShape to its leaf without descending into sub-shapes. Iterates Value() until a fixpoint is reached. Unlike Apply(), this does not rebuild the shape from its children, so it is safe to call on edges/wires whose sub-shapes have their own pending replacements (avoids cascading sub-shape re-expansion).

    Returns
    the final replacement, or the original shape if not recorded, or a Null shape if the chain terminates in a Remove.

    Field Documentation

    ◆ myNewShapes

    NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> BRepTools_ReShape::myNewShapes
    protected

    ◆ myStatus

    int BRepTools_ReShape::myStatus
    protected

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