View | Details | Raw Unified | Return to problem 1947
Collapse All | Expand All

(-)geant4.10.03/examples/extended/persistency/gdml/G01/opticalsurfaces.gdml (-1 / +5 lines)
Lines 13-18 Link Here
13
                                          5.0 -11.1"/>
13
                                          5.0 -11.1"/>
14
14
15
  <matrix name="RINDEX" coldim="2" values="1.65*eV 1.58" />
15
  <matrix name="RINDEX" coldim="2" values="1.65*eV 1.58" />
16
  <matrix name="REFLECTIVITY" coldim="2" values="1.65*eV 0.8" />
16
 </define>
17
 </define>
17
18
18
 <materials>
19
 <materials>
Lines 37-42 Link Here
37
  <box aunit="radian" lunit="mm" name="world" x="10000" y="10000" z="10000" />
38
  <box aunit="radian" lunit="mm" name="world" x="10000" y="10000" z="10000" />
38
  <box aunit="radian" lunit="mm" name="det" x="2000" y="2000" z="2000" />
39
  <box aunit="radian" lunit="mm" name="det" x="2000" y="2000" z="2000" />
39
  <opticalsurface name="surf1" model="glisur" finish="polished" type="dielectric_dielectric" value="1.0"/>
40
  <opticalsurface name="surf1" model="glisur" finish="polished" type="dielectric_dielectric" value="1.0"/>
41
  <opticalsurface name="surf2" model="glisur" finish="polished" type="dielectric_metal" value="1.0">
42
    <property name="REFLECTIVITY" ref="REFLECTIVITY" />
43
  </opticalsurface>
40
 </solids>
44
 </solids>
41
45
42
 <structure>
46
 <structure>
Lines 61-67 Link Here
61
    <volumeref ref="Detector"/>
65
    <volumeref ref="Detector"/>
62
  </skinsurface> 
66
  </skinsurface> 
63
67
64
  <bordersurface name="bordersrf1" surfaceproperty="surf1" >
68
  <bordersurface name="bordersrf1" surfaceproperty="surf2" >
65
    <physvolref ref="pv1"/>
69
    <physvolref ref="pv1"/>
66
    <physvolref ref="pv2"/>
70
    <physvolref ref="pv2"/>
67
  </bordersurface> 
71
  </bordersurface> 
(-)geant4.10.03/source/persistency/gdml/include/G4GDMLReadSolids.hh (+2 lines)
Lines 49-54 Link Here
49
class G4QuadrangularFacet;
49
class G4QuadrangularFacet;
50
class G4TriangularFacet;
50
class G4TriangularFacet;
51
class G4SurfaceProperty;
51
class G4SurfaceProperty;
52
class G4OpticalSurface;
52
53
53
class G4GDMLReadSolids : public G4GDMLReadMaterials
54
class G4GDMLReadSolids : public G4GDMLReadMaterials
54
{
55
{
Lines 107-112 Link Here
107
   zplaneType ZplaneRead(const xercesc::DOMElement* const);
108
   zplaneType ZplaneRead(const xercesc::DOMElement* const);
108
   rzPointType RZPointRead(const xercesc::DOMElement* const);
109
   rzPointType RZPointRead(const xercesc::DOMElement* const);
109
   void OpticalSurfaceRead(const xercesc::DOMElement* const);
110
   void OpticalSurfaceRead(const xercesc::DOMElement* const);
111
   void PropertyRead(const xercesc::DOMElement* const,G4OpticalSurface*);
110
  
112
  
111
};
113
};
112
114
(-)geant4.10.03/source/persistency/gdml/include/G4GDMLWriteSolids.hh (+2 lines)
Lines 141-146 Link Here
141
   void RZPointWrite(xercesc::DOMElement*, const G4double&,const G4double&);
141
   void RZPointWrite(xercesc::DOMElement*, const G4double&,const G4double&);
142
   void OpticalSurfaceWrite(xercesc::DOMElement*,
142
   void OpticalSurfaceWrite(xercesc::DOMElement*,
143
                    const G4OpticalSurface* const);
143
                    const G4OpticalSurface* const);
144
   void PropertyWrite(xercesc::DOMElement*, const G4OpticalSurface* const);
145
144
146
145
  protected:
147
  protected:
