mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
GeomServer: precision on double formatting, compound in meters, bounding box also from compound
This commit is contained in:
@@ -82,7 +82,7 @@ TopoDS_Shape apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t) {
|
||||
}
|
||||
}
|
||||
|
||||
TopoDS_Compound IfcGeom::Representation::BRep::as_compound() const {
|
||||
TopoDS_Compound IfcGeom::Representation::BRep::as_compound(bool force_meters) const {
|
||||
TopoDS_Compound compound;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(compound);
|
||||
@@ -90,7 +90,7 @@ TopoDS_Compound IfcGeom::Representation::BRep::as_compound() const {
|
||||
const TopoDS_Shape& s = it->Shape();
|
||||
gp_GTrsf trsf = it->Placement();
|
||||
|
||||
if (settings().get(IteratorSettings::CONVERT_BACK_UNITS)) {
|
||||
if (!force_meters && settings().get(IteratorSettings::CONVERT_BACK_UNITS)) {
|
||||
gp_Trsf scale;
|
||||
scale.SetScaleFactor(1.0 / settings().unit_magnitude());
|
||||
trsf.PreMultiply(scale);
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace IfcGeom {
|
||||
IfcGeom::IfcRepresentationShapeItems::const_iterator end() const { return shapes_.end(); }
|
||||
const IfcGeom::IfcRepresentationShapeItems& shapes() const { return shapes_; }
|
||||
const std::string& id() const { return id_; }
|
||||
TopoDS_Compound as_compound() const;
|
||||
TopoDS_Compound as_compound(bool force_meters = false) const;
|
||||
|
||||
bool calculate_volume(double&) const;
|
||||
bool calculate_surface_area(double&) const;
|
||||
|
||||
@@ -91,10 +91,18 @@ std::string format_json(const std::string& s) {
|
||||
return "\"" + s + "\"";
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string format_json(const double& d) {
|
||||
std::stringstream ss;
|
||||
ss << std::setprecision(std::numeric_limits<double>::digits10) << d;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string format_json(const gp_Dir& d) {
|
||||
std::stringstream ss;
|
||||
ss << "[" << d.X() << "," << d.Y() << "," << d.Z() << "]";
|
||||
ss << std::setprecision(std::numeric_limits<double>::digits10)
|
||||
<< "[" << d.X() << "," << d.Y() << "," << d.Z() << "]";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@@ -470,7 +478,7 @@ public:
|
||||
boost::optional<gp_Dir> largest_face_dir;
|
||||
|
||||
{
|
||||
TopoDS_Compound compound = elem_->geometry().as_compound();
|
||||
TopoDS_Compound compound = elem_->geometry().as_compound(true);
|
||||
TopExp_Explorer exp(compound, TopAbs_FACE);
|
||||
for (; exp.More(); exp.Next()) {
|
||||
GProp_GProps prop;
|
||||
@@ -488,20 +496,11 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (largest_face_dir) {
|
||||
put_json(LARGEST_FACE_DIRECTION, *largest_face_dir);
|
||||
put_json(LARGEST_FACE_AREA, largest_face_area);
|
||||
}
|
||||
|
||||
{
|
||||
Bnd_Box box;
|
||||
double xyz[6];
|
||||
double xyz[6];
|
||||
|
||||
for (auto& part : elem->geometry()) {
|
||||
BRepBndLib::AddClose(part.Shape(), box);
|
||||
}
|
||||
BRepBndLib::AddClose(compound, box);
|
||||
|
||||
if (!box.IsVoid()) {
|
||||
box.Get(xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5]);
|
||||
@@ -510,7 +509,11 @@ public:
|
||||
put_json(BOUNDING_BOX_SIZE_ALONG_ + XYZ[i], bsz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (largest_face_dir) {
|
||||
put_json(LARGEST_FACE_DIRECTION, *largest_face_dir);
|
||||
put_json(LARGEST_FACE_AREA, largest_face_area);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user