Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
#include "G4AdvancedBrepShapeRepresentationCreator.hh"
|
||||
#include<stdio.h>
|
||||
|
||||
G4AdvancedBrepShapeRepresentationCreator
|
||||
G4AdvancedBrepShapeRepresentationCreator::csc;
|
||||
|
||||
|
||||
G4AdvancedBrepShapeRepresentationCreator::
|
||||
G4AdvancedBrepShapeRepresentationCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
|
||||
G4AdvancedBrepShapeRepresentationCreator::
|
||||
~G4AdvancedBrepShapeRepresentationCreator(){}
|
||||
|
||||
|
||||
void G4AdvancedBrepShapeRepresentationCreator::
|
||||
CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4String attrName("items");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
EntityAggregate *ea = (EntityAggregate*)Attr->ptr.a;
|
||||
|
||||
// Get parts of this shape
|
||||
G4int partCount = ea->EntryCount();
|
||||
EntityNode* en = (EntityNode*)ea->GetHead();
|
||||
|
||||
// An Advaced_BREP_Shape_Representation is made of
|
||||
// 0 or 1 G4Axis2Placement3D and
|
||||
// 1 or more Manifold_Solid_BREP
|
||||
|
||||
G4int placement = 0, nbofsolids = 0;
|
||||
G4PlacedSolidVector* placedSldV = new G4PlacedSolidVector();
|
||||
G4PlacedSolid* placedSld;
|
||||
G4BREPSolid* sld;
|
||||
STEPentity* ent;
|
||||
G4Axis2Placement3D* place;
|
||||
|
||||
// default place
|
||||
G4Axis2Placement3D* place0 = new (G4Axis2Placement3D)( G4Vector3D(1, 0, 0),
|
||||
G4Vector3D(0, 1, 0),
|
||||
G4Point3D(0, 0, 0) );
|
||||
|
||||
|
||||
for(G4int a = 0; a < partCount; a++)
|
||||
{
|
||||
ent = en->node;
|
||||
void *tmp = G4GeometryTable::CreateObject(*ent);
|
||||
|
||||
if( !strcmp(ent->EntityName(), "Axis2_Placement_3d") )
|
||||
{
|
||||
// Get placement
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
placement = 1;
|
||||
}
|
||||
else
|
||||
if( !strcmp(ent->EntityName(), "Manifold_Solid_Brep") )
|
||||
{
|
||||
// Get solid
|
||||
sld = (G4BREPSolid*)tmp;
|
||||
nbofsolids++;
|
||||
|
||||
G4int id = ent->GetFileId();
|
||||
sld->SetId(id);
|
||||
|
||||
// Create the placed solid
|
||||
if(placement)
|
||||
placedSld = new G4PlacedSolid(sld, place);
|
||||
else
|
||||
placedSld = new G4PlacedSolid(sld, place0);
|
||||
|
||||
placedSldV->append(placedSld);
|
||||
}
|
||||
|
||||
en = (EntityNode*)en->NextNode();
|
||||
}
|
||||
|
||||
// Get geometric_representation_context, but it is not used
|
||||
attrName = "context_of_items";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
createdObject = placedSldV;
|
||||
}
|
||||
|
||||
|
||||
void G4AdvancedBrepShapeRepresentationCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "G4AdvancedFaceCreator.hh"
|
||||
#include "G4CurveVector.hh"
|
||||
#include "G4CompositeCurve.hh"
|
||||
#include "G4Surface.hh"
|
||||
|
||||
G4AdvancedFaceCreator G4AdvancedFaceCreator::csc;
|
||||
|
||||
G4AdvancedFaceCreator::G4AdvancedFaceCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4AdvancedFaceCreator::~G4AdvancedFaceCreator(){}
|
||||
|
||||
void G4AdvancedFaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Surface* srf=0;
|
||||
G4int sense;
|
||||
|
||||
STEPentity* TmpEnt=0;
|
||||
G4String attrName("bounds");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
SingleLinkNode *Node = Aggr->GetHead();
|
||||
|
||||
G4int boundaryCount = Aggr->EntryCount();
|
||||
G4CurveVector* boundaryVec = new G4CurveVector;
|
||||
void *tmp;
|
||||
|
||||
for(G4int a=0; a<boundaryCount;a++)
|
||||
{
|
||||
TmpEnt = ((EntityNode*)Node)->node;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
G4CompositeCurve* pcc= new G4CompositeCurve;
|
||||
pcc->Init(*((G4CurveVector*)tmp));
|
||||
boundaryVec->insert(pcc);
|
||||
Node = Node->NextNode();
|
||||
}
|
||||
|
||||
attrName = "face_geometry";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
srf = (G4Surface*)tmp;
|
||||
|
||||
Attr = Ent.NextAttribute();
|
||||
// if(*Attr->ptr.b) // BINARY_TYPE
|
||||
// sense = 1;
|
||||
// else
|
||||
// sense = 0;
|
||||
|
||||
// Utilize the INTEGER_TYPE attribute which is 0 or 1
|
||||
sense = *Attr->ptr.i;
|
||||
|
||||
// L. Broglia
|
||||
srf->SetSameSense(sense);
|
||||
|
||||
// Now, re-calculate the normal of the plane
|
||||
srf->CalcNormal();
|
||||
|
||||
srf->SetBoundaries(boundaryVec);
|
||||
|
||||
createdObject= srf;
|
||||
}
|
||||
|
||||
void G4AdvancedFaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
#include "G4AssemblyCreator.hh"
|
||||
#include "G4Assembly.hh"
|
||||
extern void HeaderSchemaInit (Registry & reg);
|
||||
|
||||
G4AssemblyCreator G4AssemblyCreator::ci;
|
||||
|
||||
G4AssemblyCreator::G4AssemblyCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4AssemblyCreator::G4AssemblyCreator(G4String fileName, G4String readerName)
|
||||
{
|
||||
// Name of STEP file to read in, existance of file should be checked
|
||||
//here also...
|
||||
STEPfileName = fileName;
|
||||
|
||||
// define type of STEP file reader to use
|
||||
if(readerName == "NIST")
|
||||
StepReader = new G4NISTStepReader();
|
||||
//else...
|
||||
|
||||
}
|
||||
|
||||
G4AssemblyCreator::~G4AssemblyCreator()
|
||||
{
|
||||
delete StepReader;
|
||||
}
|
||||
|
||||
|
||||
void G4AssemblyCreator::ReadStepFile()
|
||||
{
|
||||
StepReader->ReadSTEPFile(STEPfileName);
|
||||
instanceManager = StepReader->GetInstanceManager();
|
||||
}
|
||||
|
||||
void G4AssemblyCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Advanced_Brep_Shape_Representation are created into
|
||||
// Context_Dependent_Shape_Representation and
|
||||
// Shape_Definition_Representation
|
||||
G4int AdvancedBrepShapes = instanceManager.EntityKeywordCount
|
||||
("Advanced_Brep_Shape_Representation");
|
||||
|
||||
|
||||
G4int ConDepShapes = instanceManager.EntityKeywordCount
|
||||
("Context_Dependent_Shape_Representation");
|
||||
|
||||
G4int ShapeDefReps = instanceManager.EntityKeywordCount
|
||||
("Shape_Definition_Representation");
|
||||
|
||||
G4int instanceCount = instanceManager.InstanceCount();
|
||||
|
||||
STEPentity* ent=0;
|
||||
index = 0;
|
||||
int tmpindex;
|
||||
|
||||
void *tmp = 0;
|
||||
G4PlacedSolidVector* psv = new G4PlacedSolidVector();
|
||||
G4PlacedSolid* ps = new G4PlacedSolid();
|
||||
G4int a;
|
||||
|
||||
// L. Broglia
|
||||
// Total assumption !
|
||||
|
||||
if(ConDepShapes>0)
|
||||
{
|
||||
G4cout<<"\n\n Creating the Context_Dependent_Shape_Representation"<<endl;
|
||||
index = 0;
|
||||
|
||||
for( a=0; a< ConDepShapes; a++)
|
||||
{
|
||||
G4cout<<"loop "<<a+1<<" of "<<ConDepShapes<<endl;
|
||||
|
||||
// Be careful, tmpindex not correspond to STEPfile_id !
|
||||
tmpindex =
|
||||
instanceManager.GetIndex("Context_Dependent_Shape_Representation",
|
||||
index );
|
||||
|
||||
ent = instanceManager.GetSTEPentity(tmpindex);
|
||||
|
||||
if(ent!= ENTITY_NULL)
|
||||
{
|
||||
tmp =G4GeometryTable::CreateObject(*ent);
|
||||
|
||||
G4PlacedSolidVector* tmpV = (G4PlacedSolidVector*)tmp;
|
||||
G4int entr = tmpV->entries();
|
||||
|
||||
for(G4int b=0; b<entr; b++)
|
||||
{
|
||||
ps = tmpV->at(b);
|
||||
psv->append(ps);
|
||||
}
|
||||
|
||||
index = ent->STEPfile_id ;
|
||||
G4cout<<" Context_Dependent_Shape_Representation find in index "
|
||||
<<index<<endl;
|
||||
}
|
||||
|
||||
// Set index to the true value
|
||||
index = tmpindex + 1;
|
||||
ent=0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout<<"\n Creating the Shape_Definition_Representation"<<endl;
|
||||
for(a=0; a< ShapeDefReps ; a++)
|
||||
{
|
||||
G4cout<<"loop "<<a+1<<" of "<<ShapeDefReps<<endl;
|
||||
|
||||
// Be careful, tmpindex not correspond to STEPfile_id !
|
||||
tmpindex = instanceManager.GetIndex("Shape_Definition_Representation",
|
||||
index );
|
||||
|
||||
ent = instanceManager.GetSTEPentity(tmpindex);
|
||||
|
||||
if(ent!= ENTITY_NULL)
|
||||
{
|
||||
tmp = G4GeometryTable::CreateObject(*ent);
|
||||
|
||||
G4PlacedSolidVector* tmpV = (G4PlacedSolidVector*)tmp;
|
||||
G4int entr = tmpV->entries();
|
||||
|
||||
for(G4int b=0; b<entr; b++)
|
||||
{
|
||||
ps = tmpV->at(b);
|
||||
psv->append(ps);
|
||||
}
|
||||
|
||||
index = ent->STEPfile_id ;
|
||||
G4cout<<" Shape_Definition_Representation find in index "<<index<<endl;
|
||||
}
|
||||
|
||||
// Set index to the true value
|
||||
index = tmpindex + 1;
|
||||
ent=0;
|
||||
}
|
||||
}
|
||||
|
||||
createdObject = psv;
|
||||
}
|
||||
|
||||
|
||||
void G4AssemblyCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
Registry reg(&::HeaderSchemaInit);
|
||||
SdaiCONFIG_CONTROL_DESIGNInit (reg);
|
||||
|
||||
//G4Placement* plc = (G4Placement*)G4obj;
|
||||
//G4String name("Axis2Placement3d");
|
||||
// G4FCylindricalSurface *fCyl = (G4FCylindricalSurface *)G4obj;
|
||||
// G4String name("Cylindrical_Surface");
|
||||
G4ToroidalSurface *tor = (G4ToroidalSurface *)G4obj;
|
||||
G4String name("Toroidal_Surface");
|
||||
{
|
||||
void *tmp =G4GeometryTable::CreateSTEPObject(G4obj, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "G4Axis1PlacementCreator.hh"
|
||||
|
||||
G4Axis1PlacementCreator G4Axis1PlacementCreator::csc;
|
||||
|
||||
G4Axis1PlacementCreator::G4Axis1PlacementCreator(){
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4Axis1PlacementCreator::~G4Axis1PlacementCreator(){}
|
||||
|
||||
void G4Axis1PlacementCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4Axis1PlacementCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "G4Axis2Placement2dCreator.hh"
|
||||
|
||||
G4Axis2Placement2dCreator G4Axis2Placement2dCreator::csc;
|
||||
|
||||
G4Axis2Placement2dCreator::G4Axis2Placement2dCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4Axis2Placement2dCreator::~G4Axis2Placement2dCreator(){}
|
||||
|
||||
void G4Axis2Placement2dCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4Axis2Placement2dCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "G4Axis2Placement3dCreator.hh"
|
||||
G4Axis2Placement3dCreator G4Axis2Placement3dCreator::csc;
|
||||
|
||||
G4Axis2Placement3dCreator::G4Axis2Placement3dCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4Axis2Placement3dCreator::~G4Axis2Placement3dCreator(){}
|
||||
|
||||
void G4Axis2Placement3dCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Axis2Placement3D place;
|
||||
G4Vector3D dir;
|
||||
G4Vector3D axis;
|
||||
G4Point3D srfPoint;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
if(Attr->NonRefType() != ENTITY_TYPE) Attr = Ent.NextAttribute();
|
||||
|
||||
// Get point on surface
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void * tmp = G4GeometryTable::CreateObject(*TmpEnt);
|
||||
srfPoint = *(G4Point3D*)tmp;
|
||||
|
||||
// Get axis
|
||||
Attr = Ent.NextAttribute();
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
axis = *(G4Vector3D*)tmp;
|
||||
|
||||
// Get direction
|
||||
Attr = Ent.NextAttribute();
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
dir = *(G4Vector3D*)tmp;
|
||||
|
||||
createdObject = new G4Axis2Placement3D(dir, axis, srfPoint);
|
||||
}
|
||||
|
||||
|
||||
void G4Axis2Placement3dCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
G4Axis2Placement3D *plc = (G4Axis2Placement3D*)G4obj;
|
||||
|
||||
SdaiAxis2_placement_3d *place = new SdaiAxis2_placement_3d();
|
||||
|
||||
G4Vector3D axis = plc->GetAxis();
|
||||
G4Vector3D dir = plc->GetRefDirection();
|
||||
G4Vector3D pt = plc->GetLocation();
|
||||
|
||||
G4String pointName("Cartesian_Point");
|
||||
G4String directionName("Direction");
|
||||
|
||||
// Get location
|
||||
void * tmp =G4GeometryTable::CreateSTEPObject(&pt, pointName);
|
||||
place->Location((SdaiCartesian_point*)tmp);
|
||||
|
||||
// Get axis
|
||||
tmp = G4GeometryTable::CreateSTEPObject(&axis, directionName);
|
||||
place->Axis((SdaiDirection*)tmp);
|
||||
|
||||
// Get dir
|
||||
tmp = G4GeometryTable::CreateSTEPObject(&dir, directionName);
|
||||
place->Ref_direction((SdaiDirection*)tmp);
|
||||
|
||||
// Set STEP info
|
||||
place->SetFileId(GetNextId());
|
||||
place->Name("");
|
||||
|
||||
// Write out object & subobjects
|
||||
place->STEPwrite(G4cout);
|
||||
|
||||
createdObject = place;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "G4Axis2PlacementCreator.hh"
|
||||
|
||||
G4Axis2PlacementCreator G4Axis2PlacementCreator::csc;
|
||||
|
||||
G4Axis2PlacementCreator::G4Axis2PlacementCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4Axis2PlacementCreator::~G4Axis2PlacementCreator(){}
|
||||
|
||||
void G4Axis2PlacementCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4Axis2PlacementCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "G4Axis2PlacementsCreator.hh"
|
||||
|
||||
G4Axis2PlacementsCreator G4Axis2PlacementsCreator::csc;
|
||||
|
||||
G4Axis2PlacementsCreator::G4Axis2PlacementsCreator(){
|
||||
// G4cerr << " G4Axis2PlacementsCreator default constructor "
|
||||
// << " calling G4GeometryTable::RegisterObject(this) " << endl;
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4Axis2PlacementsCreator::~G4Axis2PlacementsCreator(){}
|
||||
|
||||
void G4Axis2PlacementsCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4Axis2PlacementsCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
#include "G4BSplineCurveWithKnotsCreator.hh"
|
||||
#include "G4BSplineCurve.hh"
|
||||
typedef RWTValVector<G4double> G4doubleVector;
|
||||
|
||||
G4BSplineCurveWithKnotsCreator G4BSplineCurveWithKnotsCreator::csc;
|
||||
|
||||
|
||||
G4BSplineCurveWithKnotsCreator::G4BSplineCurveWithKnotsCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
|
||||
G4BSplineCurveWithKnotsCreator::~G4BSplineCurveWithKnotsCreator(){}
|
||||
|
||||
|
||||
void G4BSplineCurveWithKnotsCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Created by L. Broglia
|
||||
|
||||
G4int degree;
|
||||
G4Point3DVector controlPointsList;
|
||||
G4doubleVector knots;
|
||||
G4doubleVector weightsData;
|
||||
G4BSplineCurve* bSpline = new G4BSplineCurve();
|
||||
|
||||
// degree
|
||||
G4String attrName("degree");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
degree = *Attr->ptr.i;
|
||||
|
||||
|
||||
// controlPointsList
|
||||
attrName = "control_points_list";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Loop to find the entities
|
||||
// Fill points
|
||||
// Temporary solution until the STEP toolkit has been updated:
|
||||
char c = ' ';
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
char tmp[16];
|
||||
SCLstring s;
|
||||
const char *Str = Aggr->asStr(s);
|
||||
G4int Count=0;
|
||||
G4int nbpoint = 0;
|
||||
STEPentity *Entity;
|
||||
G4int stringlength = strlen(Str);
|
||||
|
||||
while(c != ')')
|
||||
{
|
||||
while(c != '#')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
|
||||
if(Count>stringlength)
|
||||
{
|
||||
G4cout << "\nString index overflow in G4ControlPoints:116";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
c = Str[Count];
|
||||
int Index=0;
|
||||
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
|
||||
tmp[Index]='\0';
|
||||
//c = ' ';
|
||||
Index = atoi(tmp);
|
||||
|
||||
MgrNode* MgrTmp = instanceManager.FindFileId(Index);
|
||||
Index = instanceManager.GetIndex(MgrTmp);
|
||||
Entity = instanceManager.GetSTEPentity(Index);
|
||||
|
||||
void *tmp =G4GeometryTable::CreateObject(*Entity);
|
||||
G4Point3D* pt = (G4Point3D*) tmp;
|
||||
G4Point3D Pt(pt->x(), pt->y(), pt->z());
|
||||
|
||||
if(controlPointsList.length() <= nbpoint+1)
|
||||
controlPointsList.reshape(nbpoint+1);
|
||||
|
||||
controlPointsList[nbpoint] = Pt;
|
||||
|
||||
nbpoint++;
|
||||
}
|
||||
|
||||
|
||||
// weightsData
|
||||
attrName = "knot_multiplicities";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
c = ' ';
|
||||
Aggr = Attr->ptr.a;
|
||||
Str = Aggr->asStr(s);
|
||||
nbpoint = 0;
|
||||
Count = 0;
|
||||
|
||||
while(c != ')')
|
||||
{
|
||||
Count++;
|
||||
while(c == '(')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
}
|
||||
|
||||
int Index=0;
|
||||
c = Str[Count];
|
||||
|
||||
while( c != ',' && c != ')' )
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
|
||||
tmp[Index]='\0';
|
||||
|
||||
// L. Broglia : I am not sure of the function "atoi"
|
||||
G4double weight = atoi(tmp);
|
||||
if (weight <= 0)
|
||||
weight = 1;
|
||||
|
||||
if(weightsData.length() <= nbpoint+1)
|
||||
weightsData.reshape(nbpoint+1);
|
||||
|
||||
weightsData[nbpoint] = weight;
|
||||
nbpoint++;
|
||||
}
|
||||
|
||||
|
||||
// knots
|
||||
attrName = "knots";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
c = ' ';
|
||||
Aggr = Attr->ptr.a;
|
||||
Str = Aggr->asStr(s);
|
||||
nbpoint = 0;
|
||||
Count = 0;
|
||||
|
||||
while(c != ')')
|
||||
{
|
||||
Count++;
|
||||
|
||||
while(c == '(')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
}
|
||||
|
||||
int Index=0;
|
||||
c = Str[Count];
|
||||
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
|
||||
tmp[Index]='\0';
|
||||
|
||||
// L. Broglia : I am not sure of the function "atoi"
|
||||
G4double knot = atoi(tmp);
|
||||
if (knot <= 0)
|
||||
knot = 1;
|
||||
|
||||
if(knots.length() <= nbpoint+1)
|
||||
knots.reshape(nbpoint+1);
|
||||
|
||||
knots[nbpoint] = knot;
|
||||
nbpoint++;
|
||||
}
|
||||
|
||||
bSpline->Init(degree, &controlPointsList, &knots, &weightsData);
|
||||
|
||||
createdObject = bSpline;
|
||||
|
||||
}
|
||||
|
||||
void G4BSplineCurveWithKnotsCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
#include "G4BSplineSurfaceCreator.hh"
|
||||
#include "G4ControlPoints.hh"
|
||||
G4BSplineSurfaceCreator G4BSplineSurfaceCreator::csc;
|
||||
|
||||
G4BSplineSurfaceCreator::G4BSplineSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4BSplineSurfaceCreator::~G4BSplineSurfaceCreator(){}
|
||||
|
||||
void G4BSplineSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
SdaiB_spline_surface* bSpline = new SdaiB_spline_surface(&Ent);
|
||||
G4int u,v;
|
||||
STEPentity* ent=0;
|
||||
G4String attrName("u_degree");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
u = *Attr->ptr.i;
|
||||
bSpline->U_degree(*Attr->ptr.i);
|
||||
attrName = "v_degree";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
v=*Attr->ptr.i;
|
||||
bSpline->V_degree(*Attr->ptr.i);
|
||||
|
||||
attrName = "control_points_list";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
GenericAggregate* gAggr = (GenericAggregate*)Attr->ptr.a;
|
||||
bSpline->Control_points_list(gAggr);
|
||||
|
||||
// Get control points
|
||||
|
||||
G4int cols,rows;
|
||||
cols = v+1;
|
||||
rows = u+1;
|
||||
|
||||
STEPentity* entity;
|
||||
G4int Index;
|
||||
STEPentity *Entity;
|
||||
char tmp[16];
|
||||
SCLstring s;
|
||||
const char *Str = Aggr->asStr(s);
|
||||
|
||||
G4int stringlength = strlen(Str);
|
||||
G4ControlPoints controlPoints(4,rows, cols);
|
||||
RealAggregate rationalAggr;
|
||||
RealNode* rNode =0;
|
||||
for(G4int a=0;a<rows;a++)
|
||||
for(G4int b=0;b<cols;b++)
|
||||
{
|
||||
// get points
|
||||
|
||||
// temp version until the NIST toolkit can handle two dimensional aggregates
|
||||
// The string Str contains the STEP file id:s of the underlying point
|
||||
// entities so well have to parse the string to get them out...arghhh!
|
||||
char c = ' ';
|
||||
int Count=0;
|
||||
// Loop to find the entities
|
||||
|
||||
|
||||
// Fill points
|
||||
//Temporary solution until the STEP toolkit has been updated:
|
||||
|
||||
while(c != '#')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
if(Count>stringlength)
|
||||
{
|
||||
G4cout << "\nString index overflow in G4ControlPoints:116";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
c = Str[Count];
|
||||
int Index=0;
|
||||
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
tmp[Index]='\0';
|
||||
Index = atoi(tmp);
|
||||
//delete [] tmp;
|
||||
//Entity = InstanceList.GetSTEPentity(Index);
|
||||
MgrNode* MgrTmp = instanceManager.FindFileId(Index);
|
||||
Index = instanceManager.GetIndex(MgrTmp);
|
||||
Entity = instanceManager.GetSTEPentity(Index);
|
||||
void *tmp =G4GeometryTable::CreateObject(*Entity);
|
||||
controlPoints.put(a,b,*(G4PointRat*)tmp);
|
||||
}
|
||||
|
||||
createdObject = bSpline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void G4BSplineSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
#include "G4BSplineSurfaceWithKnotsCreator.hh"
|
||||
|
||||
G4BSplineSurfaceWithKnotsCreator G4BSplineSurfaceWithKnotsCreator::csc;
|
||||
|
||||
G4BSplineSurfaceWithKnotsCreator::G4BSplineSurfaceWithKnotsCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4BSplineSurfaceWithKnotsCreator::~G4BSplineSurfaceWithKnotsCreator(){}
|
||||
|
||||
void G4BSplineSurfaceWithKnotsCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
SdaiB_spline_surface_with_knots *bSpline = new SdaiB_spline_surface_with_knots(&Ent);
|
||||
// U dir
|
||||
G4String attrName("u_multiplicities");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
bSpline->U_multiplicities((IntAggregate*)Attr->ptr.a);
|
||||
STEPaggregate *multAggr = Attr->ptr.a;
|
||||
G4int uMultCount = multAggr->EntryCount();
|
||||
|
||||
attrName = "u_knots";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
STEPaggregate *knotAggr = Attr->ptr.a;
|
||||
G4int uKnotCount = knotAggr->EntryCount();
|
||||
|
||||
G4int totalUKnotCount = 0;
|
||||
IntNode* multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
G4int a;
|
||||
for(a=0;a<uMultCount;a++)
|
||||
{
|
||||
totalUKnotCount += multiNode->value;
|
||||
multiNode = (IntNode*)multiNode->NextNode();
|
||||
}
|
||||
|
||||
G4KnotVector *uKnots = new G4KnotVector(totalUKnotCount);
|
||||
|
||||
RealNode* knotNode = (RealNode*)knotAggr->GetHead();
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
bSpline->U_knots((RealAggregate*)knotAggr);
|
||||
|
||||
G4int multValue=0;
|
||||
G4double knotValue=0;
|
||||
G4int index=0;
|
||||
for(a=0;a<uKnotCount;a++)
|
||||
{
|
||||
multValue = multiNode->value;
|
||||
knotValue = knotNode->value;
|
||||
|
||||
for(G4int b=0;b<multValue;b++)
|
||||
{
|
||||
uKnots->PutKnot(index, knotValue);
|
||||
index++;
|
||||
}
|
||||
knotNode = (RealNode*)knotNode->NextNode();
|
||||
}
|
||||
|
||||
|
||||
// V dir
|
||||
attrName = "v_multiplicities";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
multAggr = Attr->ptr.a;
|
||||
bSpline->V_multiplicities((IntAggregate*)Attr->ptr.a);
|
||||
G4int vMultCount = multAggr->EntryCount();
|
||||
|
||||
attrName = "v_knots";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
knotAggr = Attr->ptr.a;
|
||||
bSpline->V_knots((RealAggregate*)knotAggr);
|
||||
G4int vKnotCount = knotAggr->EntryCount();
|
||||
|
||||
G4int totalVKnotCount = 0;
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
for(a=0;a<vMultCount;a++)
|
||||
{
|
||||
totalVKnotCount += multiNode->value;
|
||||
multiNode = (IntNode*)multiNode->NextNode();
|
||||
}
|
||||
G4KnotVector *vKnots = new G4KnotVector(totalVKnotCount);
|
||||
|
||||
knotNode = (RealNode*)knotAggr->GetHead();
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
multValue=0;
|
||||
knotValue=0;
|
||||
index=0;
|
||||
|
||||
for(a=0;a<uKnotCount;a++)
|
||||
{
|
||||
multValue = multiNode->value;
|
||||
knotValue = knotNode->value;
|
||||
|
||||
for(G4int b=0;b<multValue;b++)
|
||||
{
|
||||
vKnots->PutKnot(index, knotValue);
|
||||
index++;
|
||||
}
|
||||
knotNode = (RealNode*)knotNode->NextNode();
|
||||
}
|
||||
|
||||
// b_spline base parts
|
||||
|
||||
G4int u,v;
|
||||
STEPentity* ent=0;
|
||||
attrName = "u_degree";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
u = *Attr->ptr.i;
|
||||
bSpline->U_degree(*Attr->ptr.i);
|
||||
}
|
||||
|
||||
|
||||
attrName = "v_degree";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
v=*Attr->ptr.i;
|
||||
bSpline->V_degree(*Attr->ptr.i);
|
||||
}
|
||||
|
||||
attrName = "control_points_list";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
GenericAggregate* gAggr = (GenericAggregate*)Attr->ptr.a;
|
||||
bSpline->Control_points_list(gAggr);
|
||||
// Get control points
|
||||
|
||||
G4int cols,rows;
|
||||
cols = v+1;
|
||||
rows = u+1;
|
||||
|
||||
STEPentity* entity;
|
||||
G4int Index;
|
||||
STEPentity *Entity;
|
||||
char tmp[16];
|
||||
SCLstring s;
|
||||
const char *Str = Aggr->asStr(s);
|
||||
|
||||
G4int stringlength = strlen(Str);
|
||||
G4ControlPoints controlPoints(4,rows, cols);
|
||||
RealAggregate rationalAggr;
|
||||
RealNode* rNode =0;
|
||||
for(G4int a=0;a<rows;a++)
|
||||
for(G4int b=0;b<cols;b++)
|
||||
{
|
||||
// get points
|
||||
|
||||
// temp version until the NIST toolkit can handle two dimensional aggregates
|
||||
// The string Str contains the STEP file id:s of the underlying point
|
||||
// entities so well have to parse the string to get them out...arghhh!
|
||||
char c = ' ';
|
||||
int Count=0;
|
||||
// Loop to find the entities
|
||||
|
||||
|
||||
// Fill points
|
||||
//Temporary solution until the STEP toolkit has been updated:
|
||||
|
||||
while(c != '#')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
if(Count>stringlength)
|
||||
{
|
||||
G4cout << "\nString index overflow in G4ControlPoints:116";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
c = Str[Count];
|
||||
int Index=0;
|
||||
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
tmp[Index]='\0';
|
||||
Index = atoi(tmp);
|
||||
//delete [] tmp;
|
||||
//Entity = InstanceList.GetSTEPentity(Index);
|
||||
MgrNode* MgrTmp = instanceManager.FindFileId(Index);
|
||||
Index = instanceManager.GetIndex(MgrTmp);
|
||||
Entity = instanceManager.GetSTEPentity(Index);
|
||||
void *tmp =G4GeometryTable::CreateObject(*Entity);
|
||||
controlPoints.put(a,b,*(G4PointRat*)tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createdObject = bSpline;
|
||||
|
||||
}
|
||||
|
||||
void G4BSplineSurfaceWithKnotsCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
#include "G4BoundedSurfaceCreator.hh"
|
||||
|
||||
G4BoundedSurfaceCreator G4BoundedSurfaceCreator::csc;
|
||||
|
||||
G4BoundedSurfaceCreator::G4BoundedSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4BoundedSurfaceCreator::~G4BoundedSurfaceCreator(){}
|
||||
|
||||
void G4BoundedSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
STEPcomplex* complexEnt = (STEPcomplex*)&Ent;
|
||||
void* tmp=0;
|
||||
STEPentity* subEnt=0;
|
||||
SdaiB_spline_surface *bSpline=0;
|
||||
SdaiB_spline_surface_with_knots *bSplineWithKnots=0;
|
||||
SdaiRational_b_spline_surface *rationalBSpline =0;
|
||||
|
||||
if(complexEnt->EntityExists("B_Spline_Surface"))
|
||||
{
|
||||
subEnt = complexEnt->EntityPart("B_Spline_Surface");
|
||||
bSpline =(SdaiB_spline_surface*)G4GeometryTable::CreateObject(*subEnt);
|
||||
}
|
||||
|
||||
if(complexEnt->EntityExists("B_Spline_Surface_With_Knots"))
|
||||
{
|
||||
subEnt = complexEnt->EntityPart("B_Spline_Surface_With_Knots");
|
||||
bSplineWithKnots =(SdaiB_spline_surface_with_knots*)G4GeometryTable::CreateObject(*subEnt);
|
||||
}
|
||||
|
||||
if(complexEnt->EntityExists("Rational_B_Spline_Surface"))
|
||||
{
|
||||
subEnt = complexEnt->EntityPart("Rational_B_Spline_Surface");
|
||||
rationalBSpline =(SdaiRational_b_spline_surface*)G4GeometryTable::CreateObject(*subEnt);
|
||||
}
|
||||
|
||||
|
||||
G4int u,v;
|
||||
u=bSpline->U_degree();
|
||||
v=bSpline->V_degree();
|
||||
|
||||
|
||||
// Get control points
|
||||
|
||||
G4int cols,rows;
|
||||
cols = v+1;
|
||||
rows = u+1;
|
||||
char tmpstr[16];
|
||||
STEPentity* entity;
|
||||
G4int Index;
|
||||
STEPentity *Entity;
|
||||
SCLstring s;
|
||||
STEPaggregate *Aggr=bSpline->Control_points_list();
|
||||
const char *Str = Aggr->asStr(s);
|
||||
|
||||
G4int stringlength = strlen(Str);
|
||||
G4ControlPoints controlPoints(4,rows, cols);
|
||||
RealAggregate rationalAggr;
|
||||
RealNode* rNode =0;
|
||||
G4int a;
|
||||
for(a=0;a<rows;a++)
|
||||
for(G4int b=0;b<cols;b++)
|
||||
{
|
||||
// get points
|
||||
|
||||
// temp version until the NIST toolkit can handle two dimensional aggregates
|
||||
// The string Str contains the STEP file id:s of the underlying point
|
||||
// entities so well have to parse the string to get them out...arghhh!
|
||||
char c = ' ';
|
||||
int Count=0;
|
||||
// Loop to find the entities
|
||||
|
||||
|
||||
// Fill points
|
||||
//Temporary solution until the STEP toolkit has been updated:
|
||||
|
||||
while(c != '#')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
if(Count>stringlength)
|
||||
{
|
||||
G4cout << "\nString index overflow in G4ControlPoints:116";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
c = Str[Count];
|
||||
int Index=0;
|
||||
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmpstr[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
tmpstr[Index]='\0';
|
||||
Index = atoi(tmpstr);
|
||||
//delete [] tmp;
|
||||
//Entity = InstanceList.GetSTEPentity(Index);
|
||||
MgrNode* MgrTmp = instanceManager.FindFileId(Index);
|
||||
Index = instanceManager.GetIndex(MgrTmp);
|
||||
Entity = instanceManager.GetSTEPentity(Index);
|
||||
void *tmp =G4GeometryTable::CreateObject(*Entity);
|
||||
controlPoints.put(a,b,*(G4PointRat*)tmp);
|
||||
}
|
||||
|
||||
|
||||
// Get knot vectors
|
||||
STEPaggregate *multAggr = bSplineWithKnots->U_multiplicities();
|
||||
G4int uMultCount = multAggr->EntryCount();
|
||||
STEPaggregate *knotAggr = bSplineWithKnots->U_knots();
|
||||
G4int uKnotCount = knotAggr->EntryCount();
|
||||
|
||||
G4int totalUKnotCount = 0;
|
||||
IntNode* multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
for(a=0;a<uMultCount;a++)
|
||||
{
|
||||
totalUKnotCount += multiNode->value;
|
||||
multiNode = (IntNode*)multiNode->NextNode();
|
||||
}
|
||||
|
||||
G4KnotVector *uKnots = new G4KnotVector(totalUKnotCount);
|
||||
|
||||
RealNode* knotNode = (RealNode*)knotAggr->GetHead();
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
G4int multValue=0;
|
||||
G4double knotValue=0;
|
||||
G4int index=0;
|
||||
for(a=0;a<uKnotCount;a++)
|
||||
{
|
||||
multValue = multiNode->value;
|
||||
knotValue = knotNode->value;
|
||||
|
||||
for(G4int b=0;b<multValue;b++)
|
||||
{
|
||||
uKnots->PutKnot(index, knotValue);
|
||||
index++;
|
||||
}
|
||||
knotNode = (RealNode*)knotNode->NextNode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// V dir
|
||||
multAggr = bSplineWithKnots->V_multiplicities();
|
||||
G4int vMultCount = multAggr->EntryCount();
|
||||
|
||||
knotAggr = bSplineWithKnots->V_knots();
|
||||
G4int vKnotCount = knotAggr->EntryCount();
|
||||
|
||||
G4int totalVKnotCount = 0;
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
for(a=0;a<vMultCount;a++)
|
||||
{
|
||||
totalVKnotCount += multiNode->value;
|
||||
multiNode = (IntNode*)multiNode->NextNode();
|
||||
}
|
||||
G4KnotVector *vKnots = new G4KnotVector(totalVKnotCount);
|
||||
|
||||
knotNode = (RealNode*)knotAggr->GetHead();
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
multValue=0;
|
||||
knotValue=0;
|
||||
index=0;
|
||||
|
||||
for(a=0;a<uKnotCount;a++)
|
||||
{
|
||||
multValue = multiNode->value;
|
||||
knotValue = knotNode->value;
|
||||
|
||||
for(G4int b=0;b<multValue;b++)
|
||||
{
|
||||
vKnots->PutKnot(index, knotValue);
|
||||
index++;
|
||||
}
|
||||
knotNode = (RealNode*)knotNode->NextNode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// copy weights data
|
||||
STEPaggregate *weightAggr = rationalBSpline->Weights_data();
|
||||
// Temp solution until NIST supports
|
||||
// two dimensional instances.grrh
|
||||
const char* Str2 = weightAggr->asStr(s);
|
||||
rows = weightAggr->EntryCount();
|
||||
cols = 1;
|
||||
G4int counter=0;
|
||||
while (Str2[counter] != ')')
|
||||
{
|
||||
if(Str2[counter]==',')
|
||||
cols++;
|
||||
counter++;
|
||||
}
|
||||
|
||||
char c;
|
||||
G4int Count=0;
|
||||
G4double* ratVector = new G4double[cols*rows];
|
||||
for(a=0;a<rows*cols;a++)
|
||||
{
|
||||
c = '(';
|
||||
while(c == '(' || c==',')
|
||||
{
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
int Index=0;
|
||||
char *tmp = new char[16];
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
tmp[Index]='\0';
|
||||
G4double Value = atof(tmp);
|
||||
delete [] tmp;
|
||||
ratVector[a] = Value;
|
||||
|
||||
}
|
||||
|
||||
controlPoints.SetWeights(ratVector);
|
||||
|
||||
|
||||
// create BSpline
|
||||
G4BSplineSurface* bSplineSrf = new G4BSplineSurface(
|
||||
u,
|
||||
v,
|
||||
*uKnots,
|
||||
*vKnots,
|
||||
controlPoints
|
||||
);
|
||||
}
|
||||
|
||||
void G4BoundedSurfaceCreator::CreateSTEPGeometry(void * G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "G4CartesianPointCreator.hh"
|
||||
|
||||
G4CartesianPointCreator G4CartesianPointCreator::csc;
|
||||
|
||||
G4CartesianPointCreator::G4CartesianPointCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4CartesianPointCreator::~G4CartesianPointCreator(){}
|
||||
|
||||
void G4CartesianPointCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4double x,y,z;
|
||||
Ent.ResetAttributes();
|
||||
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
Attr = Ent.NextAttribute();
|
||||
STEPaggregate& XYZAggr = *Attr->ptr.a;
|
||||
SingleLinkNode* RNode = XYZAggr.GetHead();
|
||||
|
||||
x = ((RealNode*)RNode)->value;
|
||||
RNode = RNode->NextNode();
|
||||
y = ((RealNode*)RNode)->value;
|
||||
RNode = RNode->NextNode();
|
||||
z = ((RealNode*)RNode)->value;
|
||||
// createdObject = new G4Point3d(x,y,z);
|
||||
createdObject = new G4Point3D(x,y,z);
|
||||
}
|
||||
|
||||
void G4CartesianPointCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
//G4Point3d* pt = (G4Point3d*)G4obj;
|
||||
G4Point3D* pt = (G4Point3D*)G4obj;
|
||||
RealNode *xa,*ya,*za;
|
||||
|
||||
RealAggregate pointAggr;
|
||||
xa = (RealNode*)pointAggr.NewNode();
|
||||
// xa->value = pt->X();
|
||||
xa->value = pt->x();
|
||||
|
||||
ya = (RealNode*)pointAggr.NewNode();
|
||||
// ya->value = pt->Y();
|
||||
ya->value = pt->y();
|
||||
|
||||
za = (RealNode*)pointAggr.NewNode();
|
||||
// za->value = pt->Z();
|
||||
za->value = pt->z();
|
||||
|
||||
pointAggr.AddNode(xa);
|
||||
pointAggr.AddNode(ya);
|
||||
pointAggr.AddNode(za);
|
||||
|
||||
SdaiCartesian_point *sPoint = new SdaiCartesian_point();
|
||||
sPoint->Coordinates(&pointAggr);
|
||||
sPoint->SetFileId(GetNextId());
|
||||
sPoint->Name("");
|
||||
|
||||
sPoint->STEPwrite(G4cout);
|
||||
createdObject = sPoint;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "G4CircleCreator.hh"
|
||||
#include "G4CircularCurve.hh"
|
||||
|
||||
|
||||
G4CircleCreator G4CircleCreator::csc;
|
||||
|
||||
G4CircleCreator::G4CircleCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4CircleCreator::~G4CircleCreator(){}
|
||||
|
||||
void G4CircleCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Axis2Placement3D place;
|
||||
|
||||
G4double radius;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
while(Attr->NonRefType() == STRING_TYPE ||
|
||||
Attr->NonRefType() == sdaiSTRING )
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get the placement
|
||||
SelectNode* SelectN = (SelectNode*)Attr->ptr.sh;
|
||||
SdaiSelect* Select = (SdaiSelect*)SelectN;
|
||||
SdaiAxis2_placement* Place = (SdaiAxis2_placement*)Select;
|
||||
STEPentity* TmpEnt = Place->operator SdaiAxis2_placement_3dH();
|
||||
void * tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
place = *(G4Axis2Placement3D*)tmp;
|
||||
|
||||
Attr = Ent.NextAttribute();
|
||||
radius = *Attr->ptr.r;
|
||||
|
||||
G4CircularCurve* circle = new G4CircularCurve();
|
||||
circle->Init(place , radius);
|
||||
createdObject = circle;
|
||||
}
|
||||
|
||||
void G4CircleCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#include "G4ClosedShellCreator.hh"
|
||||
|
||||
G4ClosedShellCreator G4ClosedShellCreator::csc;
|
||||
|
||||
G4ClosedShellCreator::G4ClosedShellCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ClosedShellCreator::~G4ClosedShellCreator(){}
|
||||
|
||||
void G4ClosedShellCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
G4String attrName("cfs_faces");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
SingleLinkNode *Node = Aggr->GetHead();
|
||||
STEPentity* TmpEnt=0;
|
||||
|
||||
G4int FaceCount = Aggr->EntryCount();
|
||||
|
||||
G4SurfaceVector SurfaceVec;
|
||||
|
||||
for(G4int a=0; a<FaceCount;a++)
|
||||
{
|
||||
TmpEnt = ((EntityNode*)Node)->node;
|
||||
void *tmp =::G4GeometryTable::CreateObject(*TmpEnt);
|
||||
SurfaceVec.append((G4Surface*)tmp);
|
||||
Node = Node->NextNode();
|
||||
}
|
||||
|
||||
// create G4solid
|
||||
G4Surface** srfVec = new G4Surface*[FaceCount];
|
||||
|
||||
for(G4int b=0;b<FaceCount;b++)
|
||||
srfVec[b] = (SurfaceVec[b]);
|
||||
|
||||
G4BREPSolid* sld = new G4BREPSolid(" ", srfVec, FaceCount);
|
||||
|
||||
createdObject = sld;
|
||||
|
||||
// delete [] srfVec;
|
||||
// delete sld;
|
||||
}
|
||||
|
||||
void G4ClosedShellCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
G4BREPSolid* bSld = (G4BREPSolid*)G4obj;
|
||||
SdaiClosed_shell* sld = new SdaiClosed_shell();
|
||||
|
||||
G4int surfaceCount = bSld->NumberOfFaces();
|
||||
|
||||
EntityAggregate eAggr;
|
||||
EntityNode* eNode=0;
|
||||
void* tmp=0;
|
||||
G4Surface* srf=0;
|
||||
|
||||
for(G4int a=0;a<surfaceCount;a++)
|
||||
{
|
||||
srf = bSld->GetSurface(a);
|
||||
G4String srfType(srf->GetEntityType());
|
||||
tmp = G4GeometryTable::CreateSTEPObject(srf,srfType);
|
||||
|
||||
eNode = new EntityNode((STEPentity*)tmp);
|
||||
eAggr.AddNode(eNode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
sld->Cfs_faces(&eAggr);
|
||||
|
||||
|
||||
sld->SetFileId(GetNextId());
|
||||
sld->Name("");
|
||||
sld->STEPwrite(G4cout);
|
||||
|
||||
createdObject = sld;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "G4ConicCreator.hh"
|
||||
|
||||
G4ConicCreator G4ConicCreator::csc;
|
||||
|
||||
G4ConicCreator::G4ConicCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ConicCreator::~G4ConicCreator(){}
|
||||
|
||||
void G4ConicCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// G4Placement *place;
|
||||
G4String attrName("edge_start");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get the placement
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
// place = (G4Placement*)place;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void G4ConicCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "G4ConicalSurfaceCreator.hh"
|
||||
#include "G4ConicalSurface.hh"
|
||||
|
||||
G4ConicalSurfaceCreator G4ConicalSurfaceCreator::csc;
|
||||
|
||||
G4ConicalSurfaceCreator::G4ConicalSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ConicalSurfaceCreator::~G4ConicalSurfaceCreator(){}
|
||||
|
||||
void G4ConicalSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Made by L. Broglia
|
||||
|
||||
STEPattribute *Attr;
|
||||
G4Axis2Placement3D* place;
|
||||
G4double angle;
|
||||
|
||||
G4String attrName("position");
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get placement
|
||||
STEPentity* TmpEnt = *Attr->ptr.c; // ptr.c --> ENTITY_TYPE
|
||||
void *tmp = G4GeometryTable::CreateObject(*TmpEnt);
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// Get angle
|
||||
G4String attrNameA("semi_angle");
|
||||
Attr = GetNamedAttribute(attrNameA, Ent);
|
||||
angle = *Attr->ptr.r; // Be careful, angle is in degree
|
||||
|
||||
|
||||
G4ConicalSurface* aG4cone =
|
||||
new G4ConicalSurface( (*place).GetLocation() ,
|
||||
(*place).GetAxis() ,
|
||||
angle * 2*M_PI/360 );
|
||||
|
||||
createdObject = aG4cone;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void G4ConicalSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
G4FConicalSurface* fCon = (G4FConicalSurface*)G4obj;
|
||||
SdaiConical_surface* srf= new SdaiConical_surface();
|
||||
// Get placement
|
||||
G4String placementName("Axis2Placement3d");
|
||||
void * tmp =G4GeometryTable::CreateSTEPObject(&fCon, placementName);
|
||||
SdaiAxis2_placement_3d *place = (SdaiAxis2_placement_3d*)tmp;
|
||||
srf->Position(place);
|
||||
// radius
|
||||
srf->Radius(fCon->GetSmallRadius());
|
||||
// semi-angle
|
||||
//srf->Semi_angle(fCon->GetAngle());
|
||||
// Set STEP info
|
||||
srf->SetFileId(GetNextId());
|
||||
srf->Name("");
|
||||
|
||||
// Write out object
|
||||
srf->STEPwrite(G4cout);
|
||||
|
||||
createdObject = srf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "G4ConnectedFaceSetCreator.hh"
|
||||
|
||||
G4ConnectedFaceSetCreator G4ConnectedFaceSetCreator::csc;
|
||||
|
||||
G4ConnectedFaceSetCreator::G4ConnectedFaceSetCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ConnectedFaceSetCreator::~G4ConnectedFaceSetCreator(){}
|
||||
|
||||
void G4ConnectedFaceSetCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4ConnectedFaceSetCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#include "G4ContextDependentShapeRepresentationCreator.hh"
|
||||
|
||||
G4ContextDependentShapeRepresentationCreator G4ContextDependentShapeRepresentationCreator::csc;
|
||||
|
||||
G4ContextDependentShapeRepresentationCreator::G4ContextDependentShapeRepresentationCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ContextDependentShapeRepresentationCreator::~G4ContextDependentShapeRepresentationCreator(){}
|
||||
|
||||
void G4ContextDependentShapeRepresentationCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
G4String attrName("representation_relation");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
G4PlacedSolidVector* psV = (G4PlacedSolidVector*)tmp;
|
||||
|
||||
|
||||
// L. Broglia
|
||||
// For the moment, the represented_product_relation is not needed
|
||||
// So don`t create it
|
||||
attrName="represented_product_relation";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
// tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
createdObject = psV;
|
||||
}
|
||||
|
||||
void G4ContextDependentShapeRepresentationCreator::CreateSTEPGeometry(void* obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "G4CurveCreator.hh"
|
||||
|
||||
G4CurveCreator G4CurveCreator::csc;
|
||||
|
||||
G4CurveCreator::G4CurveCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4CurveCreator::~G4CurveCreator(){}
|
||||
|
||||
void G4CurveCreator::CreateG4Geometry(STEPentity& Ent){}
|
||||
|
||||
void G4CurveCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "G4CylindricalSurfaceCreator.hh"
|
||||
#include "G4FCylindricalSurface.hh"
|
||||
#include "G4CylindricalSurface.hh"
|
||||
|
||||
|
||||
G4CylindricalSurfaceCreator G4CylindricalSurfaceCreator::csc;
|
||||
|
||||
G4CylindricalSurfaceCreator::G4CylindricalSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4CylindricalSurfaceCreator::~G4CylindricalSurfaceCreator(){}
|
||||
|
||||
void G4CylindricalSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Made by L. Broglia
|
||||
|
||||
STEPattribute *Attr;
|
||||
G4Axis2Placement3D* place;
|
||||
G4double radius;
|
||||
|
||||
G4String attrName("position");
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get placement
|
||||
STEPentity* TmpEnt = *Attr->ptr.c; // ptr.c --> ENTITY_TYPE
|
||||
void *tmp = G4GeometryTable::CreateObject(*TmpEnt);
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// Get radius
|
||||
G4String attrNameR("radius");
|
||||
Attr = GetNamedAttribute(attrNameR, Ent);
|
||||
radius = *Attr->ptr.r;
|
||||
|
||||
G4CylindricalSurface* aG4cylinder =
|
||||
new G4CylindricalSurface( (*place).GetLocation() ,
|
||||
(*place).GetAxis() ,
|
||||
radius );
|
||||
createdObject = aG4cylinder;
|
||||
}
|
||||
|
||||
void G4CylindricalSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
G4FCylindricalSurface* fCyl = (G4FCylindricalSurface*)G4obj;
|
||||
SdaiCylindrical_surface* srf= new SdaiCylindrical_surface();
|
||||
|
||||
// Get placement
|
||||
G4String placementName("Axis2Placement3d");
|
||||
void * tmp =G4GeometryTable::CreateSTEPObject(&fCyl, placementName);
|
||||
SdaiAxis2_placement_3d *place = (SdaiAxis2_placement_3d*)tmp;
|
||||
srf->Position(place);
|
||||
|
||||
// radius
|
||||
srf->Radius(fCyl->GetRadius());
|
||||
|
||||
// Set STEP info
|
||||
srf->SetFileId(GetNextId());
|
||||
srf->Name("");
|
||||
|
||||
// Write out object
|
||||
srf->STEPwrite(G4cout);
|
||||
|
||||
createdObject = srf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "G4DirectionCreator.hh"
|
||||
|
||||
G4DirectionCreator G4DirectionCreator::csc;
|
||||
|
||||
G4DirectionCreator::G4DirectionCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4DirectionCreator::~G4DirectionCreator(){}
|
||||
|
||||
void G4DirectionCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4double x,y,z;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
Attr = Ent.NextAttribute();
|
||||
STEPaggregate& XYZAggr = *Attr->ptr.a;
|
||||
SingleLinkNode* RNode = XYZAggr.GetHead();
|
||||
|
||||
x = ((RealNode*)RNode)->value;
|
||||
RNode = RNode->NextNode();
|
||||
|
||||
y = ((RealNode*)RNode)->value;
|
||||
RNode = RNode->NextNode();
|
||||
|
||||
z = ((RealNode*)RNode)->value;
|
||||
createdObject = new G4ThreeVector(x,y,z);
|
||||
}
|
||||
|
||||
|
||||
void G4DirectionCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
//G4ThreeVec* dir = (G4ThreeVec*)G4obj;
|
||||
G4Vector3D* dir = (G4Vector3D*)G4obj;
|
||||
RealNode *xa,*ya,*za;
|
||||
|
||||
RealAggregate dirAggr;
|
||||
xa = (RealNode*)dirAggr.NewNode();
|
||||
// xa->value = dir->X();
|
||||
xa->value = dir->x();
|
||||
|
||||
ya = (RealNode*)dirAggr.NewNode();
|
||||
// ya->value = dir->Y();
|
||||
ya->value = dir->y();
|
||||
|
||||
za = (RealNode*)dirAggr.NewNode();
|
||||
// za->value = dir->Z();
|
||||
za->value = dir->z();
|
||||
|
||||
dirAggr.AddNode(xa);
|
||||
dirAggr.AddNode(ya);
|
||||
dirAggr.AddNode(za);
|
||||
|
||||
SdaiDirection *sDir = new SdaiDirection();
|
||||
sDir->Direction_ratios(&dirAggr);
|
||||
sDir->SetFileId(GetNextId());
|
||||
sDir->Name("");
|
||||
sDir->STEPwrite(G4cout);
|
||||
createdObject = sDir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "G4EdgeCurveCreator.hh"
|
||||
|
||||
G4EdgeCurveCreator G4EdgeCurveCreator::csc;
|
||||
|
||||
G4EdgeCurveCreator::G4EdgeCurveCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4EdgeCurveCreator::~G4EdgeCurveCreator(){}
|
||||
|
||||
void G4EdgeCurveCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Point3D *pt1,*pt2;
|
||||
G4Curve* crv;
|
||||
G4bool sameSense;
|
||||
|
||||
// Get start point
|
||||
G4String attrName("edge_start");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
pt1 = (G4Point3D*)tmp;
|
||||
|
||||
// Get end point
|
||||
attrName = "edge_end";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
pt2 = (G4Point3D*)tmp;
|
||||
|
||||
// Get curve
|
||||
attrName = "edge_geometry";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
crv = (G4Curve*)tmp;
|
||||
|
||||
// set the bounds
|
||||
G4Point3D p1(pt1->x(), pt1->y(), pt1->z());
|
||||
G4Point3D p2(pt2->x(), pt2->y(), pt1->z());
|
||||
|
||||
crv->SetBounds(p1, p2);
|
||||
|
||||
//get sense info
|
||||
Attr = Ent.NextAttribute();
|
||||
// sameSense = *Attr->ptr.b;
|
||||
|
||||
createdObject = crv;
|
||||
}
|
||||
|
||||
|
||||
void G4EdgeCurveCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "G4EdgeLoopCreator.hh"
|
||||
|
||||
G4EdgeLoopCreator G4EdgeLoopCreator::csc;
|
||||
|
||||
G4EdgeLoopCreator::G4EdgeLoopCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4EdgeLoopCreator::~G4EdgeLoopCreator(){}
|
||||
|
||||
void G4EdgeLoopCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4String attrName("edge_list");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
SingleLinkNode *Node = Aggr->GetHead();
|
||||
STEPentity* TmpEnt=0;
|
||||
|
||||
G4int EdgeCount = Aggr->EntryCount();
|
||||
G4CurveVector* CurveVec = new G4CurveVector[EdgeCount];
|
||||
|
||||
for(G4int a=0; a<EdgeCount;a++)
|
||||
{
|
||||
TmpEnt = ((EntityNode*)Node)->node;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
CurveVec->append((G4Curve*)tmp);
|
||||
Node = Node->NextNode();
|
||||
}
|
||||
|
||||
createdObject = CurveVec;
|
||||
}
|
||||
|
||||
void G4EdgeLoopCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "G4EllipseCreator.hh"
|
||||
|
||||
G4EllipseCreator G4EllipseCreator::csc;
|
||||
|
||||
G4EllipseCreator::G4EllipseCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4EllipseCreator::~G4EllipseCreator(){}
|
||||
|
||||
void G4EllipseCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4double semi1,semi2;
|
||||
|
||||
// L. Broglia
|
||||
// G4Placement* place;
|
||||
G4Axis2Placement3D* place;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
while(Attr->NonRefType() == STRING_TYPE ||
|
||||
Attr->NonRefType() == sdaiSTRING )
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get the placement
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// L. Broglia
|
||||
// place = (G4Placement*)tmp;
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// get semi axises
|
||||
Attr = Ent.NextAttribute();
|
||||
semi1 = *Attr->ptr.r;
|
||||
|
||||
Attr = Ent.NextAttribute();
|
||||
semi2 = *Attr->ptr.r;
|
||||
}
|
||||
|
||||
void G4EllipseCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "G4FaceBoundCreator.hh"
|
||||
|
||||
G4FaceBoundCreator G4FaceBoundCreator::csc;
|
||||
|
||||
G4FaceBoundCreator::G4FaceBoundCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4FaceBoundCreator::~G4FaceBoundCreator(){}
|
||||
|
||||
void G4FaceBoundCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4int orientation;
|
||||
G4String attrName("bound");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get curve
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// L. Broglia
|
||||
// Mistake : the created object tmp is a G4CurveVector
|
||||
// G4Curve* crv = (G4Curve*)tmp;
|
||||
G4CurveVector* crv = (G4CurveVector*)tmp;
|
||||
|
||||
Attr = Ent.NextAttribute();
|
||||
//orientation = *Attr->ptr.i;
|
||||
//crv->SetSameSense(orientation);
|
||||
createdObject = crv;
|
||||
|
||||
}
|
||||
|
||||
void G4FaceBoundCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "G4FaceOuterBoundCreator.hh"
|
||||
|
||||
G4FaceOuterBoundCreator G4FaceOuterBoundCreator::csc;
|
||||
|
||||
G4FaceOuterBoundCreator::G4FaceOuterBoundCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4FaceOuterBoundCreator::~G4FaceOuterBoundCreator(){}
|
||||
|
||||
void G4FaceOuterBoundCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "G4FaceSurfaceCreator.hh"
|
||||
|
||||
G4FaceSurfaceCreator G4FaceSurfaceCreator::csc;
|
||||
|
||||
G4FaceSurfaceCreator::G4FaceSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4FaceSurfaceCreator::~G4FaceSurfaceCreator(){}
|
||||
|
||||
void G4FaceSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Surface* srf=0;
|
||||
G4bool sense;
|
||||
|
||||
G4String attrName("face_geometry");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
srf = (G4Surface*)tmp;
|
||||
|
||||
Attr = Ent.NextAttribute();
|
||||
// sense = *Attr->ptr.b;
|
||||
createdObject = srf;
|
||||
}
|
||||
|
||||
void G4FaceSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "G4GeometricRepresentationContextCreator.hh"
|
||||
|
||||
G4GeometricRepresentationContextCreator G4GeometricRepresentationContextCreator
|
||||
::csc;
|
||||
|
||||
G4GeometricRepresentationContextCreator::
|
||||
G4GeometricRepresentationContextCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4GeometricRepresentationContextCreator::
|
||||
~G4GeometricRepresentationContextCreator(){}
|
||||
|
||||
void G4GeometricRepresentationContextCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Made by L. Broglia
|
||||
STEPattribute *Attr;
|
||||
|
||||
// tmp
|
||||
G4cout<<"Warning ! G4GeometricRepresentationContextCreator called ..."<<endl;
|
||||
|
||||
G4String attrName("coordinate_space_dimension");
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get coordinate space dimension
|
||||
SdaiReal Tmpdim = *Attr->ptr.r; // ptr.r --> REAL_TYPE
|
||||
|
||||
// void *tmp = G4GeometryTable::CreateObject(*TmpEnt);
|
||||
// place = (G4Axis2Placement3D*)tmp...;
|
||||
|
||||
}
|
||||
|
||||
void G4GeometricRepresentationContextCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "G4GeometryCreator.hh"
|
||||
#include "G4GeometryTable.hh"
|
||||
|
||||
InstMgr G4GeometryCreator::instanceManager;
|
||||
G4int G4GeometryCreator::objectId = 0;
|
||||
|
||||
STEPattribute* G4GeometryCreator::GetNamedAttribute(G4String& attrName, STEPentity& Ent)
|
||||
{
|
||||
STEPattribute* attr;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
G4int attrCount = Ent.AttributeCount();
|
||||
|
||||
for(G4int a=0;a<attrCount;a++)
|
||||
{
|
||||
attr = Ent.NextAttribute();
|
||||
if(attr->Name() == attrName)
|
||||
return attr;
|
||||
}
|
||||
|
||||
G4String err = "\nCannot find attribute " + attrName + " in entity " + Ent.EntityName();
|
||||
G4Exception(err);
|
||||
return 0; // NULL
|
||||
}
|
||||
|
||||
STEPentity* G4GeometryCreator::GetNamedEntity(G4String& entName, STEPentity& Ent)
|
||||
{
|
||||
// Ent is a complex entity
|
||||
|
||||
if(Ent.IsComplex())
|
||||
{
|
||||
Ent.ResetAttributes();
|
||||
STEPcomplex *complexEnt = (STEPcomplex*)&Ent;
|
||||
STEPentity* subEnt=0;
|
||||
|
||||
G4int entCount = complexEnt->AttributeCount();
|
||||
|
||||
for(G4int a=0;a<entCount;a++)
|
||||
{
|
||||
subEnt = complexEnt->sc;
|
||||
if(subEnt->EntityName() == entName)
|
||||
return subEnt;
|
||||
}
|
||||
}
|
||||
G4String err = "\nCannot find entity " + entName + " in complex entity " + Ent.EntityName();
|
||||
G4Exception(err);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
G4int[][] G4GeometryCreator::GetIds(GenericAggregate& aggr)
|
||||
{
|
||||
// Gets the file IDs of entities from the string.
|
||||
// hack for 2D-aggregates which do not work properly in the NIST toolkit
|
||||
GenericAggrNode* gNode = (GenericAggrNode*)aggr->GetHead();
|
||||
|
||||
SCLstring str;
|
||||
G4String aggrStr = gNode->asStr(str);
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
#include "G4GeometryTable.hh"
|
||||
#include "includes"
|
||||
|
||||
|
||||
G4GeometryTable G4GeometryTable::gt;
|
||||
G4CreatorVector G4GeometryTable::RegisteredObjects;
|
||||
|
||||
G4GeometryTable::G4GeometryTable()
|
||||
{
|
||||
}
|
||||
|
||||
G4GeometryTable::~G4GeometryTable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
G4bool G4GeometryTable::ExistsInTable(G4String& objectName)
|
||||
{
|
||||
G4bool existsInTable = false;
|
||||
for(G4int a=0;a<RegisteredObjects.length();a++)
|
||||
{
|
||||
G4GeometryCreator* gcTmp = RegisteredObjects(a);
|
||||
G4String rName = gcTmp->Name();
|
||||
if(rName == objectName) existsInTable = true;
|
||||
}
|
||||
return existsInTable;
|
||||
}
|
||||
|
||||
void G4GeometryTable::RegisterObject(G4GeometryCreator* gc)
|
||||
{
|
||||
G4String newName = gc->Name();
|
||||
|
||||
if(!ExistsInTable(newName))
|
||||
RegisteredObjects.append(gc);
|
||||
}
|
||||
|
||||
G4GeometryCreator* G4GeometryTable::GetObject(G4String objectName)
|
||||
{
|
||||
for(G4int a=0;a<RegisteredObjects.length();a++)
|
||||
{
|
||||
G4GeometryCreator* gcTmp = RegisteredObjects(a);
|
||||
G4String rName = gcTmp->Name();
|
||||
if(rName == objectName)
|
||||
return gcTmp;
|
||||
}
|
||||
return (G4GeometryCreator*)0;
|
||||
}
|
||||
|
||||
|
||||
void* G4GeometryTable::CreateObject(STEPentity& Ent)
|
||||
{
|
||||
Ent.ResetAttributes();
|
||||
G4String name = Ent.EntityName();
|
||||
G4GeometryCreator* gctmp = GetObject(name);
|
||||
|
||||
if(gctmp)
|
||||
{
|
||||
gctmp->CreateG4Geometry(Ent);
|
||||
void* obj = gctmp->GetCreatedObject();
|
||||
if (obj == 0) {
|
||||
G4cout << "G4 object of type "
|
||||
<< gctmp->Name() << " not necessary" << endl;
|
||||
} else {
|
||||
G4cout << "Created G4 object of type " << gctmp->Name() << endl;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4String err = "Geometry creator for entity " + name + " not found.";
|
||||
G4cout << err << endl;
|
||||
// G4Exception(err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
void* G4GeometryTable::CreateSTEPObject(void* G4obj, G4String& objName)
|
||||
{
|
||||
|
||||
G4GeometryCreator* gctmp = GetObject(objName);
|
||||
|
||||
if(gctmp)
|
||||
{
|
||||
gctmp->CreateSTEPGeometry(G4obj);
|
||||
void* obj = gctmp->GetCreatedObject();
|
||||
return obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4String err = "\nSTEP creator for entity " + objName + " not found.\n";
|
||||
G4cout << err;
|
||||
// G4Exception(err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void G4GeometryTable::PrintObjectNames()
|
||||
{
|
||||
G4String name;
|
||||
G4GeometryCreator* gc=0;
|
||||
G4int a=0;
|
||||
|
||||
G4int objectCount = RegisteredObjects.length();
|
||||
if(!objectCount)
|
||||
{
|
||||
G4cout << "No registered objects in table." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4cout << "Objects in table:" << endl;
|
||||
|
||||
for(a=0;a<objectCount;a++)
|
||||
{
|
||||
gc = RegisteredObjects[a];
|
||||
name = gc->Name();
|
||||
G4cout << name << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
G4PointCreator a;
|
||||
G4CartesianPointCreator b;
|
||||
G4PointOnCurveCreator c;
|
||||
G4PointOnSurfaceCreator d;
|
||||
G4PointReplicaCreator e;
|
||||
G4VertexPointCreator f;
|
||||
|
||||
G4CurveCreator c1;
|
||||
G4LineCreator c2;
|
||||
G4CircleCreator c3;
|
||||
G4EllipseCreator c4;
|
||||
G4HyperbolaCreator c5;
|
||||
G4ParabolaCreator c6;
|
||||
|
||||
G4EdgeCurveCreator c7;
|
||||
G4BSplineCurveWithKnotsCreator bsc1;
|
||||
|
||||
G4EdgeLoopCreator l1;
|
||||
G4OrientedEdgeCreator e1;
|
||||
G4FaceBoundCreator b1;
|
||||
G4FaceOuterBoundCreator b2 ;
|
||||
|
||||
G4DirectionCreator dir;
|
||||
G4VectorCreator vec;
|
||||
|
||||
G4Axis1PlacementCreator ax1;
|
||||
G4Axis2Placement2dCreator ax2;
|
||||
G4Axis2Placement3dCreator ax3;
|
||||
G4Axis2PlacementCreator ax4;
|
||||
G4Axis2PlacementsCreator ax5;
|
||||
|
||||
G4AdvancedFaceCreator s2;
|
||||
G4PlaneCreator s3;
|
||||
G4CylindricalSurfaceCreator s4;
|
||||
G4FaceSurfaceCreator fsc1;
|
||||
G4ToroidalSurfaceCreator s5;
|
||||
G4SphericalSurfaceCreator s6;
|
||||
G4ConicalSurfaceCreator s7;
|
||||
G4BSplineSurfaceCreator s8;
|
||||
G4BoundedSurfaceCreator s9;
|
||||
G4RationalBSplineSurfaceCreator s10;
|
||||
G4BSplineSurfaceWithKnotsCreator s11;
|
||||
|
||||
G4ClosedShellCreator sc1;
|
||||
G4OpenShellCreator sc2;
|
||||
|
||||
G4AdvancedBrepShapeRepresentationCreator shape1;
|
||||
G4ManifoldSolidBrepCreator ms1;
|
||||
|
||||
G4ConnectedFaceSetCreator cfsc1;
|
||||
|
||||
G4ItemDefinedTransformationCreator trans1;
|
||||
|
||||
G4RepresentationRelationshipCreator reprel1;
|
||||
G4RepresentationRelationshipWithTransformationCreator repretrans;
|
||||
|
||||
G4ContextDependentShapeRepresentationCreator condep1;
|
||||
|
||||
G4ProductDefinitionShapeCreator pdsc;
|
||||
G4ShapeRepresentationRelationshipCreator srrc;
|
||||
G4ShapeRepresentationCreator srcs;
|
||||
|
||||
G4ShapeDefinitionRepresentationCreator sdr;
|
||||
G4GeometricRepresentationContextCreator grc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "G4HyperbolaCreator.hh"
|
||||
|
||||
G4HyperbolaCreator G4HyperbolaCreator::csc;
|
||||
|
||||
G4HyperbolaCreator::G4HyperbolaCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4HyperbolaCreator::~G4HyperbolaCreator(){}
|
||||
|
||||
void G4HyperbolaCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4double semi1,semi_imag;
|
||||
|
||||
// L. Broglia
|
||||
// G4Placement* place;
|
||||
G4Axis2Placement3D* place;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
while(Attr->NonRefType() == STRING_TYPE ||
|
||||
Attr->NonRefType() == sdaiSTRING )
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get the placement
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// L. Broglia
|
||||
// place = (G4Placement*)tmp;
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// get semi axises
|
||||
Attr = Ent.NextAttribute();
|
||||
semi1 = *Attr->ptr.r;
|
||||
|
||||
Attr = Ent.NextAttribute();
|
||||
semi_imag = *Attr->ptr.r;
|
||||
}
|
||||
|
||||
void G4HyperbolaCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "G4ItemDefinedTransformationCreator.hh"
|
||||
|
||||
G4ItemDefinedTransformationCreator G4ItemDefinedTransformationCreator::csc;
|
||||
|
||||
G4ItemDefinedTransformationCreator::G4ItemDefinedTransformationCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ItemDefinedTransformationCreator::~G4ItemDefinedTransformationCreator(){}
|
||||
|
||||
void G4ItemDefinedTransformationCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4PlacementVector* places = new G4PlacementVector();
|
||||
|
||||
// L. Broglia
|
||||
// G4Placement* place=0;
|
||||
G4Axis2Placement3D* place=0;
|
||||
|
||||
G4String attrName("transform_item_1");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// L. Broglia
|
||||
// place = (G4Placement*)tmp;
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
places->append(place);
|
||||
attrName="transform_item_2";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// L. Broglia
|
||||
// place = (G4Placement*)tmp;
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
places->append(place);
|
||||
|
||||
createdObject = places;
|
||||
}
|
||||
|
||||
void G4ItemDefinedTransformationCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "G4LineCreator.hh"
|
||||
|
||||
G4LineCreator G4LineCreator::csc;
|
||||
|
||||
G4LineCreator::G4LineCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4LineCreator::~G4LineCreator(){}
|
||||
|
||||
void G4LineCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4ThreeVector origin;
|
||||
G4ThreeVector dir;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute *Attr;
|
||||
Attr = Ent.NextAttribute();
|
||||
while (Attr->NonRefType() == STRING_TYPE)
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get the line origin
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
origin = *(G4ThreeVector*)tmp;
|
||||
|
||||
// Get the line direction
|
||||
Attr = Ent.NextAttribute();
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
dir = *(G4ThreeVector*)tmp;
|
||||
|
||||
|
||||
G4Line* line = new G4Line();
|
||||
line->Init(origin, dir);
|
||||
createdObject = line;
|
||||
}
|
||||
|
||||
void G4LineCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "G4ManifoldSolidBrepCreator.hh"
|
||||
|
||||
G4ManifoldSolidBrepCreator G4ManifoldSolidBrepCreator::csc;
|
||||
|
||||
G4ManifoldSolidBrepCreator::G4ManifoldSolidBrepCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ManifoldSolidBrepCreator::~G4ManifoldSolidBrepCreator(){}
|
||||
|
||||
void G4ManifoldSolidBrepCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4BREPSolid* sld;
|
||||
|
||||
G4String attrName("outer");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get solid
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
sld = (G4BREPSolid*)tmp;
|
||||
createdObject = sld;
|
||||
}
|
||||
|
||||
void G4ManifoldSolidBrepCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "G4OpenShellCreator.hh"
|
||||
|
||||
G4OpenShellCreator G4OpenShellCreator::csc;
|
||||
|
||||
G4OpenShellCreator::G4OpenShellCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4OpenShellCreator::~G4OpenShellCreator(){}
|
||||
|
||||
void G4OpenShellCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4OpenShellCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "G4OrientedEdgeCreator.hh"
|
||||
|
||||
G4OrientedEdgeCreator G4OrientedEdgeCreator::csc;
|
||||
|
||||
G4OrientedEdgeCreator::G4OrientedEdgeCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4OrientedEdgeCreator::~G4OrientedEdgeCreator(){}
|
||||
|
||||
void G4OrientedEdgeCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4int orientation;
|
||||
G4Curve* crv;
|
||||
|
||||
G4String attrName("edge_element");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get curve
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
crv = (G4Curve*)tmp;
|
||||
|
||||
// Get orientation
|
||||
Attr = Ent.NextAttribute();
|
||||
orientation = *Attr->ptr.i;// INTEGER_TYPE
|
||||
|
||||
crv->SetSameSense(orientation);
|
||||
|
||||
createdObject = crv;
|
||||
}
|
||||
|
||||
void G4OrientedEdgeCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "G4ParabolaCreator.hh"
|
||||
|
||||
G4ParabolaCreator G4ParabolaCreator::csc;
|
||||
|
||||
G4ParabolaCreator::G4ParabolaCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ParabolaCreator::~G4ParabolaCreator(){}
|
||||
|
||||
void G4ParabolaCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4double focal_dist;
|
||||
|
||||
// L. Broglia
|
||||
// G4Placement* place;
|
||||
G4Axis2Placement3D* place;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
while(Attr->NonRefType() == STRING_TYPE ||
|
||||
Attr->NonRefType() == sdaiSTRING )
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get the placement
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// L. Broglia
|
||||
// place = (G4Placement*)tmp;
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// get semi axises
|
||||
Attr = Ent.NextAttribute();
|
||||
focal_dist = *Attr->ptr.r;
|
||||
|
||||
}
|
||||
|
||||
void G4ParabolaCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "G4PlaneCreator.hh"
|
||||
|
||||
G4PlaneCreator G4PlaneCreator::csc;
|
||||
|
||||
G4PlaneCreator::G4PlaneCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4PlaneCreator::~G4PlaneCreator(){}
|
||||
|
||||
void G4PlaneCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// L. Broglia
|
||||
// G4Placement* place;
|
||||
G4Axis2Placement3D* place;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute *Attr;
|
||||
Attr = Ent.NextAttribute();
|
||||
while (Attr->NonRefType() == STRING_TYPE)
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get placement
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
createdObject = new G4FPlane( place->GetRefDirection(),
|
||||
place->GetAxis(),
|
||||
place->GetLocation());
|
||||
}
|
||||
|
||||
void G4PlaneCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "G4PointCreator.hh"
|
||||
|
||||
G4PointCreator G4PointCreator::csc;
|
||||
|
||||
G4PointCreator::G4PointCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4PointCreator::~G4PointCreator(){}
|
||||
|
||||
void G4PointCreator::CreateG4Geometry(STEPentity& Ent){}
|
||||
|
||||
void G4PointCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "G4PointOnCurveCreator.hh"
|
||||
|
||||
G4PointOnCurveCreator G4PointOnCurveCreator::csc;
|
||||
|
||||
G4PointOnCurveCreator::G4PointOnCurveCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4PointOnCurveCreator::~G4PointOnCurveCreator(){}
|
||||
|
||||
void G4PointOnCurveCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Curve* crv=0;
|
||||
G4double pval = 0;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
while(Attr->NonRefType() == STRING_TYPE ||
|
||||
Attr->NonRefType() == sdaiSTRING )
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get basis curve
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void* tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
crv = (G4Curve*)tmp;
|
||||
|
||||
// Get parameter value
|
||||
Attr = Ent.NextAttribute();
|
||||
pval = *Attr->ptr.r;
|
||||
|
||||
createdObject = new G4double(pval);
|
||||
}
|
||||
|
||||
void G4PointOnCurveCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "G4PointOnSurfaceCreator.hh"
|
||||
|
||||
G4PointOnSurfaceCreator G4PointOnSurfaceCreator::csc;
|
||||
|
||||
G4PointOnSurfaceCreator::G4PointOnSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4PointOnSurfaceCreator::~G4PointOnSurfaceCreator(){}
|
||||
|
||||
void G4PointOnSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Surface* srf=0;
|
||||
G4double pval1 = 0;
|
||||
G4double pval2 = 0;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
while(Attr->NonRefType() == STRING_TYPE ||
|
||||
Attr->NonRefType() == sdaiSTRING )
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// Get basis surface
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void * tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
srf = (G4Surface*)tmp;
|
||||
|
||||
// Get parameter values
|
||||
Attr = Ent.NextAttribute();
|
||||
pval1 = *Attr->ptr.r;
|
||||
Attr = Ent.NextAttribute();
|
||||
pval2 = *Attr->ptr.r;
|
||||
|
||||
G4double* dtmp = new G4double[2];
|
||||
dtmp[0] = pval1;
|
||||
dtmp[1] = pval2;
|
||||
|
||||
createdObject = dtmp;
|
||||
}
|
||||
|
||||
void G4PointOnSurfaceCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "G4PointReplicaCreator.hh"
|
||||
|
||||
G4PointReplicaCreator G4PointReplicaCreator::csc;
|
||||
|
||||
G4PointReplicaCreator::G4PointReplicaCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4PointReplicaCreator::~G4PointReplicaCreator(){}
|
||||
|
||||
void G4PointReplicaCreator::CreateG4Geometry(STEPentity& Ent){}
|
||||
|
||||
void G4PointReplicaCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "G4ProductDefinitionShapeCreator.hh"
|
||||
|
||||
G4ProductDefinitionShapeCreator G4ProductDefinitionShapeCreator::csc;
|
||||
|
||||
G4ProductDefinitionShapeCreator::G4ProductDefinitionShapeCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4ProductDefinitionShapeCreator::~G4ProductDefinitionShapeCreator(){}
|
||||
|
||||
void G4ProductDefinitionShapeCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Made by L. Broglia
|
||||
STEPattribute *Attr;
|
||||
|
||||
// tmp
|
||||
G4cout<<"Warning ! G4ProductDefinitionShapeCreator called ..."<<endl;
|
||||
|
||||
G4String attrName("description");
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get description
|
||||
SdaiString Tmpstring = *Attr->ptr.S; // ptr.S --> STRING_TYPE
|
||||
|
||||
attrName = "definition";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get definition
|
||||
SCLundefined Tmpdef = *Attr->ptr.u; // ptr.u --> UNKNOWN_TYPE
|
||||
|
||||
// void *tmp = G4GeometryTable::CreateObject(*TmpEnt);
|
||||
// place = (G4Axis2Placement3D*)tmp;
|
||||
}
|
||||
|
||||
void G4ProductDefinitionShapeCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
#include "G4RationalBSplineSurfaceCreator.hh"
|
||||
|
||||
G4RationalBSplineSurfaceCreator G4RationalBSplineSurfaceCreator::csc;
|
||||
|
||||
G4RationalBSplineSurfaceCreator::G4RationalBSplineSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4RationalBSplineSurfaceCreator::~G4RationalBSplineSurfaceCreator(){}
|
||||
|
||||
void G4RationalBSplineSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4String attrName("weights_data");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPaggregate *weightAggr = Attr->ptr.a;
|
||||
SdaiRational_b_spline_surface* bSpline = new SdaiRational_b_spline_surface(&Ent);
|
||||
bSpline->Weights_data((GenericAggregate*)Attr->ptr.a);
|
||||
|
||||
// Temp solution until NIST supports
|
||||
// two dimensional instances.grrh
|
||||
SCLstring s;
|
||||
const char* Str = weightAggr->asStr(s);
|
||||
G4int rows = weightAggr->EntryCount();
|
||||
G4int cols = 1;
|
||||
G4int counter=0;
|
||||
while (Str[counter] != ')')
|
||||
{
|
||||
if(Str[counter]==',')
|
||||
cols++;
|
||||
counter++;
|
||||
}
|
||||
|
||||
char c;
|
||||
G4int Count=0;
|
||||
G4double* ratVector = new G4double[cols*rows];
|
||||
for(int a=0;a<rows*cols;a++)
|
||||
{
|
||||
c = '(';
|
||||
while(c == '(' || c==',')
|
||||
{
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
int Index=0;
|
||||
char *tmp = new char[16];
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
tmp[Index]='\0';
|
||||
G4double Value = atof(tmp);
|
||||
delete [] tmp;
|
||||
ratVector[a] = Value;
|
||||
|
||||
}
|
||||
/*
|
||||
// base data
|
||||
|
||||
// U dir
|
||||
attrName = "u_multiplicities";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
bSpline->U_multiplicities((IntAggregate*)Attr->ptr.a);
|
||||
STEPaggregate *multAggr = Attr->ptr.a;
|
||||
G4int uMultCount = multAggr->EntryCount();
|
||||
}
|
||||
|
||||
attrName = "u_knots";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
|
||||
STEPaggregate *knotAggr = Attr->ptr.a;
|
||||
G4int uKnotCount = knotAggr->EntryCount();
|
||||
|
||||
G4int totalUKnotCount = 0;
|
||||
IntNode* multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
for(G4int a=0;a<uMultCount;a++)
|
||||
{
|
||||
totalUKnotCount += multiNode->value;
|
||||
multiNode = (IntNode*)multiNode->NextNode();
|
||||
}
|
||||
|
||||
G4KnotVector *uKnots = new G4KnotVector(totalUKnotCount);
|
||||
|
||||
RealNode* knotNode = (RealNode*)knotAggr->GetHead();
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
bSpline->U_knots((RealAggregate*)knotAggr);
|
||||
|
||||
|
||||
|
||||
G4int multValue=0;
|
||||
G4double knotValue=0;
|
||||
G4int index=0;
|
||||
for(a=0;a<uKnotCount;a++)
|
||||
{
|
||||
multValue = multiNode->value;
|
||||
knotValue = knotNode->value;
|
||||
|
||||
for(G4int b=0;b<multValue;b++)
|
||||
{
|
||||
uKnots->PutKnot(index, knotValue);
|
||||
index++;
|
||||
}
|
||||
knotNode = (RealNode*)knotNode->NextNode();
|
||||
}
|
||||
|
||||
}
|
||||
// V dir
|
||||
attrName = "v_multiplicities";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
multAggr = Attr->ptr.a;
|
||||
bSpline->U_multiplicities((IntAggregate*)Attr->ptr.a);
|
||||
G4int vMultCount = multAggr->EntryCount();
|
||||
}
|
||||
attrName = "v_knots";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
knotAggr = Attr->ptr.a;
|
||||
bSpline->V_knots((RealAggregate*)knotAggr);
|
||||
G4int vKnotCount = knotAggr->EntryCount();
|
||||
|
||||
G4int totalVKnotCount = 0;
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
for(a=0;a<uMultCount;a++)
|
||||
{
|
||||
totalVKnotCount += multiNode->value;
|
||||
multiNode = (IntNode*)multiNode->NextNode();
|
||||
}
|
||||
G4KnotVector *vKnots = new G4KnotVector(totalVKnotCount);
|
||||
|
||||
knotNode = (RealNode*)knotAggr->GetHead();
|
||||
multiNode = (IntNode*)multAggr->GetHead();
|
||||
|
||||
multValue=0;
|
||||
knotValue=0;
|
||||
index=0;
|
||||
|
||||
for(a=0;a<uKnotCount;a++)
|
||||
{
|
||||
multValue = multiNode->value;
|
||||
knotValue = knotNode->value;
|
||||
|
||||
for(G4int b=0;b<multValue;b++)
|
||||
{
|
||||
vKnots->PutKnot(index, knotValue);
|
||||
index++;
|
||||
}
|
||||
knotNode = (RealNode*)knotNode->NextNode();
|
||||
}
|
||||
}
|
||||
// b_spline base parts
|
||||
|
||||
G4int u,v;
|
||||
STEPentity* ent=0;
|
||||
G4String attrName("u_degree");
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
u = *Attr->ptr.i;
|
||||
bSpline->U_degree(*Attr->ptr.i);
|
||||
}
|
||||
|
||||
|
||||
attrName = "v_degree";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
v=*Attr->ptr.i;
|
||||
bSpline->V_degree(*Attr->ptr.i);
|
||||
}
|
||||
|
||||
attrName = "control_points_list";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
if(Attr)
|
||||
{
|
||||
STEPaggregate *Aggr = Attr->ptr.a;
|
||||
GenericAggregate* gAggr = (GenericAggregate*)Attr->ptr.a;
|
||||
bSpline->Control_points_list(gAggr);
|
||||
// Get control points
|
||||
|
||||
G4int cols,rows;
|
||||
cols = v+1;
|
||||
rows = u+1;
|
||||
|
||||
STEPentity* entity;
|
||||
G4int Index;
|
||||
STEPentity *Entity;
|
||||
char tmp[16];
|
||||
SCLstring s;
|
||||
const char *Str = Aggr->asStr(s);
|
||||
|
||||
G4int stringlength = strlen(Str);
|
||||
G4ControlPoints controlPoints(4,rows, cols);
|
||||
RealAggregate rationalAggr;
|
||||
RealNode* rNode =0;
|
||||
for(G4int a=0;a<rows;a++)
|
||||
for(G4int b=0;b<cols;b++)
|
||||
{
|
||||
// get points
|
||||
|
||||
// temp version until the NIST toolkit can handle two dimensional aggregates
|
||||
// The string Str contains the STEP file id:s of the underlying point
|
||||
// entities so well have to parse the string to get them out...arghhh!
|
||||
char c = ' ';
|
||||
int Count=0;
|
||||
// Loop to find the entities
|
||||
|
||||
|
||||
// Fill points
|
||||
//Temporary solution until the STEP toolkit has been updated:
|
||||
|
||||
while(c != '#')
|
||||
{
|
||||
c = Str[Count];
|
||||
Count++;
|
||||
if(Count>stringlength)
|
||||
{
|
||||
G4cout << "\nString index overflow in G4ControlPoints:116";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
c = Str[Count];
|
||||
int Index=0;
|
||||
|
||||
while(c != ',' && c != ')')
|
||||
{
|
||||
tmp[Index]=c;
|
||||
Index++;
|
||||
Count++;
|
||||
c = Str[Count];
|
||||
}
|
||||
tmp[Index]='\0';
|
||||
Index = atoi(tmp);
|
||||
//delete [] tmp;
|
||||
//Entity = InstanceList.GetSTEPentity(Index);
|
||||
MgrNode* MgrTmp = instanceManager.FindFileId(Index);
|
||||
Index = instanceManager.GetIndex(MgrTmp);
|
||||
Entity = instanceManager.GetSTEPentity(Index);
|
||||
void *tmp =G4GeometryTable::CreateObject(*Entity);
|
||||
controlPoints.put(a,b,*(G4PointRat*)tmp);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
createdObject = bSpline;
|
||||
}
|
||||
|
||||
void G4RationalBSplineSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
#include "G4RepresentationRelationshipCreator.hh"
|
||||
#include "G4PlacementVector.hh"
|
||||
|
||||
G4RepresentationRelationshipCreator G4RepresentationRelationshipCreator::csc;
|
||||
G4int G4RepresentationRelationshipCreator::placeCount=0;
|
||||
G4RepresentationRelationshipCreator::G4RepresentationRelationshipCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4RepresentationRelationshipCreator::~G4RepresentationRelationshipCreator(){}
|
||||
|
||||
void G4RepresentationRelationshipCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
STEPcomplex* complexEnt = (STEPcomplex*)&Ent;
|
||||
void* tmp=0;
|
||||
STEPentity* subEnt=0;
|
||||
STEPentity* subEnt2=0;
|
||||
G4String attrName;
|
||||
STEPattribute *Attr;
|
||||
|
||||
G4PlacementVector* itemDefPlaces;
|
||||
G4PlacementVector* places;
|
||||
G4PlacedSolid* sld;
|
||||
G4PlacedSolid* tmpsld;
|
||||
G4PlacedSolidVector* sldV = new G4PlacedSolidVector();
|
||||
G4PlacedSolidVector* tmpsldV;
|
||||
|
||||
if(complexEnt->EntityExists("Representation_Relationship"))
|
||||
{
|
||||
subEnt = complexEnt->EntityPart("Representation_Relationship");
|
||||
|
||||
// get subparts
|
||||
attrName = "rep_1";
|
||||
Attr = GetNamedAttribute(attrName, *subEnt);
|
||||
subEnt2 = *Attr->ptr.c;
|
||||
places = (G4PlacementVector*)G4GeometryTable::CreateObject(*subEnt2);
|
||||
|
||||
attrName = "rep_2";
|
||||
Attr = GetNamedAttribute(attrName, *subEnt);
|
||||
subEnt2 = *Attr->ptr.c;
|
||||
tmpsldV = (G4PlacedSolidVector*)G4GeometryTable::CreateObject(*subEnt2);
|
||||
}
|
||||
|
||||
if( complexEnt->EntityExists
|
||||
("Representation_Relationship_With_Transformation") )
|
||||
{
|
||||
subEnt = complexEnt->EntityPart
|
||||
("Representation_Relationship_With_Transformation");
|
||||
|
||||
// get subparts
|
||||
attrName = "transformation_operator";
|
||||
Attr = GetNamedAttribute(attrName, *subEnt);
|
||||
SdaiSelect* sel = Attr->ptr.sh;
|
||||
|
||||
G4String underlyingTypeName(G4String(sel->UnderlyingTypeName()));
|
||||
G4String itemDefined("Item_Defined_Transformation");
|
||||
|
||||
if(underlyingTypeName == itemDefined)
|
||||
{
|
||||
G4String koe;
|
||||
SdaiTransformation* transf = (SdaiTransformation*)sel;
|
||||
|
||||
SdaiItem_defined_transformation* iTransf =
|
||||
transf->operator SdaiItem_defined_transformationH();
|
||||
|
||||
SdaiRepresentation_itemH repItem1 = iTransf->Transform_item_1();
|
||||
SdaiRepresentation_itemH repItem2 = iTransf->Transform_item_2();
|
||||
|
||||
subEnt = (STEPentity*)repItem1;
|
||||
itemDefPlaces = new G4PlacementVector();
|
||||
itemDefPlaces->append( ( (G4Axis2Placement3D*)G4GeometryTable::
|
||||
CreateObject(*subEnt) ) );
|
||||
|
||||
subEnt = (STEPentity*)repItem2;
|
||||
itemDefPlaces->append( ( (G4Axis2Placement3D*)G4GeometryTable::
|
||||
CreateObject(*subEnt) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// subEnt2 = *Attr->ptr.c;
|
||||
// G4GeometryTable::CreateObject(*subEnt2);
|
||||
}
|
||||
|
||||
if(complexEnt->EntityExists("Shape_Representation_Relationship"))
|
||||
subEnt = complexEnt->EntityPart("Shape_Representation_Relationship");
|
||||
|
||||
|
||||
G4Axis2Placement3D* place = (G4Axis2Placement3D*)places->at(placeCount);
|
||||
placeCount++;
|
||||
|
||||
// the following line is probably wrong. The combination of
|
||||
// the two transformations should be taken (?)
|
||||
//G4PlacedSolid* ps=new G4PlacedSolid((G4BREPSolid*)sld->GetSolid(), place);
|
||||
|
||||
// place the advanced BREP, so place each manifold solids
|
||||
G4int entr = tmpsldV->entries();
|
||||
for(G4int a = 0; a < entr; a++)
|
||||
{
|
||||
tmpsld = tmpsldV->at(a);
|
||||
sld = new G4PlacedSolid((G4BREPSolid*)tmpsld->GetSolid(), place);
|
||||
sldV->append(sld);
|
||||
}
|
||||
|
||||
createdObject = sldV;
|
||||
}
|
||||
|
||||
void G4RepresentationRelationshipCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#include "G4RepresentationRelationshipWithTransformationCreator.hh"
|
||||
|
||||
G4RepresentationRelationshipWithTransformationCreator G4RepresentationRelationshipWithTransformationCreator::csc;
|
||||
|
||||
G4RepresentationRelationshipWithTransformationCreator::G4RepresentationRelationshipWithTransformationCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4RepresentationRelationshipWithTransformationCreator::~G4RepresentationRelationshipWithTransformationCreator(){}
|
||||
|
||||
void G4RepresentationRelationshipWithTransformationCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4RepresentationRelationshipWithTransformationCreator::CreateSTEPGeometry(void * G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "G4ShapeDefinitionRepresentationCreator.hh"
|
||||
|
||||
G4ShapeDefinitionRepresentationCreator G4ShapeDefinitionRepresentationCreator::csc;
|
||||
|
||||
G4ShapeDefinitionRepresentationCreator::G4ShapeDefinitionRepresentationCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ShapeDefinitionRepresentationCreator::~G4ShapeDefinitionRepresentationCreator(){}
|
||||
|
||||
void G4ShapeDefinitionRepresentationCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4String attrName("used_representation");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPentity* TmpEnt = *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
G4PlacedSolid* ps = (G4PlacedSolid*)tmp;
|
||||
createdObject = ps;
|
||||
|
||||
/*
|
||||
// Output messages
|
||||
G4cout<<"Shape definition representation created with "
|
||||
<<"the Advanced Brep shape :"<<endl;
|
||||
|
||||
G4cout<<" - BBox of the solid :"<<endl;
|
||||
G4cout<< " box min: "
|
||||
<< ((G4BREPSolid*)ps->GetSolid())->GetBBox()->GetBoxMin().x()<< " "
|
||||
<< ((G4BREPSolid*)ps->GetSolid())->GetBBox()->GetBoxMin().y()<< " "
|
||||
<< ((G4BREPSolid*)ps->GetSolid())->GetBBox()->GetBoxMin().z()<< endl;
|
||||
|
||||
G4cout<< " box max: "
|
||||
<< ((G4BREPSolid*)ps->GetSolid())->GetBBox()->GetBoxMax().x()<< " "
|
||||
<< ((G4BREPSolid*)ps->GetSolid())->GetBBox()->GetBoxMax().y()<< " "
|
||||
<< ((G4BREPSolid*)ps->GetSolid())->GetBBox()->GetBoxMax().z()<< endl;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void G4ShapeDefinitionRepresentationCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "G4ShapeRepresentationCreator.hh"
|
||||
|
||||
G4ShapeRepresentationCreator G4ShapeRepresentationCreator::csc;
|
||||
|
||||
G4ShapeRepresentationCreator::G4ShapeRepresentationCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ShapeRepresentationCreator::~G4ShapeRepresentationCreator(){}
|
||||
|
||||
void G4ShapeRepresentationCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
STEPentity* TmpEnt = 0;
|
||||
G4String attrName("items");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
EntityAggregate *ea = (EntityAggregate*)Attr->ptr.a;
|
||||
void *tmp=0;
|
||||
|
||||
G4int placementCount = ea->EntryCount();
|
||||
EntityNode* en = (EntityNode*)ea->GetHead();
|
||||
G4PlacementVector *placements = new G4PlacementVector();
|
||||
|
||||
// L. Broglia
|
||||
// G4Placement* place;
|
||||
G4Axis2Placement3D* place;
|
||||
|
||||
for(G4int a=0;a<placementCount;a++)
|
||||
{
|
||||
TmpEnt = en->node;
|
||||
|
||||
// L. Broglia
|
||||
// place =(G4Placement*)G4GeometryTable::CreateObject(*TmpEnt);
|
||||
place =(G4Axis2Placement3D*)G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
placements->append(place);
|
||||
en = (EntityNode*)en->NextNode();
|
||||
}
|
||||
|
||||
attrName="context_of_items";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
TmpEnt = *Attr->ptr.c;
|
||||
tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
createdObject = placements;
|
||||
}
|
||||
|
||||
void G4ShapeRepresentationCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "G4ShapeRepresentationRelationshipCreator.hh"
|
||||
|
||||
G4ShapeRepresentationRelationshipCreator G4ShapeRepresentationRelationshipCreator::csc;
|
||||
|
||||
G4ShapeRepresentationRelationshipCreator::G4ShapeRepresentationRelationshipCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ShapeRepresentationRelationshipCreator::~G4ShapeRepresentationRelationshipCreator(){}
|
||||
|
||||
void G4ShapeRepresentationRelationshipCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void G4ShapeRepresentationRelationshipCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "G4SphericalSurfaceCreator.hh"
|
||||
|
||||
G4SphericalSurfaceCreator G4SphericalSurfaceCreator::csc;
|
||||
|
||||
G4SphericalSurfaceCreator::G4SphericalSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4SphericalSurfaceCreator::~G4SphericalSurfaceCreator(){}
|
||||
|
||||
void G4SphericalSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// Made by L. Broglia
|
||||
|
||||
STEPattribute *Attr;
|
||||
G4Axis2Placement3D* place;
|
||||
G4double radius;
|
||||
|
||||
G4String attrName("position");
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get placement
|
||||
STEPentity* TmpEnt = *Attr->ptr.c; // ptr.c --> ENTITY_TYPE
|
||||
void *tmp = G4GeometryTable::CreateObject(*TmpEnt);
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// Get radius
|
||||
G4String attrNameR("radius");
|
||||
Attr = GetNamedAttribute(attrNameR, Ent);
|
||||
radius = *Attr->ptr.r;
|
||||
|
||||
|
||||
G4SphericalSurface* aG4sphere =
|
||||
new G4SphericalSurface( (*place).GetLocation() ,
|
||||
(*place).GetPX() ,
|
||||
(*place).GetPZ() ,
|
||||
radius ,
|
||||
0, 2*M_PI ,
|
||||
0, M_PI );
|
||||
|
||||
createdObject = aG4sphere;
|
||||
|
||||
}
|
||||
|
||||
void G4SphericalSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
G4SphericalSurface* fSph = (G4SphericalSurface*)G4obj;
|
||||
SdaiSpherical_surface* srf= new SdaiSpherical_surface();
|
||||
// Get placement
|
||||
G4String placementName("Axis2Placement3d");
|
||||
void * tmp =G4GeometryTable::CreateSTEPObject(&fSph, placementName);
|
||||
SdaiAxis2_placement_3d *place = (SdaiAxis2_placement_3d*)tmp;
|
||||
srf->Position(place);
|
||||
// radius
|
||||
srf->Radius(fSph->GetRadius());
|
||||
|
||||
// Set STEP info
|
||||
srf->SetFileId(GetNextId());
|
||||
srf->Name("");
|
||||
|
||||
// Write out object
|
||||
srf->STEPwrite(G4cout);
|
||||
|
||||
createdObject = srf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "G4ToroidalSurfaceCreator.hh"
|
||||
|
||||
G4ToroidalSurfaceCreator G4ToroidalSurfaceCreator::csc;
|
||||
|
||||
G4ToroidalSurfaceCreator::G4ToroidalSurfaceCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4ToroidalSurfaceCreator::~G4ToroidalSurfaceCreator(){}
|
||||
|
||||
void G4ToroidalSurfaceCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4Axis2Placement3D* place;
|
||||
G4double majorRadius, minorRadius;
|
||||
|
||||
// Get the placement
|
||||
G4String attrName("position");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
place = (G4Axis2Placement3D*)tmp;
|
||||
|
||||
// get radii
|
||||
attrName = "major_radius";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
majorRadius = *Attr->ptr.r;
|
||||
attrName = "minor_radius";
|
||||
Attr = GetNamedAttribute(attrName, Ent);
|
||||
minorRadius = *Attr->ptr.r;
|
||||
|
||||
|
||||
G4ToroidalSurface* aTorus = new G4ToroidalSurface( (*place).GetLocation() ,
|
||||
(*place).GetPZ() ,
|
||||
(*place).GetPX() ,
|
||||
minorRadius ,
|
||||
majorRadius );
|
||||
createdObject = aTorus;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void G4ToroidalSurfaceCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
G4ToroidalSurface* tor = (G4ToroidalSurface*)G4obj;
|
||||
SdaiToroidal_surface* srf= new SdaiToroidal_surface();
|
||||
// Get placement
|
||||
G4String placementName("Axis2Placement3d");
|
||||
void * tmp =G4GeometryTable::CreateSTEPObject(&tor, placementName);
|
||||
SdaiAxis2_placement_3d *place = (SdaiAxis2_placement_3d*)tmp;
|
||||
srf->Position(place);
|
||||
// radiis
|
||||
srf->Minor_radius(tor->GetMinRadius());
|
||||
srf->Major_radius(tor->GetMaxRadius());
|
||||
|
||||
// Set STEP info
|
||||
srf->SetFileId(GetNextId());
|
||||
srf->Name("");
|
||||
|
||||
// Write out object
|
||||
srf->STEPwrite(G4cout);
|
||||
|
||||
createdObject = srf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "G4VectorCreator.hh"
|
||||
|
||||
G4VectorCreator G4VectorCreator::csc;
|
||||
|
||||
G4VectorCreator::G4VectorCreator(){G4GeometryTable::RegisterObject(this);}
|
||||
|
||||
G4VectorCreator::~G4VectorCreator(){}
|
||||
|
||||
void G4VectorCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
G4double Magnitude;
|
||||
G4ThreeVector* place;
|
||||
|
||||
Ent.ResetAttributes();
|
||||
STEPattribute* Attr = Ent.NextAttribute();
|
||||
Attr = Ent.NextAttribute();
|
||||
|
||||
// get the orientation
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void *tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
place = (G4ThreeVector*)tmp;
|
||||
|
||||
// get Magnitude
|
||||
Attr = Ent.NextAttribute();
|
||||
Magnitude = *Attr->ptr.r;
|
||||
|
||||
createdObject = new G4ThreeVector(Magnitude * place->x(),
|
||||
Magnitude * place->y(),
|
||||
Magnitude * place->z()
|
||||
);
|
||||
}
|
||||
|
||||
void G4VectorCreator::CreateSTEPGeometry(void* G4obj)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "G4VertexPointCreator.hh"
|
||||
|
||||
G4VertexPointCreator G4VertexPointCreator::csc;
|
||||
|
||||
G4VertexPointCreator::G4VertexPointCreator()
|
||||
{
|
||||
G4GeometryTable::RegisterObject(this);
|
||||
}
|
||||
|
||||
G4VertexPointCreator::~G4VertexPointCreator(){}
|
||||
|
||||
void G4VertexPointCreator::CreateG4Geometry(STEPentity& Ent)
|
||||
{
|
||||
// G4Point3d *point;
|
||||
G4Point3D *point;
|
||||
|
||||
G4String attrName("vertex_geometry");
|
||||
STEPattribute *Attr = GetNamedAttribute(attrName, Ent);
|
||||
|
||||
// Get the geometric point
|
||||
STEPentity* TmpEnt= *Attr->ptr.c;
|
||||
void * tmp =G4GeometryTable::CreateObject(*TmpEnt);
|
||||
|
||||
// point = (G4Point3d*)tmp;
|
||||
point = (G4Point3D*)tmp;
|
||||
createdObject = point;
|
||||
}
|
||||
|
||||
void G4VertexPointCreator::CreateSTEPGeometry(void* G4obj){}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user