primitives3d.h 4.62 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* This library 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 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library 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 this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef PRIMITIVES3D_H
#define PRIMITIVES3D_H

#include <vector>

#include "Utils/os_spec.h"
#include "Geometry/transfo.h"

namespace CGoGN
{

namespace Algo
{

namespace Modelisation
{

/**
* class of geometric primitive
* It alloaw the creation of:
* - grid 3D
* - ??
* Topological creation methods are separated from embedding to
* easily allow specific embedding.
*/
template <typename PFP>
class Primitive3D
{
	typedef typename PFP::MAP MAP;
	typedef typename PFP::VEC3 EMB;
	

public:
	enum {NONE,HEXAGRID};

protected:
	/**
	* Map in which we are working
	*/
	MAP& m_map;


	typename PFP::TVEC3& m_positions;
	/**
	* Reference dart of primitive
	*/
	Dart m_dart;

	/**
	* Kind of primitive (grid, cylinder,  
	*/
	int m_kind;

	/**
	* Table of vertex darts (one dart per vertex)
	* Order depend on primitive kind
	*/
	std::vector<Dart> m_tableVertDarts;

	/**
	* numbers that defined the subdivision of  primitives
	*/
	int m_nx;

	int m_ny;

	int m_nz;

	/**
	* Create a 3D grid 
	* @param nx nb of cubes in x
	* @return the dart of vertex (0,0,0) direction z
	*/	
	Dart HexaGrid1Topo(int nx);

	/**
	* Create a 3D grid 
	* @param nx nb of cubes in x
	* @param ny nb of cubes in y
	* @return the dart of vertex (0,0,0) direction z
	*/	
	Dart HexaGrid2Topo(int nx, int ny);

108
	Dart createHexa();
Pierre Kraemer's avatar
Pierre Kraemer committed
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
141
142
143


public:

	/**
	* Constructor
	* @param map the map in which we want to work
	*/
	Primitive3D(MAP& map, typename PFP::TVEC3& position):
	 m_map(map),
	 m_positions(position),
	 m_kind(NONE),
	 m_nx(-1), m_ny(-1), m_nz(-1) {}

	/**
	* get the table of darts (one per vertex)
	*/
	const std::vector<Dart>& getVertexDarts() { return m_tableVertDarts;}

	/*
	* get the reference dart
	*/
	Dart getDart() { return m_dart;}


	/**
	* transform the primitive with transformation matrice
	* @param matrice 
	*/
	void transform(const Geom::Matrix44f& matrice);

	/**
	* mark all darts of the primitive 
	* @param m the marker to use 
	*/
Pierre Kraemer's avatar
Pierre Kraemer committed
144
//	void mark(Mark m);
Pierre Kraemer's avatar
Pierre Kraemer committed
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198


	/**
	* Create a 3D grid 
	* @param nx nb of cubes in x
	* @param ny nb of cubes in y
	* @param nz nb of cubes in z
	* @return the dart of vertex (0,0,0) direction z
	*/	
	Dart hexaGrid_topo(int nx, int ny, int nz);


	/**
	* embed the topo grid primitive 
	* Grid has size x,y,z centered on 0
	* @param x
	* @param y 
	* @param z
	* @param positions handler of position attribute
	*/
	void embedHexaGrid( float x, float y, float z);

	/**
	* Create a 3D grid 
	* @param nx nb of cubes in x
	* @param ny nb of cubes in y
	* @param nz nb of cubes in z
	* @return the dart of vertex (0,0,0) direction z
	*/	
// 	Dart prismGrid_topo(int nx,int nz);


	/**
	* embed the topo grid primitive 
	* Grid has size x,y,z centered on 0
	* @param x
	* @param y 
	* @param z
	*/
// 	void embedPrismGrid( float x, float z);



};

}//end namespace
}//end namespace
}//end namespace



#include "primitives3d.hpp"

#endif