RayZaler 0.1
The free opto-mechanical simulation framework
StlMesh.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _STL_MESH_H
20#define _STL_MESH_H
21
22#include <OpticalElement.h>
23#include <GLHelpers.h>
24
25namespace RZ {
26 class TranslatedFrame;
27
28 class StlMesh : public Element {
29 std::string m_path;
30 std::vector<Real> m_coords, m_normals;
31 std::vector<unsigned int> m_tris, m_solids;
32 std::vector<Real> m_vertices, m_vnormals;
33
34 Real m_units = 1e-3;
35 bool m_haveMesh = false;
36
37 void rescaleVertices();
38 void tryOpenModel();
39
40 protected:
41 virtual bool propertyChanged(std::string const &, PropertyValue const &) override;
42
43 public:
44 StlMesh(
46 std::string const &,
48 Element *parent = nullptr);
49
50 virtual ~StlMesh() override;
51
52 virtual void enterOpenGL() override;
53 virtual void renderOpenGL() override;
54 };
55
56 RZ_DECLARE_ELEMENT(StlMesh);
57}
58
59#endif // _STL_MESH_H
Definition: Element.h:393
Definition: Element.h:173
Definition: Element.h:58
Definition: ReferenceFrame.h:59
Definition: StlMesh.h:28