Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:29:05

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    * Empty constructor.
0043    */
0044   inline Poly_CoherentNode()
0045       : gp_XYZ(0., 0., 0.),
0046         myTriangles(nullptr),
0047         myIndex(-1)
0048   {
0049     myUV[0] = Precision::Infinite();
0050     myUV[1] = Precision::Infinite();
0051   }
0052 
0053   /**
0054    * Constructor.
0055    */
0056   inline Poly_CoherentNode(const gp_XYZ& thePnt)
0057       : gp_XYZ(thePnt),
0058         myTriangles(nullptr),
0059         myIndex(-1)
0060   {
0061     myUV[0]     = Precision::Infinite();
0062     myUV[1]     = Precision::Infinite();
0063     myNormal[0] = 0.f;
0064     myNormal[1] = 0.f;
0065     myNormal[2] = 0.f;
0066   }
0067 
0068   /**
0069    * Set the UV coordinates of the Node.
0070    */
0071   inline void SetUV(const double theU, const double theV)
0072   {
0073     myUV[0] = theU;
0074     myUV[1] = theV;
0075   }
0076 
0077   /**
0078    * Get U coordinate of the Node.
0079    */
0080   inline double GetU() const { return myUV[0]; }
0081 
0082   /**
0083    * Get V coordinate of the Node.
0084    */
0085   inline double GetV() const { return myUV[1]; }
0086 
0087   /**
0088    * Define the normal vector in the Node.
0089    */
0090   Standard_EXPORT void SetNormal(const gp_XYZ& theVector);
0091 
0092   /**
0093    * Query if the Node contains a normal vector.
0094    */
0095   inline bool HasNormal() const
0096   {
0097     return ((myNormal[0] * myNormal[0] + myNormal[1] * myNormal[1] + myNormal[2] * myNormal[2])
0098             > Precision::Confusion());
0099   }
0100 
0101   /**
0102    * Get the stored normal in the node.
0103    */
0104   inline gp_XYZ GetNormal() const { return gp_XYZ(myNormal[0], myNormal[1], myNormal[2]); }
0105 
0106   /**
0107    * Set the value of node Index.
0108    */
0109   inline void SetIndex(const int theIndex) { myIndex = theIndex; }
0110 
0111   /**
0112    * Get the value of node Index.
0113    */
0114   inline int GetIndex() const { return myIndex; }
0115 
0116   /**
0117    * Check if this is a free node, i.e., a node without a single
0118    * incident triangle.
0119    */
0120   inline bool IsFreeNode() const noexcept { return myTriangles == nullptr; }
0121 
0122   /**
0123    * Reset the Node to void.
0124    */
0125   Standard_EXPORT void Clear(const occ::handle<NCollection_BaseAllocator>&);
0126 
0127   /**
0128    * Connect a triangle to this Node.
0129    */
0130   Standard_EXPORT void AddTriangle(const Poly_CoherentTriangle&                  theTri,
0131                                    const occ::handle<NCollection_BaseAllocator>& theA);
0132 
0133   /**
0134    * Disconnect a triangle from this Node.
0135    */
0136   Standard_EXPORT bool RemoveTriangle(const Poly_CoherentTriangle&                  theTri,
0137                                       const occ::handle<NCollection_BaseAllocator>& theA);
0138 
0139   /**
0140    * Create an iterator of incident triangles.
0141    */
0142   inline Poly_CoherentTriPtr::Iterator TriangleIterator() const { return *myTriangles; }
0143 
0144   Standard_EXPORT void Dump(Standard_OStream& theStream) const;
0145 
0146   //   /**
0147   //    * Destructor.
0148   //    */
0149   //   Standard_EXPORT virtual ~Poly_CoherentNode ();
0150 
0151 private:
0152   // ---------- PRIVATE FIELDS ----------
0153 
0154   double               myUV[2];
0155   Poly_CoherentTriPtr* myTriangles;
0156   int                  myIndex;
0157   float                myNormal[3];
0158 };
0159 
0160 #endif