gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
LineMesh.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2023, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
64 //******************************************************************************
65 // namespace
66 //******************************************************************************
67 namespace gVirtualXRay {
68 
69 
70 //-----------------------------------------------------------------
71 template<typename T> LineMesh<T>::LineMesh(const VEC3& aStartPoint,
72  const VEC3& anEndPoint):
73 //-----------------------------------------------------------------
74  PolygonMesh()
75 //-----------------------------------------------------------------
76 {
77  create(aStartPoint, anEndPoint);
78 }
79 
80 
81 //--------------------------------------------------------------------
82 template<typename T> void LineMesh<T>::create(const VEC3& aStartPoint,
83  const VEC3& anEndPoint)
84 //--------------------------------------------------------------------
85 {
86  // Reset the mesh
87  reset();
88  m_external_data_flag = false;
89 
90  // Store vertices, normal vectors and indices
91  std::vector<T> p_vertex_set;
92 
93  // Vertices
94  p_vertex_set.push_back(aStartPoint.getX());
95  p_vertex_set.push_back(aStartPoint.getY());
96  p_vertex_set.push_back(aStartPoint.getZ());
97 
98  p_vertex_set.push_back(anEndPoint.getX());
99  p_vertex_set.push_back(anEndPoint.getY());
100  p_vertex_set.push_back(anEndPoint.getZ());
101 
102  setInternalData(GL_LINES,
103  &p_vertex_set,
104  false,
105  GL_STATIC_DRAW);
106 }
107 
108 } // namespace gVirtualXRay
T getX() const
Accessor on the position along the x-axis.
Definition: Vec3.inl:115
T getZ() const
Accessor on the position along the z-axis.
Definition: Vec3.inl:131
LineMesh(const VEC3 &aStartPoint=VEC3(0, 0, 0), const VEC3 &anEndPoint=VEC3(1.0 *cm, 0, 0))
Default constructor.
Definition: LineMesh.inl:71
T getY() const
Accessor on the position along the y-axis.
Definition: Vec3.inl:123
PolygonMesh is a class to handle polygon (triangles) meshes.
Definition: PolygonMesh.h:114