1 // Created on: 2007-12-08
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef Poly_CoherentNode_HeaderFile
17 #define Poly_CoherentNode_HeaderFile
20 #include <Poly_CoherentTriPtr.hxx>
21 #include <Precision.hxx>
23 class NCollection_BaseAllocator;
26 * Node of coherent triangulation. Contains:
28 * <li>Coordinates of a 3D point defining the node location</li>
29 * <li>2D point coordinates</li>
30 * <li>List of triangles that use this Node</li>
31 * <li>Integer index, normally the index of the node in the original
36 class Poly_CoherentNode : public gp_XYZ
39 // ---------- PUBLIC METHODS ----------
45 inline Poly_CoherentNode ()
46 : gp_XYZ (0., 0., 0.),
49 { myUV[0] = Precision::Infinite(); myUV[1] = Precision::Infinite(); }
54 inline Poly_CoherentNode (const gp_XYZ& thePnt)
58 { myUV[0] = Precision::Infinite(); myUV[1] = Precision::Infinite(); myNormal[0] = 0.f; myNormal[1] = 0.f; myNormal[2] = 0.f; }
61 * Set the UV coordinates of the Node.
63 inline void SetUV (const Standard_Real theU,
64 const Standard_Real theV)
65 { myUV[0] = theU; myUV[1] = theV; }
68 * Get U coordinate of the Node.
70 inline Standard_Real GetU () const
74 * Get V coordinate of the Node.
76 inline Standard_Real GetV () const
80 * Define the normal vector in the Node.
82 Standard_EXPORT void SetNormal (const gp_XYZ& theVector);
85 * Query if the Node contains a normal vector.
87 inline Standard_Boolean HasNormal () const
88 { return ((myNormal[0]*myNormal[0] + myNormal[1]*myNormal[1] +
89 myNormal[2]*myNormal[2]) > Precision::Confusion()); }
92 * Get the stored normal in the node.
94 inline gp_XYZ GetNormal () const
95 { return gp_XYZ (myNormal[0], myNormal[1], myNormal[2]); }
98 * Set the value of node Index.
100 inline void SetIndex (const Standard_Integer theIndex)
101 { myIndex = theIndex; }
104 * Get the value of node Index.
106 inline Standard_Integer GetIndex () const
110 * Check if this is a free node, i.e., a node without a single
113 inline Standard_Boolean IsFreeNode () const
114 { return myTriangles == 0L; }
117 * Reset the Node to void.
119 Standard_EXPORT void Clear (const Handle(NCollection_BaseAllocator)&);
122 * Connect a triangle to this Node.
124 Standard_EXPORT void AddTriangle
125 (const Poly_CoherentTriangle& theTri,
126 const Handle(NCollection_BaseAllocator)& theA);
129 * Disconnect a triangle from this Node.
131 Standard_EXPORT Standard_Boolean
133 (const Poly_CoherentTriangle& theTri,
134 const Handle(NCollection_BaseAllocator)& theA);
137 * Create an iterator of incident triangles.
139 inline Poly_CoherentTriPtr::Iterator
140 TriangleIterator () const
141 { return * myTriangles; }
143 Standard_EXPORT void Dump (Standard_OStream& theStream) const;
148 // Standard_EXPORT virtual ~Poly_CoherentNode ();
153 // ---------- PROTECTED METHODS ----------
158 // ---------- PRIVATE FIELDS ----------
160 Standard_Real myUV[2];
161 Poly_CoherentTriPtr * myTriangles;
162 Standard_Integer myIndex;
163 Standard_ShortReal myNormal[3];