~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/bsp/intern/BSP_CSGMesh.h

  • Committer: Reinhard Tartler
  • Date: 2014-05-31 01:50:05 UTC
  • mfrom: (14.2.27 sid)
  • Revision ID: siretart@tauware.de-20140531015005-ml6druahuj82nsav
mergeĀ fromĀ debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * ***** BEGIN GPL LICENSE BLOCK *****
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License
6
 
 * as published by the Free Software Foundation; either version 2
7
 
 * of the License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software Foundation,
16
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 
 *
18
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
 
 * All rights reserved.
20
 
 *
21
 
 * The Original Code is: all of this file.
22
 
 *
23
 
 * Contributor(s): none yet.
24
 
 *
25
 
 * ***** END GPL LICENSE BLOCK *****
26
 
 */
27
 
 
28
 
/** \file bsp/intern/BSP_CSGMesh.h
29
 
 *  \ingroup bsp
30
 
 */
31
 
 
32
 
 
33
 
#ifndef __BSP_CSGMESH_H__
34
 
#define __BSP_CSGMESH_H__
35
 
 
36
 
#include "BSP_MeshPrimitives.h"
37
 
#include "MEM_SmartPtr.h"
38
 
#include "MEM_RefCountPtr.h"
39
 
#include "MEM_NonCopyable.h"
40
 
#include "../extern/CSG_BooleanOps.h"
41
 
 
42
 
 
43
 
class MT_Plane3;
44
 
 
45
 
class BSP_CSGMesh : 
46
 
        public MEM_NonCopyable, 
47
 
        public MEM_RefCountable
48
 
{
49
 
 
50
 
public :
51
 
 
52
 
        static
53
 
                BSP_CSGMesh *
54
 
        New(
55
 
        );
56
 
 
57
 
                bool
58
 
        SetVertices(
59
 
                std::vector<BSP_MVertex> *verts
60
 
        );
61
 
 
62
 
                void
63
 
        AddPolygon(
64
 
                const int * verts,
65
 
                int num_verts
66
 
        );      
67
 
 
68
 
        // assumes that the face already has a plane equation
69
 
                void
70
 
        AddPolygon(
71
 
                const BSP_MFace &face
72
 
        );
73
 
 
74
 
 
75
 
        // Allocate and build the mesh edges.
76
 
        ////////////////////////////////////
77
 
 
78
 
                bool
79
 
        BuildEdges(
80
 
        );
81
 
 
82
 
        // Clean the mesh of edges. and edge pointers
83
 
        // This removes the circular connectivity information
84
 
        /////////////////////////////////////////////
85
 
 
86
 
                void
87
 
        DestroyEdges(
88
 
        );
89
 
 
90
 
        // return a new separate copy of the 
91
 
        // mesh allocated on the heap.
92
 
 
93
 
                BSP_CSGMesh *
94
 
        NewCopy(
95
 
        ) const;
96
 
        
97
 
 
98
 
        // Reverse the winding order of every polygon 
99
 
        // in the mesh and swap the planes around.
100
 
 
101
 
                void
102
 
        Invert(
103
 
        );
104
 
 
105
 
 
106
 
        // geometry access
107
 
        //////////////////
108
 
 
109
 
                std::vector<BSP_MVertex> &
110
 
        VertexSet(
111
 
        ) const;
112
 
                std::vector<BSP_MFace> &
113
 
        FaceSet(
114
 
        ) const;
115
 
 
116
 
                std::vector<BSP_MEdge> &
117
 
        EdgeSet(
118
 
        ) const;
119
 
 
120
 
        ~BSP_CSGMesh(
121
 
        );
122
 
 
123
 
        // local geometry queries.
124
 
        /////////////////////////
125
 
 
126
 
        // face queries
127
 
        ///////////////
128
 
 
129
 
                void
130
 
        FaceVertices(
131
 
                const BSP_FaceInd & f,
132
 
                std::vector<BSP_VertexInd> &output
133
 
        );
134
 
        
135
 
                void
136
 
        FaceEdges(
137
 
                const BSP_FaceInd & f,
138
 
                std::vector<BSP_EdgeInd> &output
139
 
        );      
140
 
 
141
 
        // edge queries
142
 
        ///////////////
143
 
 
144
 
                void
145
 
        EdgeVertices(
146
 
                const BSP_EdgeInd & e,
147
 
                std::vector<BSP_VertexInd> &output
148
 
        );
149
 
 
150
 
                void
151
 
        EdgeFaces(
152
 
                const BSP_EdgeInd & e,
153
 
                std::vector<BSP_FaceInd> &output
154
 
        );
155
 
 
156
 
        // vertex queries
157
 
        /////////////////
158
 
 
159
 
                void
160
 
        VertexEdges(
161
 
                const BSP_VertexInd & v,
162
 
                std::vector<BSP_EdgeInd> &output
163
 
        );
164
 
        
165
 
                void
166
 
        VertexFaces(
167
 
                const BSP_VertexInd & v,
168
 
                std::vector<BSP_FaceInd> &output
169
 
        );
170
 
 
171
 
        // Returns the edge index of the edge from v1 to v2. 
172
 
        // Does this by searching the edge sets of v1 - but not v2.
173
 
        // If you are paranoid you should check both and make sure the 
174
 
        // indices are the same. If the edge doe not exist edgeInd is empty.
175
 
 
176
 
                BSP_EdgeInd
177
 
        FindEdge(
178
 
                const BSP_VertexInd &v1,
179
 
                const BSP_VertexInd &v2
180
 
        ) const;
181
 
 
182
 
 
183
 
        /**
184
 
         * Sanity checkers
185
 
         */
186
 
 
187
 
        // make sure the edge faces have a pointer to f
188
 
 
189
 
                bool
190
 
        SC_Face(
191
 
                BSP_FaceInd f
192
 
        );
193
 
 
194
 
        /**
195
 
         * Return the face plane equation
196
 
         */
197
 
 
198
 
                MT_Plane3
199
 
        FacePlane(
200
 
                const BSP_FaceInd &fi
201
 
        )const;
202
 
 
203
 
 
204
 
        /**
205
 
         * Recompute Face plane equations.
206
 
         * essential if you have been messing with the object.
207
 
         */
208
 
 
209
 
                void
210
 
        ComputeFacePlanes(
211
 
        );
212
 
                
213
 
        /**
214
 
         * Count the number of trinagles in the mesh.
215
 
         * This is not the same as the number of polygons.
216
 
         */
217
 
 
218
 
                int
219
 
        CountTriangles(
220
 
        ) const;
221
 
 
222
 
private :
223
 
        
224
 
                void
225
 
        InsertEdge(
226
 
                const BSP_VertexInd &v1,
227
 
                const BSP_VertexInd &v2,
228
 
                const BSP_FaceInd &f,
229
 
                std::vector<BSP_EdgeInd> &new_edges
230
 
        );
231
 
 
232
 
                
233
 
        // Private to insure heap instantiation.
234
 
 
235
 
        BSP_CSGMesh(
236
 
        );
237
 
 
238
 
        std::vector<BSP_MVertex> *m_verts;
239
 
        std::vector<BSP_MFace>   *m_faces;
240
 
        std::vector<BSP_MEdge>   *m_edges;
241
 
 
242
 
        MT_Vector3 m_bbox_min;
243
 
        MT_Vector3 m_bbox_max;
244
 
 
245
 
};
246
 
 
247
 
 
248
 
#endif
249