Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-11 08:22:15

0001 // Created on: 2007-12-25
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2007-2014 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 Poly_CoherentLink_HeaderFile
0017 #define Poly_CoherentLink_HeaderFile
0018 
0019 #include <Standard_TypeDef.hxx>
0020 
0021 class Poly_CoherentTriangle;
0022 
0023 /**
0024  * Link between two mesh nodes that is created by existing triangle(s).
0025  * Keeps reference to the opposite node of each incident triangle.
0026  * The referred node with index "0" is always on the left side of the link,
0027  * the one with the index "1" is always on the right side.
0028  * It is possible to find both incident triangles using the method
0029  * Poly_CoherentTriangulation::FindTriangle().
0030  * <p>
0031  * Any Link can store an arbitrary pointer that is called Attribute.
0032  */
0033 
0034 class Poly_CoherentLink
0035 {
0036 public:
0037   // ---------- PUBLIC METHODS ----------
0038 
0039   /**
0040    * Empty constructor.
0041    */
0042   Standard_EXPORT Poly_CoherentLink();
0043 
0044   /**
0045    * Constructor. Creates a Link that has no reference to 'opposite nodes'.
0046    * This constructor is useful to create temporary object that is not
0047    * inserted into any existing triangulation.
0048    */
0049   inline Poly_CoherentLink(const Standard_Integer iNode0, const Standard_Integer iNode1)
0050       : myAttribute(0L)
0051   {
0052     myNode[0]         = iNode0;
0053     myNode[1]         = iNode1;
0054     myOppositeNode[0] = -1;
0055     myOppositeNode[1] = -1;
0056   }
0057 
0058   /**
0059    * Constructor, takes a triangle and a side. A link is created always such
0060    * that myNode[0] < myNode[1]. Unlike the previous constructor, this one
0061    * assigns the 'opposite node' fields. This constructor is used when a
0062    * link is inserted into a Poly_CoherentTriangulation structure.
0063    * @param theTri
0064    *   Triangle containing the link that is created
0065    * @param iSide
0066    *   Can be 0, 1 or 2. Index of the node
0067    */
0068   Standard_EXPORT Poly_CoherentLink(const Poly_CoherentTriangle& theTri, Standard_Integer iSide);
0069 
0070   /**
0071    * Return the node index in the current triangulation.
0072    * @param ind
0073    *   0 or 1 making distinction of the two nodes that constitute the Link.
0074    *   Node(0) always returns a smaller number than Node(1).
0075    */
0076   inline Standard_Integer Node(const Standard_Integer ind) const { return myNode[ind & 0x1]; }
0077 
0078   /**
0079    * Return the opposite node (belonging to the left or right incident triangle)
0080    * index in the current triangulation.
0081    * @param ind
0082    *   0 or 1 making distinction of the two involved triangles: 0 on the left,
0083    *   1 on the right side of the Link.
0084    */
0085   inline Standard_Integer OppositeNode(const Standard_Integer ind) const
0086   {
0087     return myOppositeNode[ind & 0x1];
0088   }
0089 
0090   /**
0091    * Query the attribute of the Link.
0092    */
0093   inline Standard_Address GetAttribute() const { return myAttribute; }
0094 
0095   /**
0096    * Set the attribute of the Link.
0097    */
0098   inline void SetAttribute(const Standard_Address theAtt) { myAttribute = theAtt; }
0099 
0100   /**
0101    * Query the status of the link - if it is an invalid one.
0102    * An invalid link has Node members equal to -1.
0103    */
0104   inline Standard_Boolean IsEmpty() const { return myNode[0] < 0 || myNode[1] < 0; }
0105 
0106   /**
0107    * Invalidate this Link.
0108    */
0109   inline void Nullify()
0110   {
0111     myNode[0]         = -1;
0112     myNode[1]         = -1;
0113     myOppositeNode[0] = -1;
0114     myOppositeNode[1] = -1;
0115   }
0116 
0117 protected:
0118   // ---------- PROTECTED METHODS ----------
0119 
0120 private:
0121   // ---------- PRIVATE FIELDS ----------
0122   Standard_Integer myNode[2];
0123   Standard_Integer myOppositeNode[2];
0124   Standard_Address myAttribute;
0125 
0126   friend class Poly_CoherentTriangulation;
0127 };
0128 
0129 #endif