146
148
(-)geant4.10.03/source/persistency/gdml/src/G4GDMLReadSolids.cc (-1 / +90 lines)
Lines 69-74 Link Here
69
#include "G4OpticalSurface.hh"
69
#include "G4OpticalSurface.hh"
70
#include "G4UnitsTable.hh"
70
#include "G4UnitsTable.hh"
71
#include "G4SurfaceProperty.hh"
71
#include "G4SurfaceProperty.hh"
72
#include "G4MaterialPropertiesTable.hh"
72
73
73
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
74
G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
74
{
75
{
Lines 2467-2472 Link Here
2467
}
2468
}
2468
2469
2469
void G4GDMLReadSolids::
2470
void G4GDMLReadSolids::
2471
PropertyRead(const xercesc::DOMElement* const propertyElement,
2472
             G4OpticalSurface* opticalsurface)
2473
{
2474
   G4String name;
2475
   G4String ref;
2476
   G4GDMLMatrix matrix;
2477
2478
   const xercesc::DOMNamedNodeMap* const attributes
2479
         = propertyElement->getAttributes();
2480
   XMLSize_t attributeCount = attributes->getLength();
2481
2482
   for (XMLSize_t attribute_index=0;
2483
        attribute_index<attributeCount; attribute_index++)
2484
   {
2485
      xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2486
2487
      if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2488
      { continue; }
2489
2490
      const xercesc::DOMAttr* const attribute
2491
            = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
2492
      if (!attribute)
2493
      {
2494
        G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead",
2495
                    FatalException, "No attribute found!");
2496
        return;
2497
      }
2498
      const G4String attName = Transcode(attribute->getName());
2499
      const G4String attValue = Transcode(attribute->getValue());
2500
2501
      if (attName=="name") { name = GenerateName(attValue); } else
2502
      if (attName=="ref")  { matrix = GetMatrix(ref=attValue); }
2503
   }
2504
2505
   /*
2506
   if (matrix.GetCols() != 2)
2507
   {
2508
     G4String error_msg = "Referenced matrix '" + ref
2509
            + "' should have \n two columns as a property table for opticalsurface: "
2510
            + opticalsurface->GetName();
2511
     G4Exception("G4GDMLReadSolids::PropertyRead()", "InvalidRead",
2512
                 FatalException, error_msg);
2513
   }
2514
   */
2515
2516
   if (matrix.GetRows() == 0) { return; }
2517
2518
   G4MaterialPropertiesTable* matprop=opticalsurface->GetMaterialPropertiesTable();
2519
   if (!matprop)
2520
   {
2521
     matprop = new G4MaterialPropertiesTable();
2522
     opticalsurface->SetMaterialPropertiesTable(matprop);
2523
   }
2524
   if (matrix.GetCols() == 1)  // constant property assumed
2525
   {
2526
     matprop->AddConstProperty(Strip(name), matrix.Get(0,0));
2527
   }
2528
   else  // build the material properties vector
2529
   {
2530
     G4MaterialPropertyVector* propvect = new G4MaterialPropertyVector();
2531
     for (size_t i=0; i<matrix.GetRows(); i++)
2532
     {
2533
       propvect->InsertValues(matrix.Get(i,0),matrix.Get(i,1));
2534
     }
2535
     matprop->AddProperty(Strip(name),propvect);
2536
   }
2537
}
2538
2539
void G4GDMLReadSolids::
2470
OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
2540
OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
2471
{
2541
{
2472
   G4String name;
2542
   G4String name;
Lines 2586-2592 Link Here
2586
      { type = firsov; }
2656
      { type = firsov; }
2587
   else { type = x_ray; }
2657
   else { type = x_ray; }
2588
2658
2589
   new G4OpticalSurface(name,model,finish,type,value);
2659
   G4OpticalSurface* opticalsurface
2660
         = new G4OpticalSurface(name,model,finish,type,value);
2661
2662
   for (xercesc::DOMNode* iter = opticalsurfaceElement->getFirstChild();
2663
        iter != 0;iter = iter->getNextSibling())
2664
   {
2665
      if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
2666
2667
      const xercesc::DOMElement* const child
2668
            = dynamic_cast<xercesc::DOMElement*>(iter);
2669
      if (!child)
2670
      {
2671
        G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()",
2672
                    "InvalidRead", FatalException, "No child found!");
2673
        return;
2674
      }
2675
      const G4String tag = Transcode(child->getTagName());
2676
2677
      if (tag=="property") { PropertyRead(child,opticalsurface); }
2678
   }
2590
}
2679
}
2591
2680
2592
void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
2681
void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
(-)geant4.10.03/source/persistency/gdml/src/G4GDMLWriteSolids.cc (+54 lines)
Lines 69-74 Link Here
69
#include "G4UnionSolid.hh"
69
#include "G4UnionSolid.hh"
70
#include "G4OpticalSurface.hh"
70
#include "G4OpticalSurface.hh"
71
#include "G4SurfaceProperty.hh"
71
#include "G4SurfaceProperty.hh"
72
#include "G4MaterialPropertiesTable.hh"
72
73
73
G4GDMLWriteSolids::G4GDMLWriteSolids()
74
G4GDMLWriteSolids::G4GDMLWriteSolids()
74
  : G4GDMLWriteMaterials(), solidsElement(0)
