| 918 | } |
| 919 | |
| 920 | void mapping::initialize_settings() { |
| 921 | settings_.get<settings::LengthUnit>().value = length_unit_; |
| 922 | settings_.get<settings::PlaneUnit>().value = angle_unit_; |
| 923 | |
| 924 | // Set precision from file |
| 925 | double lowest_precision_encountered = std::numeric_limits<double>::infinity(); |
| 926 | bool any_precision_encountered = false; |
| 927 | |
| 928 | IfcSchema::IfcGeometricRepresentationContext::list::it it; |
| 929 | IfcSchema::IfcGeometricRepresentationContext::list::ptr contexts = |
| 930 | file_->instances_by_type_excl_subtypes<IfcSchema::IfcGeometricRepresentationContext>(); |
| 931 | |
| 932 | for (it = contexts->begin(); it != contexts->end(); ++it) { |
| 933 | IfcSchema::IfcGeometricRepresentationContext* context = *it; |
| 934 | |
| 935 | // See if there is a context_id filter and whether the context is selected |
| 936 | if (settings_.get<settings::ContextIds>().has()) { |
| 937 | auto cids = settings_.get<settings::ContextIds>().get(); |
| 938 | if (cids.find(context->id()) == cids.end()) { |
| 939 | bool selected_sub_context = false; |
| 940 | auto subs = context->HasSubContexts(); |
| 941 | for (auto& sub : *subs) { |
| 942 | if (cids.find(context->id()) != cids.end()) { |
| 943 | selected_sub_context = true; |
| 944 | break; |
| 945 | } |
| 946 | } |
| 947 | if (!selected_sub_context) { |
| 948 | continue; |
| 949 | } |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | auto fp = settings_.get<settings::PrecisionFactor>().get(); |
| 954 | if (context->Precision() && (*context->Precision() * length_unit_ * fp) < lowest_precision_encountered) { |
| 955 | // Some arbitrary factor that has proven to work better for the models in the set of test files. |
| 956 | lowest_precision_encountered = *context->Precision() * length_unit_ * fp; |
| 957 | any_precision_encountered = true; |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | double precision_to_set = 1.e-5; |
| 962 | |
| 963 | if (any_precision_encountered) { |
| 964 | if (lowest_precision_encountered < 1.e-7) { |
| 965 | Logger::Message(Logger::LOG_WARNING, "Precision lower than 0.0000001 meter not enforced"); |
| 966 | precision_to_set = 1.e-7; |
| 967 | } else { |
| 968 | precision_to_set = lowest_precision_encountered; |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | settings_.get<Precision>().value = precision_to_set; |
| 973 | } |
| 974 | |
| 975 | bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layerset_information& info, int &) |
| 976 | { |