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

Method initialize

src/ifcgeom/Iterator.cpp:18–168  ·  view source on GitHub ↗

* Initialize iterator's list of tasks. * * Will automatically process first element, if 'defer-processing-first-element' is not set to `true`. * * @return Returns true if the iterator is initialized with any elements, false otherwise. * * @note * - A true return value does not guarantee successful initialization of all elements. * Some elements may have failed to initialize. Check had_error_proc

Source from the content-addressed store, hash-verified

16* element fails, even if subsequent elements could be initialized successfully.
17*/
18bool IfcGeom::Iterator::initialize() {
19 using std::chrono::high_resolution_clock;
20
21 if (initialization_outcome_) {
22 return *initialization_outcome_;
23 }
24
25 time_points[0] = high_resolution_clock::now();
26 std::vector<ifcopenshell::geometry::geometry_conversion_task> reps;
27 if (num_threads_ != 1) {
28 // @todo this shouldn't be necessary with properly immutable taxonomy items
29 converter_->mapping()->use_caching() = false;
30 }
31 try {
32 converter_->mapping()->get_representations(reps, filters_);
33 } catch (const std::exception& e) {
34 Logger::Error(e);
35 }
36 time_points[1] = high_resolution_clock::now();
37
38 for (auto& task : reps) {
39 geometry_conversion_result res;
40 res.index = task.index;
41 if (!settings_.get<ifcopenshell::geometry::settings::NoParallelMapping>().get()) {
42 res.representation = task.representation;
43 res.products_2 = task.products;
44 } else {
45 res.item = converter_->mapping()->map(task.representation);
46 if (!res.item) {
47 continue;
48 }
49 std::transform(task.products->begin(), task.products->end(), std::back_inserter(res.products), [this, &res](IfcUtil::IfcBaseClass* prod) {
50 auto prod_item = converter_->mapping()->map(prod);
51 return std::make_pair(prod->as<IfcUtil::IfcBaseEntity>(), ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::geom_item>(prod_item)->matrix);
52 });
53 }
54 tasks_.push_back(res);
55 }
56
57 if (settings_.get<ifcopenshell::geometry::settings::NoParallelMapping>().get() && settings_.get<ifcopenshell::geometry::settings::PermissiveShapeReuse>().get()) {
58 std::unordered_map<
59 ifcopenshell::geometry::taxonomy::item::ptr,
60 std::vector<std::pair<IfcUtil::IfcBaseEntity*, ifcopenshell::geometry::taxonomy::matrix4::ptr>>> folded;
61
62 for (auto& r : tasks_) {
63 auto i = r.item;
64
65 Eigen::Matrix4d m4 = Eigen::Matrix4d::Identity();
66
67 while (auto col = std::dynamic_pointer_cast<ifcopenshell::geometry::taxonomy::collection>(i)) {
68 if (col->children.size() == 1) {
69 if (col->matrix) {
70 m4 *= col->matrix->ccomponents();
71 }
72 i = col->children[0];
73 } else {
74 break;
75 }

Callers 15

add_collision_objectsMethod · 0.45
add_fileMethod · 0.45
mainFunction · 0.45
ParseMethod · 0.45
DoImportMethod · 0.45
to_obj_fileMethod · 0.45
import_ifcFunction · 0.45
IfcConvert.cppFile · 0.45
init_input_fileFunction · 0.45
fix_quantitiesFunction · 0.45
fix_storeycontainmentFunction · 0.45

Calls 14

NoticeFunction · 0.85
to_stringFunction · 0.85
WarningFunction · 0.85
push_backMethod · 0.80
ErrorFunction · 0.50
createFunction · 0.50
get_representationsMethod · 0.45
getMethod · 0.45
mapMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected