| 1828 | } |
| 1829 | |
| 1830 | void SvgSerializer::addTextAnnotations(const drawing_key& k) { |
| 1831 | auto& meta = drawing_metadata[k]; |
| 1832 | |
| 1833 | boost::optional<std::pair<double, double>> range; |
| 1834 | |
| 1835 | if (k.first && section_data_) { |
| 1836 | for (auto& sd : *section_data_) { |
| 1837 | if (sd.which() == 0) { |
| 1838 | const auto& plan = boost::get<horizontal_plan>(sd); |
| 1839 | if (k.first == plan.storey) { |
| 1840 | range = std::make_pair(plan.elevation, plan.next_elevation); |
| 1841 | } |
| 1842 | } |
| 1843 | } |
| 1844 | } |
| 1845 | |
| 1846 | aggregate_of_instance::ptr annotations; |
| 1847 | if (file) { |
| 1848 | annotations = file->instances_by_type("IfcAnnotation"); |
| 1849 | } |
| 1850 | if (annotations) { |
| 1851 | for (auto& ann_ : *annotations) { |
| 1852 | auto ann = (IfcUtil::IfcBaseEntity*) ann_; |
| 1853 | |
| 1854 | auto ot = ann->get("ObjectType"); |
| 1855 | auto nm = ann->get("Name"); |
| 1856 | auto ds = ann->get("Description"); |
| 1857 | auto pl = ann->get("ObjectPlacement"); |
| 1858 | |
| 1859 | if (!ot.isNull() && !nm.isNull() && !ds.isNull() && !pl.isNull()) { |
| 1860 | auto object_type = (std::string) ot; |
| 1861 | auto name = (std::string) nm; |
| 1862 | auto desc = (std::string) ds; |
| 1863 | |
| 1864 | if (object_type == "Text") { |
| 1865 | auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_); |
| 1866 | auto item = mapping->map(pl); |
| 1867 | auto matrix = ifcopenshell::geometry::taxonomy::cast<ifcopenshell::geometry::taxonomy::matrix4>(item); |
| 1868 | delete mapping; |
| 1869 | if (item) { |
| 1870 | gp_Trsf trsf; |
| 1871 | auto& m = matrix->ccomponents(); |
| 1872 | trsf.SetValues( |
| 1873 | m(0, 0), m(0, 1), m(0, 2), m(0, 3), |
| 1874 | m(1, 0), m(1, 1), m(1, 2), m(1, 3), |
| 1875 | m(2, 0), m(2, 1), m(2, 2), m(2, 3) |
| 1876 | ); |
| 1877 | #ifdef TAXONOMY_USE_NAKED_PTR |
| 1878 | delete matrix; |
| 1879 | #endif |
| 1880 | |
| 1881 | auto v = gp_Pnt(trsf.TranslationPart()); |
| 1882 | |
| 1883 | auto z_local = gp::DZ().Transformed(trsf); |
| 1884 | auto view_dir = z_local.Dot(meta.pln_3d.Axis().Direction()); |
| 1885 | |
| 1886 | if ((!range || (v.Z() >= range->first && v.Z() < range->second)) && view_dir > 0.99) { |
| 1887 | |