mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
--svg-poly option and correct HLR view direction
This commit is contained in:
@@ -376,6 +376,8 @@ int main(int argc, char** argv) {
|
|||||||
"Creates SVG elevation drawings automatically based on model extents")
|
"Creates SVG elevation drawings automatically based on model extents")
|
||||||
("svg-xmlns",
|
("svg-xmlns",
|
||||||
"Stores name and guid in a separate namespace as opposed to data-name, data-guid")
|
"Stores name and guid in a separate namespace as opposed to data-name, data-guid")
|
||||||
|
("svg-poly",
|
||||||
|
"Uses the polygonal algorithm for hidden line rendering")
|
||||||
("door-arcs", "Draw door openings arcs for IfcDoor elements")
|
("door-arcs", "Draw door openings arcs for IfcDoor elements")
|
||||||
("section-height", po::value<double>(§ion_height),
|
("section-height", po::value<double>(§ion_height),
|
||||||
"Specifies the cut section height for SVG 2D geometry.")
|
"Specifies the cut section height for SVG 2D geometry.")
|
||||||
@@ -959,6 +961,7 @@ int main(int argc, char** argv) {
|
|||||||
static_cast<SvgSerializer*>(serializer.get())->setAutoElevation(true);
|
static_cast<SvgSerializer*>(serializer.get())->setAutoElevation(true);
|
||||||
}
|
}
|
||||||
static_cast<SvgSerializer*>(serializer.get())->setUseNamespace(vmap.count("svg-xmlns") > 0);
|
static_cast<SvgSerializer*>(serializer.get())->setUseNamespace(vmap.count("svg-xmlns") > 0);
|
||||||
|
static_cast<SvgSerializer*>(serializer.get())->setUseHlrPoly(vmap.count("svg-poly") > 0);
|
||||||
if (relative_center_x && relative_center_y) {
|
if (relative_center_x && relative_center_y) {
|
||||||
static_cast<SvgSerializer*>(serializer.get())->setDrawingCenter(*relative_center_x, *relative_center_y);
|
static_cast<SvgSerializer*>(serializer.get())->setDrawingCenter(*relative_center_x, *relative_center_y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,8 @@
|
|||||||
|
|
||||||
#include <ShapeFix_Edge.hxx>
|
#include <ShapeFix_Edge.hxx>
|
||||||
|
|
||||||
|
#include <HLRBRep_PolyHLRToShape.hxx>
|
||||||
|
|
||||||
#include "../ifcparse/IfcGlobalId.h"
|
#include "../ifcparse/IfcGlobalId.h"
|
||||||
|
|
||||||
#include "SvgSerializer.h"
|
#include "SvgSerializer.h"
|
||||||
@@ -566,7 +568,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
|||||||
|
|
||||||
auto& compound_to_use = is_floor_plan_ ? compound : compound_unmirrored;
|
auto& compound_to_use = is_floor_plan_ ? compound : compound_unmirrored;
|
||||||
|
|
||||||
if (use_hlr && hlr) {
|
if (use_hlr && (hlr_poly || hlr_brep)) {
|
||||||
|
|
||||||
// Check if any of the bounding box points is on the correct side of the plane
|
// Check if any of the bounding box points is on the correct side of the plane
|
||||||
Bnd_Box bb;
|
Bnd_Box bb;
|
||||||
@@ -593,13 +595,19 @@ void SvgSerializer::write(const geometry_data& data) {
|
|||||||
} else {
|
} else {
|
||||||
state = d < 0. ? -1 : 1;
|
state = d < 0. ? -1 : 1;
|
||||||
}
|
}
|
||||||
if (state == 1) {
|
if (state == -1) {
|
||||||
any = true;
|
any = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (any) {
|
if (any) {
|
||||||
hlr->Add(compound_to_use);
|
if (hlr_brep) {
|
||||||
|
hlr_brep->Add(compound_to_use);
|
||||||
|
}
|
||||||
|
if (hlr_poly) {
|
||||||
|
BRepMesh_IncrementalMesh(compound_to_use, 0.10);
|
||||||
|
hlr_poly->Load(compound_to_use);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -988,30 +996,30 @@ void SvgSerializer::finalize() {
|
|||||||
if (auto_elevation_) {
|
if (auto_elevation_) {
|
||||||
{
|
{
|
||||||
gp_Pln pln(gp_Ax3(
|
gp_Pln pln(gp_Ax3(
|
||||||
gp_Pnt((xmin + xmax) / 2., -(ymin - 1.e-1), 0.),
|
gp_Pnt(0., -(ymin - 10.), 0.),
|
||||||
gp_Dir(0, -1, 0),
|
gp_Dir(0, 1, 0),
|
||||||
gp_Dir(-1, 0, 0)));
|
gp_Dir(1, 0, 0)));
|
||||||
deferred_section_data_->push_back(vertical_section{ pln , "Elevation South", true });
|
deferred_section_data_->push_back(vertical_section{ pln , "Elevation South", true });
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
gp_Pln pln(gp_Ax3(
|
gp_Pln pln(gp_Ax3(
|
||||||
gp_Pnt(xmax + 1.e-1, (ymin + ymax) / -2., 0.),
|
gp_Pnt(xmax + 10., 0., 0.),
|
||||||
gp_Dir(-1, 0, 0),
|
gp_Dir(1, 0, 0),
|
||||||
gp_Dir(0, -1, 0)));
|
gp_Dir(0, 1, 0)));
|
||||||
deferred_section_data_->push_back(vertical_section{ pln , "Elevation East", true });
|
deferred_section_data_->push_back(vertical_section{ pln , "Elevation East", true });
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
gp_Pln pln(gp_Ax3(
|
gp_Pln pln(gp_Ax3(
|
||||||
gp_Pnt((xmin + xmax) / 2., -(ymax + 1.e-1), 0.),
|
gp_Pnt(0., -(ymax + 10.), 0.),
|
||||||
gp_Dir(0, 1, 0),
|
gp_Dir(0, -1, 0),
|
||||||
gp_Dir(1, 0, 0)));
|
gp_Dir(-1, 0, 0)));
|
||||||
deferred_section_data_->push_back(vertical_section{ pln , "Elevation North", true });
|
deferred_section_data_->push_back(vertical_section{ pln , "Elevation North", true });
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
gp_Pln pln(gp_Ax3(
|
gp_Pln pln(gp_Ax3(
|
||||||
gp_Pnt(xmin - 1.e-1, (ymin + ymax) / -2., 0.),
|
gp_Pnt(xmin - 10., 0., 0.),
|
||||||
gp_Dir(1, 0, 0),
|
gp_Dir(-1, 0, 0),
|
||||||
gp_Dir(0, 1, 0)));
|
gp_Dir(0, -1, 0)));
|
||||||
deferred_section_data_->push_back(vertical_section{ pln , "Elevation West", true });
|
deferred_section_data_->push_back(vertical_section{ pln , "Elevation West", true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1033,7 +1041,11 @@ void SvgSerializer::finalize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_hlr) {
|
if (use_hlr) {
|
||||||
hlr = new HLRBRep_Algo;
|
if (use_hlr_poly_) {
|
||||||
|
hlr_poly = new HLRBRep_PolyAlgo;
|
||||||
|
} else {
|
||||||
|
hlr_brep = new HLRBRep_Algo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
section_data_ = std::vector<section_data>{ sd };
|
section_data_ = std::vector<section_data>{ sd };
|
||||||
@@ -1043,18 +1055,30 @@ void SvgSerializer::finalize() {
|
|||||||
|
|
||||||
if (use_hlr) {
|
if (use_hlr) {
|
||||||
const auto& section = boost::get<vertical_section>(sd);
|
const auto& section = boost::get<vertical_section>(sd);
|
||||||
gp_Ax2 transform = section.plane.Position().Ax2();
|
|
||||||
HLRAlgo_Projector projector(transform);
|
|
||||||
hlr->Projector(projector);
|
|
||||||
|
|
||||||
hlr->Update();
|
gp_Trsf trsf;
|
||||||
hlr->Hide();
|
trsf.SetTransformation(section.plane.Position());
|
||||||
|
HLRAlgo_Projector projector(trsf, false, 1.);
|
||||||
|
|
||||||
HLRBRep_HLRToShape hlr_shapes(hlr);
|
TopoDS_Shape hlr_compound_unmirrored;
|
||||||
auto hlr_compound_unmirrored = hlr_shapes.VCompound();
|
|
||||||
|
if (use_hlr_poly_) {
|
||||||
|
hlr_poly->Projector(projector);
|
||||||
|
|
||||||
|
hlr_poly->Update();
|
||||||
|
HLRBRep_PolyHLRToShape hlr_shapes;
|
||||||
|
hlr_shapes.Update(hlr_poly);
|
||||||
|
hlr_compound_unmirrored = hlr_shapes.VCompound();
|
||||||
|
} else {
|
||||||
|
hlr_brep->Projector(projector);
|
||||||
|
|
||||||
|
hlr_brep->Update();
|
||||||
|
hlr_brep->Hide();
|
||||||
|
HLRBRep_HLRToShape hlr_shapes(hlr_brep);
|
||||||
|
hlr_compound_unmirrored = hlr_shapes.VCompound();
|
||||||
|
}
|
||||||
|
|
||||||
if (!hlr_compound_unmirrored.IsNull()) {
|
if (!hlr_compound_unmirrored.IsNull()) {
|
||||||
|
|
||||||
// Compound 3D curves for mirroring to work
|
// Compound 3D curves for mirroring to work
|
||||||
ShapeFix_Edge sfe;
|
ShapeFix_Edge sfe;
|
||||||
TopExp_Explorer exp(hlr_compound_unmirrored, TopAbs_EDGE);
|
TopExp_Explorer exp(hlr_compound_unmirrored, TopAbs_EDGE);
|
||||||
@@ -1092,9 +1116,8 @@ void SvgSerializer::finalize() {
|
|||||||
|
|
||||||
resetScale();
|
resetScale();
|
||||||
|
|
||||||
if (use_hlr) {
|
if (hlr_brep) hlr_brep.Nullify();
|
||||||
hlr.Nullify();
|
if (hlr_poly) hlr_poly.Nullify();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <HLRBRep_Algo.hxx>
|
#include <HLRBRep_Algo.hxx>
|
||||||
#include <HLRBRep_HLRToShape.hxx>
|
#include <HLRBRep_HLRToShape.hxx>
|
||||||
|
#include <HLRBRep_PolyAlgo.hxx>
|
||||||
|
#include <HLRAlgo_Projector.hxx>
|
||||||
#include <gp_Pln.hxx>
|
#include <gp_Pln.hxx>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -126,7 +128,7 @@ protected:
|
|||||||
bool with_section_heights_from_storey_, rescale, print_space_names_, print_space_areas_;
|
bool with_section_heights_from_storey_, rescale, print_space_names_, print_space_areas_;
|
||||||
bool draw_door_arcs_, is_floor_plan_;
|
bool draw_door_arcs_, is_floor_plan_;
|
||||||
bool auto_section_, auto_elevation_;
|
bool auto_section_, auto_elevation_;
|
||||||
bool use_namespace_;
|
bool use_namespace_, use_hlr_poly_;
|
||||||
|
|
||||||
IfcParse::IfcFile* file;
|
IfcParse::IfcFile* file;
|
||||||
IfcUtil::IfcBaseEntity* storey_;
|
IfcUtil::IfcBaseEntity* storey_;
|
||||||
@@ -140,7 +142,8 @@ protected:
|
|||||||
|
|
||||||
std::list<geometry_data> element_buffer_;
|
std::list<geometry_data> element_buffer_;
|
||||||
|
|
||||||
Handle(HLRBRep_Algo) hlr;
|
Handle(HLRBRep_Algo) hlr_brep;
|
||||||
|
Handle(HLRBRep_PolyAlgo) hlr_poly;
|
||||||
|
|
||||||
std::string namespace_prefix_;
|
std::string namespace_prefix_;
|
||||||
public:
|
public:
|
||||||
@@ -160,6 +163,7 @@ public:
|
|||||||
, auto_section_(false)
|
, auto_section_(false)
|
||||||
, auto_elevation_(false)
|
, auto_elevation_(false)
|
||||||
, use_namespace_(false)
|
, use_namespace_(false)
|
||||||
|
, use_hlr_poly_(false)
|
||||||
, file(0)
|
, file(0)
|
||||||
, storey_(0)
|
, storey_(0)
|
||||||
, xcoords_begin(0)
|
, xcoords_begin(0)
|
||||||
@@ -213,6 +217,10 @@ public:
|
|||||||
namespace_prefix_ = use_namespace_ ? "ifc:" : "data-";
|
namespace_prefix_ = use_namespace_ ? "ifc:" : "data-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setUseHlrPoly(bool b) {
|
||||||
|
use_hlr_poly_ = b;
|
||||||
|
}
|
||||||
|
|
||||||
void setScale(double s) { scale_ = s; }
|
void setScale(double s) { scale_ = s; }
|
||||||
void setDrawingCenter(double x, double y) {
|
void setDrawingCenter(double x, double y) {
|
||||||
center_x_ = x; center_y_ = y;
|
center_x_ = x; center_y_ = y;
|
||||||
|
|||||||
Reference in New Issue
Block a user