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

Method resize

src/serializers/SvgSerializer.cpp:1692–1754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1690}
1691
1692std::array<std::array<double, 3>, 3> SvgSerializer::resize() {
1693 // identity matrix;
1694 std::array<std::array<double, 3>, 3> m = {{ {{1,0,0}},{{0,1,0}},{{0,0,1}} }};
1695
1696 if (size_) {
1697 // Scale the resulting image to a bounding rectangle specified by command line arguments
1698 // or specified by IfcAnnotation[ObjectType=DRAWING]
1699 const double dx = xmax - xmin;
1700 const double dy = ymax - ymin;
1701
1702 double sc, cx, cy;
1703 if (offset_2d_ && scale_) {
1704 // offset_2d is the offset in plane u,v coordinates as we want to keep the
1705 // plane coordinates used for HLR close to the model origin.
1706 sc = (*scale_) * 1000;
1707 cx = offset_2d_->first;
1708 cy = offset_2d_->second;
1709 } else if (scale_) {
1710 sc = (*scale_) * 1000;
1711 cx = (xmax + xmin) / 2. * sc - size_->first * center_x_.get_value_or(0.5);
1712 cy = (ymax + ymin) / 2. * sc - size_->second * center_y_.get_value_or(0.5);
1713 } else {
1714 if (calculated_scale_) {
1715 sc = *calculated_scale_;
1716 }
1717 else {
1718 if (dx / size_->first > dy / size_->second) {
1719 sc = size_->first / dx;
1720 }
1721 else {
1722 sc = size_->second / dy;
1723 }
1724 calculated_scale_ = sc;
1725 }
1726 cx = xmin * sc;
1727 cy = ymin * sc;
1728 }
1729
1730 if (mirror_y_) {
1731 cy = - size_->second - cy;
1732 }
1733 if (mirror_x_) {
1734 cx = - size_->first - cx;
1735 }
1736
1737 m = {{ {{sc,0,-cx}},{{0,sc,-cy}},{{0,0,1}} }};
1738
1739 float_item_list::const_iterator it;
1740 for (it = xcoords.begin() + xcoords_begin; it != xcoords.end(); ++it, ++xcoords_begin) {
1741 double& v = (*it)->value();
1742 v = v * sc - cx;
1743 }
1744 for (it = ycoords.begin() + ycoords_begin; it != ycoords.end(); ++it, ++ycoords_begin) {
1745 double& v = (*it)->value();
1746 v = v * sc - cy;
1747 }
1748 for (it = radii.begin() + radii_begin; it != radii.end(); ++it, ++radii_begin) {
1749 (*it)->value() *= sc;

Callers 15

writeMethod · 0.80
readMethod · 0.80
serializeFunction · 0.80
write_streaming_Method · 0.80
box_project_uvsMethod · 0.80
map_implMethod · 0.80
splitFunction · 0.80
MainWindowMethod · 0.80
__init__Method · 0.80
get_axis2placementFunction · 0.80

Calls 3

beginMethod · 0.45
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected