Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:38

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,
0050                                          const Standard_Integer iNode1)
0051     : myAttribute (0L)
0052   {
0053     myNode[0] = iNode0; myNode[1] = iNode1;
0054     myOppositeNode[0] = -1; myOppositeNode[1] = -1;
0055   }
0056 
0057   /**
0058    * Constructor, takes a triangle and a side. A link is created always such
0059    * that myNode[0] < myNode[1]. Unlike the previous constructor, this one
0060    * assigns the 'opposite node' fields. This constructor is used when a
0061    * link is inserted into a Poly_CoherentTriangulation structure.  
0062    * @param theTri
0063    *   Triangle containing the link that is created
0064    * @param iSide
0065    *   Can be 0, 1 or 2. Index of the node
0066    */
0067   Standard_EXPORT Poly_CoherentLink     (const Poly_CoherentTriangle& theTri,
0068                                          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
0077   { return myNode[ind & 0x1]; }
0078 
0079   /**
0080    * Return the opposite node (belonging to the left or right incident triangle)
0081    * index in the current triangulation.
0082    * @param ind
0083    *   0 or 1 making distinction of the two involved triangles: 0 on the left,
0084    *   1 on the right side of the Link.
0085    */
0086   inline Standard_Integer       OppositeNode (const Standard_Integer ind) const
0087   { return myOppositeNode[ind & 0x1]; }
0088 
0089   /**
0090    * Query the attribute of the Link.
0091    */
0092   inline Standard_Address       GetAttribute () const
0093   { return myAttribute; }
0094 
0095   /**
0096    * Set the attribute of the Link.
0097    */
0098   inline void                   SetAttribute (const Standard_Address theAtt)
0099   { myAttribute = theAtt; }
0100 
0101   /**
0102    * Query the status of the link - if it is an invalid one.
0103    * An invalid link has Node members equal to -1.
0104    */
0105   inline Standard_Boolean       IsEmpty      () const
0106   { return myNode[0] < 0 || myNode[1] < 0; }
0107 
0108   /**
0109    * Invalidate this Link.
0110    */
0111   inline void                   Nullify      ()
0112   {
0113     myNode[0] = -1; myNode[1] = -1;
0114     myOppositeNode[0] = -1; myOppositeNode[1] = -1;
0115   }
0116   
0117 
0118  protected:
0119   // ---------- PROTECTED METHODS ----------
0120 
0121 
0122 
0123  private:
0124   // ---------- PRIVATE FIELDS ----------
0125   Standard_Integer              myNode[2];
0126   Standard_Integer              myOppositeNode[2];
0127   Standard_Address              myAttribute;
0128 
0129   friend class Poly_CoherentTriangulation;
0130 };
0131 
0132 #endif