File: mesh.h

package info (click to toggle)
lsp-plugins 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,856 kB
  • sloc: cpp: 427,831; xml: 57,779; makefile: 9,961; php: 1,005; sh: 18
file content (140 lines) | stat: -rw-r--r-- 5,631 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
 * Copyright (C) 2021 Linux Studio Plugins Project <https://lsp-plug.in/>
 *           (C) 2021 Vladimir Sadovnikov <sadko4u@gmail.com>
 *
 * This file is part of lsp-dsp-units
 * Created on: 9 авг. 2021 г.
 *
 * lsp-dsp-units is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * lsp-dsp-units is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with lsp-dsp-units. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LSP_PLUG_IN_DSP_UNITS_3D_RT_MESH_H_
#define LSP_PLUG_IN_DSP_UNITS_3D_RT_MESH_H_

#include <lsp-plug.in/dsp-units/version.h>
#include <lsp-plug.in/dsp-units/3d/rt/types.h>
#include <lsp-plug.in/dsp-units/3d/Allocator3D.h>
#include <lsp-plug.in/dsp-units/3d/Object3D.h>

namespace lsp
{
    namespace dspu
    {
        namespace rt
        {
            typedef struct LSP_DSP_UNITS_PUBLIC mesh_t
            {
                private:
                    mesh_t(const mesh_t &);
                    mesh_t & operator = (const mesh_t &);

                public:
                    Allocator3D<rtm::vertex_t>      vertex;     // Collection of vertexes
                    Allocator3D<rtm::edge_t>        edge;       // Collection of edges
                    Allocator3D<rtm::triangle_t>    triangle;   // Collection of triangles

                public:
                    explicit mesh_t();
                    ~mesh_t();

                protected:
                    bool            validate_list(rtm::edge_t *e);
                    static ssize_t  linked_count(rtm::triangle_t *t, rtm::edge_t *e);

                    status_t        split_edge(rtm::edge_t* e, rtm::vertex_t* sp);
                    status_t        split_triangle(rtm::triangle_t* t, rtm::vertex_t* sp);
                    static bool     unlink_triangle(rtm::triangle_t *t, rtm::edge_t *e);
                    static status_t arrange_triangle(rtm::triangle_t *ct, rtm::edge_t *e);

                public:
                    /**
                     * Clear mesh: clear underlying structures
                     */
                    inline void     clear()
                    {
                        vertex.clear();
                        edge.clear();
                        triangle.clear();
                    }

                    /**
                     * Flush mesh: clear underlying structures and release memory
                     */
                    inline void     flush()
                    {
                        vertex.flush();
                        edge.flush();
                        triangle.flush();
                    }

                    /**
                     * Swap internal mesh contents with another context
                     * @param dst destination context to perform swap
                     */
                    inline void     swap(mesh_t *dst)
                    {
                        vertex.swap(&dst->vertex);
                        edge.swap(&dst->edge);
                        triangle.swap(&dst->triangle);
                    }

                    /**
                     * Add object to context
                     * @param obj object to add
                     * @param oid unique id to identify the object
                     * @param material material that describes behaviour of reflected rays
                     * @return status of operation
                     */
                    inline status_t add_object(Object3D *obj, ssize_t oid, rt::material_t *material)
                    {
                        return add_object(obj, oid, obj->matrix(), material);
                    }

                    /**
                     * Add object to context
                     * @param obj object to add
                     * @param oid unique id to identify the object
                     * @param transform transformation matrix to apply to object
                     * @param material material that describes behaviour of reflected rays
                     * @return status of operation
                     */
                    status_t        add_object(Object3D *obj, ssize_t oid, const dsp::matrix3d_t *transform, rt::material_t *material);

                    /**
                     * Remove conflicts between triangles, does not modify the 'itag' field of
                     * triangle, so it can be used to identify objects of the scene
                     *
                     * @return status of operation
                     */
                    status_t        solve_conflicts();

                    /**
                     * Check consistency of the context: that all stored pointers are valid
                     * @return true if context is in valid state
                     */
                    bool            validate();

                    /**
                     * Copy all data from the source mesh
                     * @param src source mesh to copy
                     * @return status of operation
                     */
                    status_t        copy(mesh_t *src);
            } mesh_t;
        } // namespace rt
    } // namespace dspu
} // namespace lsp


#endif /* LSP_PLUG_IN_DSP_UNITS_3D_RT_MESH_H_ */