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
    Poly_CoherentTriangulation Class Reference

    Definition of HANDLE object using Standard_DefineHandle.hxx. More...

    #include <Poly_CoherentTriangulation.hxx>

    Inheritance diagram for Poly_CoherentTriangulation:

    Data Structures

    class  IteratorOfTriangle
    class  IteratorOfNode
    struct  TwoIntegers
     Couple of integer indices (used in RemoveDegenerated()). More...

    Public Member Functions

     Poly_CoherentTriangulation (const occ::handle< NCollection_BaseAllocator > &theAlloc=nullptr)
     Poly_CoherentTriangulation (const occ::handle< Poly_Triangulation > &theTriangulation, const occ::handle< NCollection_BaseAllocator > &theAlloc=nullptr)
     ~Poly_CoherentTriangulation () override
    occ::handle< Poly_TriangulationGetTriangulation () const
    bool RemoveDegenerated (const double theTol, NCollection_List< TwoIntegers > *pLstRemovedNode=nullptr)
    bool GetFreeNodes (NCollection_List< int > &lstNodes) const
    int MaxNode () const
    int MaxTriangle () const
    void SetDeflection (const double theDefl)
    double Deflection () const
    int SetNode (const gp_XYZ &thePnt, const int iN=-1)
    const Poly_CoherentNodeNode (const int i) const
    Poly_CoherentNodeChangeNode (const int i)
    int NNodes () const
    const Poly_CoherentTriangleTriangle (const int i) const
    int NTriangles () const
    int NLinks () const
    bool RemoveTriangle (Poly_CoherentTriangle &theTr)
    void RemoveLink (Poly_CoherentLink &theLink)
    Poly_CoherentTriangleAddTriangle (const int iNode0, const int iNode1, const int iNode2)
    bool ReplaceNodes (Poly_CoherentTriangle &theTriangle, const int iNode0, const int iNode1, const int iNode2)
    Poly_CoherentLinkAddLink (const Poly_CoherentTriangle &theTri, const int theConn)
    bool FindTriangle (const Poly_CoherentLink &theLink, const Poly_CoherentTriangle *pTri[2]) const
    int ComputeLinks ()
    void ClearLinks ()
    const occ::handle< NCollection_BaseAllocator > & Allocator () const
    occ::handle< Poly_CoherentTriangulationClone (const occ::handle< NCollection_BaseAllocator > &theAlloc) const
    void Dump (Standard_OStream &) const
    Public Member Functions inherited from Standard_Transient
     Standard_Transient ()
     Empty constructor.
     Standard_Transient (const Standard_Transient &)
     Copy constructor – does nothing.
    Standard_Transientoperator= (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_TransientThis () 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 Attributes

    NCollection_DynamicArray< Poly_CoherentTrianglemyTriangles
    NCollection_DynamicArray< Poly_CoherentNodemyNodes
    NCollection_DynamicArray< Poly_CoherentLinkmyLinks
    occ::handle< NCollection_BaseAllocatormyAlloc
    double myDeflection

    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

    Definition of HANDLE object using Standard_DefineHandle.hxx.

    Triangulation structure that allows to:

    • Store the connectivity of each triangle with up to 3 neighbouring ones and with the corresponding 3rd nodes on them,
    • Store the connectivity of each node with all triangles that share this node
    • Add nodes and triangles to the structure,
    • Find all triangles sharing a single or a couple of nodes
    • Remove triangles from structure
    • Optionally create Links between pairs of nodes according to the current triangulation.
    • Convert from/to Poly_Triangulation structure.

    This class is useful for algorithms that need to analyse and/or edit a triangulated mesh – for example for mesh refining. The connectivity model follows the idea that all Triangles in a mesh should have coherent orientation like on a surface of a solid body. Connections between more than 2 triangles are not supported.

    Architecture

    The data types used in this structure are:

    • Poly_CoherentNode: Inherits go_XYZ therefore provides the full public API of gp_XYZ. Contains references to all incident triangles. You can add new nodes but you cannot remove existing ones. However each node that has no referenced triangle is considered as "free" (use the method IsFreeNode() to check this). Free nodes are not available to further processing, particularly they are not exported in Poly_Triangulation.
    • Poly_CoherentTriangle: Main data type. Refers three Nodes, three connected Triangles, three opposite (connected) Nodes and three Links. If there is boundary then 1, 2 or 3 references to Triangles/connected Nodes/Links are assigned to NULL (for pointers) or -1 (for integer node index).

      You can find a triangle by one node using its triangle iterator or by two nodes - creating a temporary Poly_CoherentLink and calling the method FindTriangle().

      Triangles can be removed but they are never deleted from the containing array. Removed triangles have all nodes equal to -1. You can use the method IsEmpty() to check that.

    • Poly_CoherentLink: Auxiliary data type. Normally the array of Links is empty, because for many algorithms it is sufficient to define only Triangles. You can explicitly create the Links at least once, calling the method ComputeLinks(). Each Link is oriented couple of Poly_CoherentNode (directed to the ascending Node index). It refers two connected triangulated Nodes - on the left and on the right, therefore a Poly_CoherentLink instance refers the full set of nodes that constitute a couple of connected Triangles. A boundary Link has either the first (left) or the second (right) connected node index equal to -1.

      When the array of Links is created, all subsequent calls to AddTriangle and RemoveTriangle try to preserve the connectivity Triangle-Link in addition to the connectivity Triangle-Triangle. Particularly, new Links are created by method AddTriangle() and existing ones are removed by method RemoveTriangle(), in each case whenever necessary.

      Similarly to Poly_CoherentTriangle, a Link can be removed but not destroyed separately from others. Removed Link can be recogniosed using the method IsEmpty(). To destroy all Links, call the method ClearLinks(), this method also nullifies Link references in all Triangles. All objects (except for free Nodes and empty Triangles and Links) can be visited by the corresponding Iterator. Direct access is provided only for Nodes (needed to resolve Node indexed commonly used as reference). Triangles and Links can be retrieved by their index only internally, the public API provides only references or pointers to C++ objects. If you need a direct access to Triangles and Links, you can subclass Poly_CoherentTriangulation and use the protected API for your needs.

      Memory management: All data objects are stored in NCollection_DynamicArray containers that prove to be efficient for the performance. In addition references to triangles are stored in ring lists, with an instance of such list per Poly_CoherentNode. These lists are allocated in a memory allocator that is provided in the constructor of Poly_CoherentTriangulation. By default the standard OCCT allocator (aka NCollection_BaseAllocator) is used. But if you need to increase the performance you can use NCollection_IncAllocator instead.

    Constructor & Destructor Documentation

    ◆ Poly_CoherentTriangulation() [1/2]

    Poly_CoherentTriangulation::Poly_CoherentTriangulation ( const occ::handle< NCollection_BaseAllocator > & theAlloc = nullptr)

    Empty constructor.

    ◆ Poly_CoherentTriangulation() [2/2]

    Poly_CoherentTriangulation::Poly_CoherentTriangulation ( const occ::handle< Poly_Triangulation > & theTriangulation,
    const occ::handle< NCollection_BaseAllocator > & theAlloc = nullptr )

    Constructor. It does not create Links, you should call ComputeLinks following this constructor if you need these links.

    ◆ ~Poly_CoherentTriangulation()

    Poly_CoherentTriangulation::~Poly_CoherentTriangulation ( )
    override

    Destructor.

    Member Function Documentation

    ◆ AddLink()

    Poly_CoherentLink * Poly_CoherentTriangulation::AddLink ( const Poly_CoherentTriangle & theTri,
    const int theConn )

    Add a single link to triangulation, based on a triangle and its side index. This method does not check for coincidence with already present links.

    Parameters
    theTriTriangle that contains the link to be added.
    theConnIndex of the side (i.e., 0, 1 0r 2) defining the added link.

    ◆ AddTriangle()

    Poly_CoherentTriangle * Poly_CoherentTriangulation::AddTriangle ( const int iNode0,
    const int iNode1,
    const int iNode2 )

    Add a triangle to the triangulation.

    Returns
    Pointer to the added triangle instance or NULL if an error occurred.

    ◆ Allocator()

    const occ::handle< NCollection_BaseAllocator > & Poly_CoherentTriangulation::Allocator ( ) const
    inline

    Query the allocator of elements, this allocator can be used for other objects

    ◆ ChangeNode()

    Poly_CoherentNode & Poly_CoherentTriangulation::ChangeNode ( const int i)
    inline

    Get the node at the given index 'i'.

    ◆ ClearLinks()

    void Poly_CoherentTriangulation::ClearLinks ( )

    Clear all Links data from the Triangulation data.

    ◆ Clone()

    occ::handle< Poly_CoherentTriangulation > Poly_CoherentTriangulation::Clone ( const occ::handle< NCollection_BaseAllocator > & theAlloc) const

    Create a copy of this Triangulation, using the given allocator.

    ◆ ComputeLinks()

    int Poly_CoherentTriangulation::ComputeLinks ( )

    (Re)Calculate all links in this Triangulation.

    ◆ Deflection()

    double Poly_CoherentTriangulation::Deflection ( ) const
    inline

    Query the Deflection parameter (default value 0. – if never initialized)

    ◆ Dump()

    void Poly_CoherentTriangulation::Dump ( Standard_OStream & ) const

    Debugging output.

    ◆ FindTriangle()

    bool Poly_CoherentTriangulation::FindTriangle ( const Poly_CoherentLink & theLink,
    const Poly_CoherentTriangle * pTri[2] ) const

    Find one or two triangles that share the given couple of nodes.

    Parameters
    theLinkLink (in fact, just a couple of nodes) on which the triangle is searched.
    pTri[out] Array of two pointers to triangle. pTri[0] stores the triangle to the left of the link, while pTri[1] stores the one to the right of the link.
    Returns
    True if at least one triangle is found and output as pTri.

    ◆ GetFreeNodes()

    bool Poly_CoherentTriangulation::GetFreeNodes ( NCollection_List< int > & lstNodes) const

    Create a list of free nodes. These nodes may appear as a result of any custom mesh decimation or RemoveDegenerated() call. This analysis is necessary if you support additional data structures based on the triangulation (e.g., edges on the surface boundary).

    Parameters
    lstNodes[out] List that receives the indices of free nodes.

    ◆ GetTriangulation()

    occ::handle< Poly_Triangulation > Poly_CoherentTriangulation::GetTriangulation ( ) const

    Create an instance of Poly_Triangulation from this object.

    ◆ MaxNode()

    int Poly_CoherentTriangulation::MaxNode ( ) const
    inline

    Query the index of the last node in the triangulation

    ◆ MaxTriangle()

    int Poly_CoherentTriangulation::MaxTriangle ( ) const
    inline

    Query the index of the last triangle in the triangulation

    ◆ NLinks()

    int Poly_CoherentTriangulation::NLinks ( ) const

    Query the total number of active Links.

    ◆ NNodes()

    int Poly_CoherentTriangulation::NNodes ( ) const

    Query the total number of active nodes (i.e. nodes used by 1 or more triangles)

    ◆ Node()

    const Poly_CoherentNode & Poly_CoherentTriangulation::Node ( const int i) const
    inline

    Get the node at the given index 'i'.

    ◆ NTriangles()

    int Poly_CoherentTriangulation::NTriangles ( ) const

    Query the total number of active triangles (i.e. triangles that refer nodes, non-empty ones)

    ◆ RemoveDegenerated()

    bool Poly_CoherentTriangulation::RemoveDegenerated ( const double theTol,
    NCollection_List< TwoIntegers > * pLstRemovedNode = nullptr )

    Find and remove degenerated triangles in Triangulation.

    Parameters
    theTolTolerance for the degeneration case. If any two nodes of a triangle have the distance less than this tolerance, this triangle is considered degenerated and therefore removed by this method.
    pLstRemovedNodeOptional parameter. If defined, then it will receive the list of arrays where the first number is the index of removed node and the second - the index of remaining node to which the mesh was reconnected.

    ◆ RemoveLink()

    void Poly_CoherentTriangulation::RemoveLink ( Poly_CoherentLink & theLink)

    Removal of a single link from the triangulation.

    ◆ RemoveTriangle()

    bool Poly_CoherentTriangulation::RemoveTriangle ( Poly_CoherentTriangle & theTr)

    Removal of a single triangle from the triangulation.

    ◆ ReplaceNodes()

    bool Poly_CoherentTriangulation::ReplaceNodes ( Poly_CoherentTriangle & theTriangle,
    const int iNode0,
    const int iNode1,
    const int iNode2 )

    Replace nodes in the given triangle.

    Returns
    True if operation succeeded.

    ◆ SetDeflection()

    void Poly_CoherentTriangulation::SetDeflection ( const double theDefl)
    inline

    Set the Deflection value as the parameter of the given triangulation.

    ◆ SetNode()

    int Poly_CoherentTriangulation::SetNode ( const gp_XYZ & thePnt,
    const int iN = -1 )

    Initialize a node

    Parameters
    thePoint3D Coordinates of the node.
    iNIndex of the node. If negative (default), the node is added to the end of the current array of nodes.
    Returns
    Index of the added node.

    ◆ Triangle()

    const Poly_CoherentTriangle & Poly_CoherentTriangulation::Triangle ( const int i) const
    inline

    Get the triangle at the given index 'i'.

    Field Documentation

    ◆ myAlloc

    occ::handle<NCollection_BaseAllocator> Poly_CoherentTriangulation::myAlloc
    protected

    ◆ myDeflection

    double Poly_CoherentTriangulation::myDeflection
    protected

    ◆ myLinks

    NCollection_DynamicArray<Poly_CoherentLink> Poly_CoherentTriangulation::myLinks
    protected

    ◆ myNodes

    NCollection_DynamicArray<Poly_CoherentNode> Poly_CoherentTriangulation::myNodes
    protected

    ◆ myTriangles

    NCollection_DynamicArray<Poly_CoherentTriangle> Poly_CoherentTriangulation::myTriangles
    protected

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