75
  : G4GDMLWriteMaterials(), solidsElement(0)
Lines 1050-1058 Link Here
1050
   optElement->setAttributeNode(NewAttribute("type", surf->GetType()));
1051
   optElement->setAttributeNode(NewAttribute("type", surf->GetType()));
1051
   optElement->setAttributeNode(NewAttribute("value", sval));
1052
   optElement->setAttributeNode(NewAttribute("value", sval));
1052
1053
1054
   // Write any property attached to the optical surface...
1055
   //
1056
   if (surf->GetMaterialPropertiesTable())
1057
   {
1058
     PropertyWrite(optElement, surf);
1059
   }
1060
1053
   solElement->appendChild(optElement);
1061
   solElement->appendChild(optElement);
1054
}
1062
}
1055
1063
1064
void G4GDMLWriteSolids::PropertyWrite(xercesc::DOMElement* optElement,
1065
                                         const G4OpticalSurface* const surf)
1066
{
1067
   xercesc::DOMElement* propElement;
1068
   G4MaterialPropertiesTable* ptable = surf->GetMaterialPropertiesTable();
1069
   const std::map< G4String, G4PhysicsOrderedFreeVector*,
1070
                 std::less<G4String> >* pmap = ptable->GetPropertiesMap();
1071
   const std::map< G4String, G4double,
1072
                 std::less<G4String> >* cmap = ptable->GetPropertiesCMap();
1073
   std::map< G4String, G4PhysicsOrderedFreeVector*,
1074
                 std::less<G4String> >::const_iterator mpos;
1075
   std::map< G4String, G4double,
1076
                 std::less<G4String> >::const_iterator cpos;
1077
   for (mpos=pmap->begin(); mpos!=pmap->end(); mpos++)
1078
   {
1079
      propElement = NewElement("property");
1080
      propElement->setAttributeNode(NewAttribute("name", mpos->first));
1081
      propElement->setAttributeNode(NewAttribute("ref",
1082
                                    GenerateName(mpos->first, mpos->second)));
1083
      if (mpos->second)
1084
      {
1085
         PropertyVectorWrite(mpos->first, mpos->second);
1086
         optElement->appendChild(propElement);
1087
      }
1088
      else
1089
      {
1090
         G4String warn_message = "Null pointer for material property -"
1091
                  + mpos->first + "- of optical surface -" + surf->GetName() + "- !";
1092
         G4Exception("G4GDMLWriteSolids::PropertyWrite()", "NullPointer",
1093
                     JustWarning, warn_message);
1094
         continue;
1095
      }
1096
   }
1097
   for (cpos=cmap->begin(); cpos!=cmap->end(); cpos++)
1098
   {
1099
      propElement = NewElement("property");
1100
      propElement->setAttributeNode(NewAttribute("name", cpos->first));
1101
      propElement->setAttributeNode(NewAttribute("ref", cpos->first));
1102
      xercesc::DOMElement* constElement = NewElement("constant");
1103
      constElement->setAttributeNode(NewAttribute("name", cpos->first));
1104
      constElement->setAttributeNode(NewAttribute("value", cpos->second));
1105
      defineElement->appendChild(constElement);
1106
      optElement->appendChild(propElement);
1107
   }
1108
}
1109
1056
void G4GDMLWriteSolids::SolidsWrite(xercesc::DOMElement* gdmlElement)
1110
void G4GDMLWriteSolids::SolidsWrite(xercesc::DOMElement* gdmlElement)
1057
{
1111
{
1058
   G4cout << "G4GDML: Writing solids..." << G4endl;
1112
   G4cout << "G4GDML: Writing solids..." << G4endl;

Return to problem 1947