Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2007-12-08
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_CoherentNode_HeaderFile
0017 #define Poly_CoherentNode_HeaderFile
0018 
0019 #include <gp_XYZ.hxx>
0020 #include <Poly_CoherentTriPtr.hxx>
0021 #include <Precision.hxx>
0022 
0023 class NCollection_BaseAllocator;
0024 
0025 /**
0026  * Node of coherent triangulation. Contains:
0027  * <ul>
0028  * <li>Coordinates of a 3D point defining the node location</li>
0029  * <li>2D point coordinates</li>
0030  * <li>List of triangles that use this Node</li>
0031  * <li>Integer index, normally the index of the node in the original
0032  *     triangulation</li>
0033  * </ul>
0034  */
0035 
0036 class Poly_CoherentNode : public gp_XYZ 
0037 {
0038  public:
0039   // ---------- PUBLIC METHODS ----------
0040 
0041 
0042   /**
0043    * Empty constructor.
0044    */
0045   inline Poly_CoherentNode ()
0046     : gp_XYZ            (0., 0., 0.),
0047       myTriangles       (0L),
0048       myIndex           (-1)
0049   { myUV[0] = Precision::Infinite(); myUV[1] = Precision::Infinite(); }
0050 
0051   /**
0052    * Constructor.
0053    */
0054   inline Poly_CoherentNode (const gp_XYZ& thePnt)
0055     : gp_XYZ            (thePnt),
0056       myTriangles       (0L),
0057       myIndex           (-1)
0058   { myUV[0] = Precision::Infinite(); myUV[1] = Precision::Infinite(); myNormal[0] = 0.f; myNormal[1] = 0.f; myNormal[2] = 0.f; }
0059 
0060   /**
0061    * Set the UV coordinates of the Node.
0062    */
0063   inline void             SetUV         (const Standard_Real theU,
0064                                          const Standard_Real theV)
0065   { myUV[0] = theU; myUV[1] = theV; }
0066 
0067   /**
0068    * Get U coordinate of the Node.
0069    */
0070   inline Standard_Real    GetU          () const
0071   { return myUV[0]; }
0072 
0073   /**
0074    * Get V coordinate of the Node.
0075    */
0076   inline Standard_Real    GetV          () const
0077   { return myUV[1]; }
0078 
0079   /**
0080    * Define the normal vector in the Node.
0081    */
0082   Standard_EXPORT void    SetNormal     (const gp_XYZ& theVector);
0083 
0084   /**
0085    * Query if the Node contains a normal vector.
0086    */
0087   inline Standard_Boolean HasNormal     () const
0088   { return ((myNormal[0]*myNormal[0] + myNormal[1]*myNormal[1] +
0089              myNormal[2]*myNormal[2]) > Precision::Confusion()); }
0090 
0091   /**
0092    * Get the stored normal in the node.
0093    */
0094   inline gp_XYZ           GetNormal    () const
0095   { return gp_XYZ (myNormal[0], myNormal[1], myNormal[2]); }
0096 
0097   /**
0098    * Set the value of node Index.
0099    */
0100   inline void             SetIndex     (const Standard_Integer theIndex)
0101   { myIndex = theIndex; }
0102 
0103   /**
0104    * Get the value of node Index.
0105    */
0106   inline Standard_Integer GetIndex      () const
0107   { return myIndex; }
0108 
0109   /**
0110    * Check if this is a free node, i.e., a node without a single
0111    * incident triangle.
0112    */
0113   inline Standard_Boolean IsFreeNode    () const
0114   { return myTriangles == 0L; }
0115 
0116   /**
0117    * Reset the Node to void.
0118    */
0119   Standard_EXPORT void  Clear   (const Handle(NCollection_BaseAllocator)&);
0120 
0121   /**
0122    * Connect a triangle to this Node.
0123    */
0124   Standard_EXPORT void  AddTriangle
0125                                 (const Poly_CoherentTriangle&            theTri,
0126                                  const Handle(NCollection_BaseAllocator)& theA);
0127 
0128   /**
0129    * Disconnect a triangle from this Node.
0130    */
0131   Standard_EXPORT Standard_Boolean
0132                         RemoveTriangle
0133                                 (const Poly_CoherentTriangle&            theTri,
0134                                  const Handle(NCollection_BaseAllocator)& theA);
0135 
0136   /**
0137    * Create an iterator of incident triangles.
0138    */
0139   inline Poly_CoherentTriPtr::Iterator
0140                         TriangleIterator () const
0141   { return * myTriangles; }
0142 
0143   Standard_EXPORT void  Dump    (Standard_OStream& theStream) const;
0144 
0145 //   /**
0146 //    * Destructor.
0147 //    */
0148 //   Standard_EXPORT virtual ~Poly_CoherentNode ();
0149 
0150 
0151 
0152  protected:
0153   // ---------- PROTECTED METHODS ----------
0154 
0155 
0156 
0157  private:
0158   // ---------- PRIVATE FIELDS ----------
0159 
0160   Standard_Real         myUV[2];
0161   Poly_CoherentTriPtr   * myTriangles;
0162   Standard_Integer      myIndex;
0163   Standard_ShortReal    myNormal[3];
0164 };
0165 
0166 #endif