diff --git a/DDCAD/src/ASSIMPWriter.cpp b/DDCAD/src/ASSIMPWriter.cpp index 1ab11d62739a1da31778118a21a86420b178b646..4b8ddbcba776b1e642c44b5e437d7ce9c32df70b 100644 --- a/DDCAD/src/ASSIMPWriter.cpp +++ b/DDCAD/src/ASSIMPWriter.cpp @@ -314,11 +314,11 @@ int ASSIMPWriter::write(const std::string& file_name, unique_ptr<TGeoHMatrix> trafo(placements[imesh].second); unique_ptr<TGeoTessellated> shape_holder; PlacedVolume pv = placements[imesh].first; - Volume v = pv.volume(); - Solid s = v.solid(); - Material m = v.material(); - TessellatedSolid tes = s; - aiString node_name(v.name()); + Volume vol = pv.volume(); + Solid sol = vol.solid(); + Material mat = vol.material(); + TessellatedSolid tes = sol; + aiString node_name(vol.name()); identity.Clear(); TGeoShape::SetTransform(&identity); @@ -326,15 +326,15 @@ int ASSIMPWriter::write(const std::string& file_name, /// If the shape is already tessellated, no need to create another one! if ( !tes.isValid() ) { TessellateShape helper; - auto* shape=dynamic_cast<TGeoCompositeShape*>(s.ptr()); + auto* shape = dynamic_cast<TGeoCompositeShape*>(sol.ptr()); if ( build_mode || shape ) { // Always use this method! auto* paintVol = detector.manager().GetPaintVolume(); - detector.manager().SetPaintVolume(v.ptr()); - shape_holder = helper.build_mesh(imesh, v.name(), s.ptr()); + detector.manager().SetPaintVolume(vol.ptr()); + shape_holder = helper.build_mesh(imesh, vol.name(), sol.ptr()); detector.manager().SetPaintVolume(paintVol); } else { - shape_holder = helper.tessellate_primitive(v.name(), s); + shape_holder = helper.tessellate_primitive(vol.name(), sol); } tes = shape_holder.get(); } @@ -348,16 +348,16 @@ int ASSIMPWriter::write(const std::string& file_name, size_t index = std::numeric_limits<size_t>::max(); for( size_t j=0; j<materials.size(); ++j ) { - if( materials[j] == m ) { + if( materials[j] == mat ) { index = j; break; } } if ( index > materials.size() ) { - aiString name(m.name()); + aiString name(mat.name()); auto* ai_mat = new aiMaterial(); index = materials.size(); - materials.push_back(m); + materials.push_back(mat); ai_mat->AddProperty(&name, AI_MATKEY_NAME); scene.mMaterials[scene.mNumMaterials] = ai_mat; ++scene.mNumMaterials; @@ -365,9 +365,9 @@ int ASSIMPWriter::write(const std::string& file_name, aiMesh* mesh = new aiMesh; mesh->mName = node_name; mesh->mMaterialIndex = index; - if ( v.visAttributes().isValid() ) { + if ( vol.visAttributes().isValid() ) { float cr = 0e0, cg = 0e0, cb = 0e0, ca = 0e0; - v.visAttributes().argb(ca, cr, cg, cb); + vol.visAttributes().argb(ca, cr, cg, cb); mesh->mColors[0] = new aiColor4D(cr, cg, cb, ca); } mesh->mFaces = new aiFace[tes->GetNfacets()]; diff --git a/DDParsers/src/Evaluator/Evaluator.cpp b/DDParsers/src/Evaluator/Evaluator.cpp index 419f5e98a449ae2c6e35f14e9f391f8e93840c1e..5beb6626c4820de847933606256c1ffe4d010e38 100644 --- a/DDParsers/src/Evaluator/Evaluator.cpp +++ b/DDParsers/src/Evaluator/Evaluator.cpp @@ -43,18 +43,39 @@ //--------------------------------------------------------------------------- #define EVAL dd4hep::tools::Evaluator -/// Internal expression evaluator helper class -struct Item { - enum { UNKNOWN, VARIABLE, EXPRESSION, FUNCTION, STRING } what; - double variable; - std::string expression; - void *function; - - explicit Item() : what(UNKNOWN), variable(0),expression(), function(0) {} - explicit Item(double x) : what(VARIABLE), variable(x),expression(), function(0) {} - explicit Item(std::string x) : what(EXPRESSION),variable(0),expression(x),function(0) {} - explicit Item(void *x) : what(FUNCTION), variable(0),expression(), function(x) {} -}; +namespace { + + /// Internal expression evaluator helper class + struct Item { + enum { UNKNOWN, VARIABLE, EXPRESSION, FUNCTION, STRING } what; + double variable; + std::string expression; + void *function; + + explicit Item() : what(UNKNOWN), variable(0),expression(), function(0) {} + explicit Item(double x) : what(VARIABLE), variable(x),expression(), function(0) {} + explicit Item(std::string x) : what(EXPRESSION),variable(0),expression(x),function(0) {} + explicit Item(void *x) : what(FUNCTION), variable(0),expression(), function(x) {} + }; + + /// Internal expression evaluator helper union + union FCN { + void* ptr; + double (*f0)(); + double (*f1)(double); + double (*f2)(double,double); + double (*f3)(double,double,double); + double (*f4)(double,double,double,double); + double (*f5)(double,double,double,double,double); + FCN(void* p) { ptr = p; } + FCN(double (*f)()) { f0 = f; } + FCN(double (*f)(double)) { f1 = f; } + FCN(double (*f)(double,double)) { f2 = f; } + FCN(double (*f)(double,double,double)) { f3 = f; } + FCN(double (*f)(double,double,double,double)) { f4 = f; } + FCN(double (*f)(double,double,double,double,double)) { f5 = f; } + }; +} //typedef char * pchar; typedef std::unordered_map<std::string,Item> dic_type; @@ -104,27 +125,6 @@ struct EVAL::Object::Struct { std::mutex theLock; }; -namespace { - - /// Internal expression evaluator helper union - union FCN { - void* ptr; - double (*f0)(); - double (*f1)(double); - double (*f2)(double,double); - double (*f3)(double,double,double); - double (*f4)(double,double,double,double); - double (*f5)(double,double,double,double,double); - FCN(void* p) { ptr = p; } - FCN(double (*f)()) { f0 = f; } - FCN(double (*f)(double)) { f1 = f; } - FCN(double (*f)(double,double)) { f2 = f; } - FCN(double (*f)(double,double,double)) { f3 = f; } - FCN(double (*f)(double,double,double,double)) { f4 = f; } - FCN(double (*f)(double,double,double,double,double)) { f5 = f; } - }; -} - //--------------------------------------------------------------------------- #define REMOVE_BLANKS \ for(pointer=name;;pointer++) if (!isspace(*pointer)) break; \