| 98 | } |
| 99 | |
| 100 | void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, boost::optional<std::vector<double>> dash_array) { |
| 101 | /* ShapeFix_Wire fix; |
| 102 | Handle(ShapeExtend_WireData) data = new ShapeExtend_WireData; |
| 103 | for (TopExp_Explorer edges(result, TopAbs_EDGE); edges.More(); edges.Next()) { |
| 104 | data->Add(edges.Current()); |
| 105 | } |
| 106 | fix.Load(data); |
| 107 | fix.FixReorder(); |
| 108 | fix.FixConnected(); |
| 109 | const TopoDS_Wire fixed_wire = fix.Wire(); */ |
| 110 | |
| 111 | util::string_buffer path; |
| 112 | |
| 113 | std::list<TopoDS_Shape> wires; |
| 114 | if (comp_or_wire.ShapeType() == TopAbs_WIRE) { |
| 115 | wires.push_back(comp_or_wire); |
| 116 | } else if (comp_or_wire.ShapeType() == TopAbs_COMPOUND) { |
| 117 | TopoDS_Iterator it(comp_or_wire); |
| 118 | for (; it.More(); it.Next()) { |
| 119 | wires.push_back(it.Value()); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | bool first_wire = true; |
| 124 | |
| 125 | for (auto& wire : wires) { |
| 126 | |
| 127 | bool first = true; |
| 128 | |
| 129 | for (TopExp_Explorer edges(wire, TopAbs_EDGE); edges.More(); edges.Next()) { |
| 130 | const TopoDS_Edge& edge = TopoDS::Edge(edges.Current()); |
| 131 | |
| 132 | double u1, u2; |
| 133 | Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, u1, u2); |
| 134 | Handle(Geom2d_Curve) curve2d; |
| 135 | if (curve.IsNull()) { |
| 136 | TopLoc_Location loc; |
| 137 | Handle_Geom_Surface surf; |
| 138 | |
| 139 | BRep_Tool::CurveOnSurface(edge, curve2d, surf, loc, u1, u2); |
| 140 | |
| 141 | if (curve2d.IsNull()) { |
| 142 | Logger::Error("Failed to obtain 2d and 3d curve from edge"); |
| 143 | continue; |
| 144 | } |
| 145 | |
| 146 | Handle(Standard_Type) sty = surf->DynamicType(); |
| 147 | if (sty != STANDARD_TYPE(Geom_Plane)) { |
| 148 | Logger::Error("Non-planar p-curves are not supported by this serializer"); |
| 149 | continue; |
| 150 | } |
| 151 | |
| 152 | gp_Pln pln = Handle(Geom_Plane)::DownCast(surf)->Pln(); |
| 153 | curve = GeomAPI::To3d(curve2d, pln); |
| 154 | } |
| 155 | |
| 156 | Handle(Standard_Type) ty = curve->DynamicType(); |
| 157 | bool conical = (ty == STANDARD_TYPE(Geom_Circle) || ty == STANDARD_TYPE(Geom_Ellipse)); |
nothing calls this directly
no test coverage detected