MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / initialize_settings

Method initialize_settings

src/ifcgeom/mapping/mapping.cpp:920–973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

918}
919
920void 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
975bool mapping::get_layerset_information(const IfcUtil::IfcBaseInterface* p, layerset_information& info, int &)
976{

Callers 1

constructMethod · 0.80

Calls 7

MessageClass · 0.85
beginMethod · 0.45
endMethod · 0.45
hasMethod · 0.45
getMethod · 0.45
findMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected