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

Method map_impl

src/ifcgeom/mapping/IfcSweptDiskSolid.cpp:52–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50*/
51
52taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
53 auto loop = taxonomy::cast<taxonomy::loop>(map(inst->Directrix()));
54
55 // Start- EndParam became optional in IFC4
56#ifdef SCHEMA_IfcSweptDiskSolid_StartParam_IS_OPTIONAL
57 auto sp = inst->StartParam();
58 auto ep = inst->EndParam();
59#else
60 boost::optional<double> sp, ep;
61 try {
62 sp = inst->StartParam();
63 ep = inst->EndParam();
64 } catch (const IfcParse::IfcException& e) {
65 Logger::Warning(e);
66 }
67#endif
68
69 const double tol = settings_.get<settings::Precision>().get();
70
71#ifdef SCHEMA_HAS_IfcSweptDiskSolidPolygonal
72 if (inst->as<IfcSchema::IfcSweptDiskSolidPolygonal>()) {
73 auto fr = inst->as<IfcSchema::IfcSweptDiskSolidPolygonal>()->FilletRadius();
74 if (fr && *fr > tol) {
75 fillet_loop(loop, *fr);
76 }
77 }
78#endif
79
80 std::vector<double> radii = { inst->Radius() * length_unit_ };
81
82 if (inst->InnerRadius()) {
83 // Subtraction of pipes with small radii is unstable.
84 radii.push_back(*inst->InnerRadius() * length_unit_);
85 }
86
87 auto f = taxonomy::make<taxonomy::face>();
88
89 {
90 for (auto it = radii.begin(); it != radii.end(); ++it) {
91 const double r = *it;
92 const bool exterior = it == radii.begin();
93
94 auto c = taxonomy::make<taxonomy::circle>();
95 c->radius = r;
96
97 auto e = taxonomy::make<taxonomy::edge>();
98 e->basis = c;
99 e->start = 0.;
100 e->end = 2 * boost::math::constants::pi<double>();
101 // @todo allow identity by leaving unspecified?
102 c->matrix = taxonomy::make<taxonomy::matrix4>();
103
104 auto l = taxonomy::make<taxonomy::loop>();
105 l->children = { e };
106 l->external = exterior;
107
108 f->children.push_back(l);
109 }

Callers

nothing calls this directly

Calls 5

WarningFunction · 0.85
push_backMethod · 0.80
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected