Page MenuHomeHEPForge

FROG_Element_Primitive_Cube.h
No OneTemporary

FROG_Element_Primitive_Cube.h

#ifndef _FROG_ELEMENT_PRIMITIVE_CUBE_H__
#define _FROG_ELEMENT_PRIMITIVE_CUBE_H__
#include "FROG_Element_Base.h"
class FROG_Element_Primitive_Cube : public FROG_Element_Base_With_DetId {
public :
float PosX; float PosY; float PosZ;
float WidthX; float WidthY; float WidthZ;
float LengthX; float LengthY; float LengthZ;
float ThickX; float ThickY; float ThickZ;
FROG_Objects* frogObjects_;
virtual bool isCompactible(){ return true; }
static unsigned int sizeOf(){ return FROG_Element_Base_With_DetId::sizeOf() + 12*sizeof(float);}
FROG_Element_Primitive_Cube(
unsigned int detId,
float posX, float posY, float posZ,
float widthX, float widthY, float widthZ,
float lengthX, float lengthY, float lengthZ,
float thickX, float thickY, float thickZ) :
FROG_Element_Base_With_DetId(C_PRIMITIVE_CUBE,detId),
PosX(posX), PosY(posY), PosZ(posZ),
WidthX(widthX), WidthY(widthY), WidthZ(widthZ),
LengthX(lengthX), LengthY(lengthY), LengthZ(lengthZ),
ThickX(thickX), ThickY(thickY), ThickZ(thickZ)
{
size_ = sizeOf();
}
FROG_Element_Primitive_Cube(FILE* pFile) : FROG_Element_Base_With_DetId(C_PRIMITIVE_CUBE)
{
size_ = sizeOf();
fread(&detId_ ,sizeof(detId_) ,1,pFile);
fread(&PosX ,sizeof(PosX) ,1,pFile);
fread(&PosY ,sizeof(PosY) ,1,pFile);
fread(&PosZ ,sizeof(PosZ) ,1,pFile);
fread(&WidthX ,sizeof(WidthX) ,1,pFile);
fread(&WidthY ,sizeof(WidthY) ,1,pFile);
fread(&WidthZ ,sizeof(WidthZ) ,1,pFile);
fread(&LengthX ,sizeof(LengthX) ,1,pFile);
fread(&LengthY ,sizeof(LengthY) ,1,pFile);
fread(&LengthZ ,sizeof(LengthZ) ,1,pFile);
fread(&ThickX ,sizeof(ThickX) ,1,pFile);
fread(&ThickY ,sizeof(ThickY) ,1,pFile);
fread(&ThickZ ,sizeof(ThickZ) ,1,pFile);
}
virtual void write () {
size_ = sizeOf();
data_ = new unsigned char[size_-6];
data_ = FillBuffer( data_, &detId_, sizeof(detId_));
data_ = FillBuffer( data_, &PosX, sizeof(PosX));
data_ = FillBuffer( data_, &PosY, sizeof(PosY));
data_ = FillBuffer( data_, &PosZ, sizeof(PosZ));
data_ = FillBuffer( data_, &WidthX, sizeof(WidthX));
data_ = FillBuffer( data_, &WidthY, sizeof(WidthY));
data_ = FillBuffer( data_, &WidthZ, sizeof(WidthZ));
data_ = FillBuffer( data_, &LengthX, sizeof(LengthX));
data_ = FillBuffer( data_, &LengthY, sizeof(LengthY));
data_ = FillBuffer( data_, &LengthZ, sizeof(LengthZ));
data_ = FillBuffer( data_, &ThickX, sizeof(ThickX));
data_ = FillBuffer( data_, &ThickY, sizeof(ThickY));
data_ = FillBuffer( data_, &ThickZ, sizeof(ThickZ));
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_ );
glBegin (GL_QUADS);
glVertex3d (PosX+WidthX +LengthX+ThickX,PosY+WidthY +LengthY+ThickY,PosZ+WidthZ +LengthZ+ThickZ); //+++
glVertex3d (PosX-WidthX +LengthX+ThickX,PosY-WidthY +LengthY+ThickY,PosZ-WidthZ +LengthZ+ThickZ); //-++
glVertex3d (PosX-WidthX -LengthX+ThickX,PosY-WidthY -LengthY+ThickY,PosZ-WidthZ -LengthZ+ThickZ); //--+
glVertex3d (PosX+WidthX -LengthX+ThickX,PosY+WidthY -LengthY+ThickY,PosZ+WidthZ -LengthZ+ThickZ); //+-+
glVertex3d (PosX+WidthX +LengthX-ThickX,PosY+WidthY +LengthY-ThickY,PosZ+WidthZ +LengthZ-ThickZ); //++-
glVertex3d (PosX+WidthX -LengthX-ThickX,PosY+WidthY -LengthY-ThickY,PosZ+WidthZ -LengthZ-ThickZ); //+--
glVertex3d (PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ); //---
glVertex3d (PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ); //-+-
glVertex3d (PosX+WidthX +LengthX+ThickX,PosY+WidthY +LengthY+ThickY,PosZ+WidthZ +LengthZ+ThickZ); //+++
glVertex3d (PosX+WidthX +LengthX-ThickX,PosY+WidthY +LengthY-ThickY,PosZ+WidthZ +LengthZ-ThickZ); //++-;
glVertex3d (PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ); //-+-
glVertex3d (PosX-WidthX +LengthX+ThickX,PosY-WidthY +LengthY+ThickY,PosZ-WidthZ +LengthZ+ThickZ); //-++
glVertex3d (PosX+WidthX -LengthX+ThickX,PosY+WidthY -LengthY+ThickY,PosZ+WidthZ -LengthZ+ThickZ); //+-+
glVertex3d (PosX-WidthX -LengthX+ThickX,PosY-WidthY -LengthY+ThickY,PosZ-WidthZ -LengthZ+ThickZ); //--+
glVertex3d (PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ); //---
glVertex3d (PosX+WidthX -LengthX-ThickX,PosY+WidthY -LengthY-ThickY,PosZ+WidthZ -LengthZ-ThickZ); //+--
glVertex3d (PosX+WidthX +LengthX+ThickX,PosY+WidthY +LengthY+ThickY,PosZ+WidthZ +LengthZ+ThickZ); //+++
glVertex3d (PosX+WidthX -LengthX+ThickX,PosY+WidthY -LengthY+ThickY,PosZ+WidthZ -LengthZ+ThickZ); //+-+
glVertex3d (PosX+WidthX -LengthX-ThickX,PosY+WidthY -LengthY-ThickY,PosZ+WidthZ -LengthZ-ThickZ); //+--
glVertex3d (PosX+WidthX +LengthX-ThickX,PosY+WidthY +LengthY-ThickY,PosZ+WidthZ +LengthZ-ThickZ); //++-
glVertex3d (PosX-WidthX +LengthX+ThickX,PosY-WidthY +LengthY+ThickY,PosZ-WidthZ +LengthZ+ThickZ); //-++
glVertex3d (PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ); //-+-
glVertex3d (PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ); //---
glVertex3d (PosX-WidthX -LengthX+ThickX,PosY-WidthY -LengthY+ThickY,PosZ-WidthZ -LengthZ+ThickZ); //--+
glEnd();
}
#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

File Metadata

Mime Type
text/x-c++
Expires
Mon, Jan 20, 9:24 PM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242468
Default Alt Text
FROG_Element_Primitive_Cube.h (6 KB)

Event Timeline