Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8310327
FROG_Element_Primitive_FiveSidedPolygon.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
FROG_Element_Primitive_FiveSidedPolygon.h
View Options
#ifndef _FROG_ELEMENT_PRIMITIVE_FIVESIDEDPOLYGON_H__
#define _FROG_ELEMENT_PRIMITIVE_FIVESIDEDPOLYGON_H__
//Code created by Maciej Zbigniew Besta
//For the TOTEM Collaboration
//Email: maciej.zbigniew.besta@cern.ch
#include
"FROG_Element_Base.h"
#include
"FROG_Primitives.h"
class
FROG_Element_Primitive_FiveSidedPolygon
:
public
FROG_Element_Base_With_DetId
{
public
:
float
P1X
;
float
P1Y
;
float
P1Z
;
float
P2X
;
float
P2Y
;
float
P2Z
;
float
P3X
;
float
P3Y
;
float
P3Z
;
float
P4X
;
float
P4Y
;
float
P4Z
;
float
P5X
;
float
P5Y
;
float
P5Z
;
virtual
bool
isCompactible
(){
return
true
;
}
static
unsigned
int
sizeOf
(){
return
FROG_Element_Base_With_DetId
::
sizeOf
()
+
15
*
sizeof
(
float
);}
FROG_Element_Primitive_FiveSidedPolygon
()
:
FROG_Element_Base_With_DetId
(
C_PRIMITIVE_FIVESIDEDPOLYGON
){}
FROG_Element_Primitive_FiveSidedPolygon
(
unsigned
int
detId
,
float
p1X
,
float
p1Y
,
float
p1Z
,
float
p2X
,
float
p2Y
,
float
p2Z
,
float
p3X
,
float
p3Y
,
float
p3Z
,
float
p4X
,
float
p4Y
,
float
p4Z
,
float
p5X
,
float
p5Y
,
float
p5Z
)
:
FROG_Element_Base_With_DetId
(
C_PRIMITIVE_FIVESIDEDPOLYGON
,
detId
),
P1X
(
p1X
),
P1Y
(
p1Y
),
P1Z
(
p1Z
),
P2X
(
p2X
),
P2Y
(
p2Y
),
P2Z
(
p2Z
),
P3X
(
p3X
),
P3Y
(
p3Y
),
P3Z
(
p3Z
),
P4X
(
p4X
),
P4Y
(
p4Y
),
P4Z
(
p4Z
),
P5X
(
p5X
),
P5Y
(
p5Y
),
P5Z
(
p5Z
)
{
size_
=
sizeOf
();
}
unsigned
read
(
FILE
*
pFile
,
unsigned
int
toRead
=
0
)
{
unsigned
int
read
=
0
;
read
+=
fread
(
&
detId_
,
1
,
sizeof
(
detId_
)
,
pFile
);
read
+=
fread
(
&
P1X
,
1
,
sizeof
(
P1X
)
,
pFile
);
read
+=
fread
(
&
P1Y
,
1
,
sizeof
(
P1Y
)
,
pFile
);
read
+=
fread
(
&
P1Z
,
1
,
sizeof
(
P1Z
)
,
pFile
);
read
+=
fread
(
&
P2X
,
1
,
sizeof
(
P2X
)
,
pFile
);
read
+=
fread
(
&
P2Y
,
1
,
sizeof
(
P2Y
)
,
pFile
);
read
+=
fread
(
&
P2Z
,
1
,
sizeof
(
P2Z
)
,
pFile
);
read
+=
fread
(
&
P3X
,
1
,
sizeof
(
P3X
)
,
pFile
);
read
+=
fread
(
&
P3Y
,
1
,
sizeof
(
P3Y
)
,
pFile
);
read
+=
fread
(
&
P3Z
,
1
,
sizeof
(
P3Z
)
,
pFile
);
read
+=
fread
(
&
P4X
,
1
,
sizeof
(
P4X
)
,
pFile
);
read
+=
fread
(
&
P4Y
,
1
,
sizeof
(
P4Y
)
,
pFile
);
read
+=
fread
(
&
P4Z
,
1
,
sizeof
(
P4Z
)
,
pFile
);
read
+=
fread
(
&
P5X
,
1
,
sizeof
(
P5X
)
,
pFile
);
read
+=
fread
(
&
P5Y
,
1
,
sizeof
(
P5Y
)
,
pFile
);
read
+=
fread
(
&
P5Z
,
1
,
sizeof
(
P5Z
)
,
pFile
);
return
read
;
}
virtual
void
write
()
{
size_
=
sizeOf
();
data_
=
new
unsigned
char
[
size_
-
6
];
data_
=
FillBuffer
(
data_
,
&
detId_
,
sizeof
(
detId_
));
data_
=
FillBuffer
(
data_
,
&
P1X
,
sizeof
(
P1X
));
data_
=
FillBuffer
(
data_
,
&
P1Y
,
sizeof
(
P1Y
));
data_
=
FillBuffer
(
data_
,
&
P1Z
,
sizeof
(
P1Z
));
data_
=
FillBuffer
(
data_
,
&
P2X
,
sizeof
(
P2X
));
data_
=
FillBuffer
(
data_
,
&
P2Y
,
sizeof
(
P2Y
));
data_
=
FillBuffer
(
data_
,
&
P2Z
,
sizeof
(
P2Z
));
data_
=
FillBuffer
(
data_
,
&
P3X
,
sizeof
(
P3X
));
data_
=
FillBuffer
(
data_
,
&
P3Y
,
sizeof
(
P3Y
));
data_
=
FillBuffer
(
data_
,
&
P3Z
,
sizeof
(
P3Z
));
data_
=
FillBuffer
(
data_
,
&
P4X
,
sizeof
(
P4X
));
data_
=
FillBuffer
(
data_
,
&
P4Y
,
sizeof
(
P4Y
));
data_
=
FillBuffer
(
data_
,
&
P4Z
,
sizeof
(
P4Z
));
data_
=
FillBuffer
(
data_
,
&
P5X
,
sizeof
(
P5X
));
data_
=
FillBuffer
(
data_
,
&
P5Y
,
sizeof
(
P5Y
));
data_
=
FillBuffer
(
data_
,
&
P5Z
,
sizeof
(
P5Z
));
data_
=
(
unsigned
char
*
)((
unsigned
long
)
data_
-
(
size_
-
6
)
);
}
#ifdef FROG_OPENGL
void
Object_SmartDisplay
(){
GLfloat
*
positionData
=
NULL
;
GLfloat
*
normalData
=
NULL
;
if
(
DisplayList_
){
glCallList
(
DisplayList_
);
return
;
}
if
(
!
VBO_Vertices_
){
VBO_VerticesN_
=
10
;
positionData
=
new
GLfloat
[
3
*
VBO_VerticesN_
];
normalData
=
new
GLfloat
[
3
*
VBO_VerticesN_
];
// FIRST FACE
positionData
[
0
]
=
P1X
;
positionData
[
1
]
=
P1Y
;
positionData
[
2
]
=
P1Z
;
positionData
[
3
]
=
P2X
;
positionData
[
4
]
=
P2Y
;
positionData
[
5
]
=
P2Z
;
positionData
[
6
]
=
P3X
;
positionData
[
7
]
=
P3Y
;
positionData
[
8
]
=
P3Z
;
positionData
[
9
]
=
P4X
;
positionData
[
10
]
=
P4Y
;
positionData
[
11
]
=
P4Z
;
positionData
[
12
]
=
P5X
;
positionData
[
13
]
=
P5Y
;
positionData
[
14
]
=
P5Z
;
// SECOND FACE
positionData
[
15
]
=
P1X
;
positionData
[
16
]
=
P1Y
;
positionData
[
17
]
=
P1Z
;
positionData
[
18
]
=
P5X
;
positionData
[
19
]
=
P5Y
;
positionData
[
20
]
=
P5Z
;
positionData
[
21
]
=
P4X
;
positionData
[
22
]
=
P4Y
;
positionData
[
23
]
=
P4Z
;
positionData
[
24
]
=
P3X
;
positionData
[
25
]
=
P3Y
;
positionData
[
26
]
=
P3Z
;
positionData
[
27
]
=
P2X
;
positionData
[
28
]
=
P2Y
;
positionData
[
29
]
=
P2Z
;
//Compute Cloud Vertice BaryCenter
GetVerticesArrayBarycenter
(
positionData
,
VBO_VerticesN_
,
obj_pos_x
,
obj_pos_y
,
obj_pos_z
);
//COmpute Normals
SetNormalArray
(
positionData
,
normalData
,
0
,
10
,
5
);
if
(
FROG
::
Support_VBO_
){
//Use VBO
glGenBuffersARB
(
1
,
&
VBO_Vertices_
);
// Get A Valid Name
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Vertices_
);
// Bind The Buffer
glBufferDataARB
(
GL_ARRAY_BUFFER_ARB
,
3
*
VBO_VerticesN_
*
sizeof
(
float
),
positionData
,
GL_STATIC_DRAW_ARB
);
glGenBuffersARB
(
1
,
&
VBO_Normals_
);
// Get A Valid Name
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Normals_
);
// Bind The Buffer
glBufferDataARB
(
GL_ARRAY_BUFFER_ARB
,
3
*
VBO_VerticesN_
*
sizeof
(
float
),
normalData
,
GL_STATIC_DRAW_ARB
);
delete
[]
normalData
;
delete
[]
positionData
;
}
}
if
(
!
FROG
::
Support_VBO_
){
//VBO not Available --> Use DisplayList
DisplayList_
=
glGenListsOptimized
(
1
);
glNewList
(
DisplayList_
,
GL_COMPILE_AND_EXECUTE
);
}
glEnableClientState
(
GL_VERTEX_ARRAY
);
glEnableClientState
(
GL_NORMAL_ARRAY
);
if
(
FROG
::
Support_VBO_
){
//Use VBO
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Normals_
);
glNormalPointer
(
GL_FLOAT
,
0
,
(
char
*
)
NULL
);
glBindBufferARB
(
GL_ARRAY_BUFFER_ARB
,
VBO_Vertices_
);
glVertexPointer
(
3
,
GL_FLOAT
,
0
,
(
char
*
)
NULL
);
}
else
{
//VBO not Available --> Use DisplayList
glNormalPointer
(
GL_FLOAT
,
0
,
normalData
);
glVertexPointer
(
3
,
GL_FLOAT
,
0
,
positionData
);
}
glDrawArrays
(
GL_POLYGON
,
0
,
5
);
glDrawArrays
(
GL_POLYGON
,
5
,
5
);
glDisableClientState
(
GL_NORMAL_ARRAY
);
glDisableClientState
(
GL_VERTEX_ARRAY
);
if
(
!
FROG
::
Support_VBO_
){
glEndList
();
delete
[]
normalData
;
delete
[]
positionData
;
}
}
virtual
void
display
(
bool
UseDisplayList
=
true
,
float
*
color
=
NULL
){
if
(
!
style_
)
init
();
glLineWidth
(
style_
->
thickness_
);
if
(
color
){
glColor4fv
(
color
);}
else
{
glColor4fv
(
style_
->
color_
);}
glLoadName
(
detId_
);
glPushAttrib
(
GL_LINE_BIT
);
glLineWidth
(
style_
->
thickness_
);
Object_SmartDisplay
();
glPopAttrib
();
}
#endif
virtual
void
init
(){
if
(
style_
)
return
;
init_standard
();
//Decide if this objects has to be render now or later
if
(
NeedPostRendering
())
return
;
((
FROG_ReadCards
*
)
FROG
::
Card_
)
->
GetColor
(
style_
->
color_
,
"Id_%i_Color"
,
detId_
);
((
FROG_ReadCards
*
)
FROG
::
Card_
)
->
GetFloat
(
&
style_
->
thickness_
,
"Id_%i_Thickness"
,
detId_
);
}
};
#endif
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sat, Dec 21, 6:08 PM (9 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4023740
Default Alt Text
FROG_Element_Primitive_FiveSidedPolygon.h (7 KB)
Attached To
rFROGSVN frogsvn
Event Timeline
Log In to Comment