Index: /trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Cone.h
===================================================================
--- /trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Cone.h	(revision 102)
+++ /trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Cone.h	(revision 102)
@@ -0,0 +1,141 @@
+#ifndef _FROG_ELEMENT_PRIMITIVE_CONE_H__
+#define _FROG_ELEMENT_PRIMITIVE_CONE_H__
+
+#include "FROG_Element_Base.h"
+
+class FROG_Element_Primitive_Cone : public FROG_Element_Base_With_DetId {
+public :
+	float Radius;		 
+	float PosX;			float PosY;    float PosZ;	
+	float LengthX;		float LengthY; float LengthZ;
+	unsigned short NPhi;unsigned char Endcap; 
+	FROG_Objects*  frogObjects_;
+	
+	virtual bool isCompactible(){ return true; }
+
+	static unsigned int sizeOf(){ return FROG_Element_Base_With_DetId::sizeOf() + 7*sizeof(float) + sizeof(unsigned short) + sizeof(unsigned char);}
+
+	FROG_Element_Primitive_Cone(
+	unsigned int detId,	float radius,
+	float posX,			float posY,    float posZ,
+	float lengthX,		float lengthY, float lengthZ,
+	unsigned short nPhi=10, unsigned char endcap=0) :
+	FROG_Element_Base_With_DetId(C_PRIMITIVE_CONE,detId),	
+	Radius(radius),
+	PosX(posX),			PosY(posY),			PosZ(posZ),
+	LengthX(lengthX),	LengthY(lengthY),	LengthZ(lengthZ),
+	NPhi(nPhi), Endcap(endcap)
+	{    
+		size_ = sizeOf();
+	}
+
+	FROG_Element_Primitive_Cone(FILE* pFile) : FROG_Element_Base_With_DetId(C_PRIMITIVE_CONE)
+	{   
+		size_ = sizeOf();
+		fread(&detId_           ,sizeof(detId_)			 ,1,pFile);				
+		fread(&Radius           ,sizeof(Radius)          ,1,pFile);
+		fread(&PosX             ,sizeof(PosX)            ,1,pFile);
+		fread(&PosY             ,sizeof(PosY)            ,1,pFile);
+		fread(&PosZ             ,sizeof(PosZ)            ,1,pFile);
+		fread(&LengthX          ,sizeof(LengthX)         ,1,pFile);
+		fread(&LengthY          ,sizeof(LengthY)         ,1,pFile);
+		fread(&LengthZ          ,sizeof(LengthZ)         ,1,pFile);
+		fread(&NPhi             ,sizeof(NPhi)            ,1,pFile);		
+		fread(&Endcap           ,sizeof(Endcap)          ,1,pFile);		
+	}
+
+	virtual void write () {
+		size_ = sizeOf();
+		data_ = new unsigned char[size_-6];
+		data_ = FillBuffer(	data_, &detId_,				sizeof(detId_));
+		data_ = FillBuffer(	data_, &Radius,				sizeof(Radius));
+		data_ = FillBuffer( data_, &PosX,				sizeof(PosX));
+		data_ = FillBuffer( data_, &PosY,				sizeof(PosY));
+		data_ = FillBuffer( data_, &PosZ,				sizeof(PosZ));
+		data_ = FillBuffer( data_, &LengthX,			sizeof(LengthX));
+		data_ = FillBuffer( data_, &LengthY,			sizeof(LengthY));
+		data_ = FillBuffer( data_, &LengthZ,			sizeof(LengthZ));
+		data_ = FillBuffer( data_, &NPhi,				sizeof(NPhi));		
+		data_ = FillBuffer( data_, &Endcap,				sizeof(Endcap));		
+		data_ = (unsigned char*)((unsigned long)data_ - (size_-6) );		
+	}
+
+	#ifdef FROG_OPENGL
+	virtual void display(bool UseDisplayList=true, float* color=NULL){
+		// first Init Colors & Style!
+		init(NULL);
+
+		glLineWidth(style_->thickness_);
+        if(color){glColor4fv(color);}else{glColor4fv(style_->color_);}
+		glLoadName( detId_ );
+		
+		double dphi  = 6.283185307179586476925286766559 /NPhi;
+		double L     = sqrt(LengthX*LengthX+LengthY*LengthY+LengthZ*LengthZ);
+
+		double rotTheta = 57.29*asin(LengthY/L);
+		double rotPhi   = 57.29*asin(LengthX/sqrt(LengthX*LengthX+LengthZ*LengthZ));
+			
+		glPushMatrix();		
+		glTranslatef(PosX,PosY,PosZ);		
+		glRotatef(rotPhi  ,0,1,0);
+		glRotatef(rotTheta,1,0,0);
+                double theta=atan(L/Radius);
+		glBegin (GL_QUADS); 			
+			for(double phi=0; phi<=6.2831;phi+=dphi){	
+				glNormal3f (       cos(phi)      ,sin(phi)              ,0);
+				glVertex3f (Radius*cos(phi)      ,Radius*sin(phi)	,-L*0.5);		// BARREL OUTER FACE
+				glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi)	,-L*0.5); 				
+				glVertex3f (0 ,0  , L*0.5); 
+				glVertex3f (0 ,0  , L*0.5); 				
+			}
+		glEnd(); 
+		
+		
+		if(Endcap>1){
+			for(double phi=0; phi<=6.2831;phi+=dphi){							
+				glNormal3f (0,0,-1);
+                                glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi)  , L*-0.5);       // ENDCAP1 INNER FACE
+                                glVertex3f (Radius*cos(phi)              ,Radius*sin(phi)               , L*-0.5);
+                                glVertex3f (0                                    ,0                                             , L*-0.5);
+			}
+		}
+		glEnd(); 
+
+
+		if(Endcap<2){// we have to draw internal face because cylinder is open
+			glBegin (GL_TRIANGLES); 
+			for(double phi=0; phi<=6.2831;phi+=dphi){	
+				glNormal3f (0,0,-1);
+				glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi)	, L*0.5);	// ENDCAP1 INNER FACE
+				glVertex3f (Radius*cos(phi)		 ,Radius*sin(phi)		, L*0.5);
+				glVertex3f (0					 ,0						, L*0.5);
+			}
+			glEnd(); 
+
+			glBegin (GL_QUADS); 			
+				for(double phi=0; phi<=6.2831;phi+=dphi){		
+					glNormal3f (      -cos(phi)      ,-      sin(phi)       ,0);					
+					glVertex3f (Radius*cos(phi)		 ,Radius*sin(phi)		,-L*0.5);		// BARREL OUTER FACE
+					glVertex3f (0		 ,0		, L*0.5); 
+					glVertex3f (0 ,0 , L*0.5); 
+					glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi)	,-L*0.5); 					
+				}
+			glEnd(); 
+		}
+		glPopMatrix();
+	}
+	#endif
+
+	virtual void init(void* frogObjects){
+		if(frogObjects!=NULL){
+			frogObjects_ = (FROG_Objects*) frogObjects;			
+		}else if(frogObjects==NULL && frogObjects_ != NULL){
+			if(mother_ != NULL && mother_->style_ !=NULL){		style_ = new FROG_Objects_Style(mother_->style_);
+			}else{												style_ = new FROG_Objects_Style();	}	
+
+			frogObjects_->frogCard_->GetColor( style_->color_     ,"Id_%i_Color"		,detId_);
+			frogObjects_->frogCard_->GetFloat(&style_->thickness_ ,"Id_%i_Thickness"	,detId_);
+		}
+	}
+};
+#endif
