Minor code format revisions

This commit is contained in:
Richard Brice
2023-10-25 06:46:34 -07:00
committed by Thomas Krijnen
parent ba4ff68597
commit b83f2de5c4
+25 -21
View File
@@ -69,11 +69,10 @@ private:
public: public:
// First constructor, takes parameters from IfcCurveSegment // First constructor, takes parameters from IfcCurveSegment
curve_segment_evaluator(mapping* mapping, double length_unit, segment_type_t segment_type, IfcSchema::IfcCurve* curve, IfcSchema::IfcCurveMeasureSelect* st, IfcSchema::IfcCurveMeasureSelect* le) curve_segment_evaluator(mapping* mapping, double length_unit, segment_type_t segment_type, IfcSchema::IfcCurve* curve, IfcSchema::IfcCurveMeasureSelect* st, IfcSchema::IfcCurveMeasureSelect* le)
: mapping_(mapping) : mapping_(mapping),
, length_unit_(length_unit) length_unit_(length_unit),
, segment_type_(segment_type) segment_type_(segment_type),
, curve_(curve) curve_(curve) {
{
// @todo in IFC4X3_ADD2 this needs to be length measure // @todo in IFC4X3_ADD2 this needs to be length measure
if (!st->as<IfcSchema::IfcLengthMeasure>() || !le->as<IfcSchema::IfcLengthMeasure>()) { if (!st->as<IfcSchema::IfcLengthMeasure>() || !le->as<IfcSchema::IfcLengthMeasure>()) {
@@ -85,21 +84,25 @@ public:
length_ = *le->as<IfcSchema::IfcLengthMeasure>() * length_unit; length_ = *le->as<IfcSchema::IfcLengthMeasure>() * length_unit;
} }
void set_spiral_functor(mapping* mapping_,IfcSchema::IfcSpiral* c, double s, std::function<double(double)> signX, std::function<double(double)> fnX, std::function<double(double)> signY, std::function<double(double)> fnY) void set_spiral_functor(mapping* mapping_, IfcSchema::IfcSpiral* c, double s, std::function<double(double)> signX, std::function<double(double)> fnX, std::function<double(double)> signY, std::function<double(double)> fnY) {
{
// determine the length of the spiral from the local origin to the end point // determine the length of the spiral from the local origin to the end point
auto sign_s = binary_sign(start_); auto sign_s = binary_sign(start_);
auto sign_l = binary_sign(length_); auto sign_l = binary_sign(length_);
double L = 0; double L = 0;
if (sign_s == 0) L = fabs(length_); // start_ is at zero so length_ is the L if (sign_s == 0) {
else if (sign_s == sign_l) L = fabs(start_ + length_); // start_ and length_ are additive L = fabs(length_); // start_ is at zero so length_ is the L
else L = fabs(start_); // start_ and length_ are in opposite directions so start_ is furthest from the origin } else if (sign_s == sign_l) {
L = fabs(start_ + length_); // start_ and length_ are additive
} else {
L = fabs(start_); // start_ and length_ are in opposite directions so start_ is furthest from the origin
}
auto transformation_matrix = taxonomy::cast<taxonomy::matrix4>(mapping_->map(c->Position()))->ccomponents(); auto transformation_matrix = taxonomy::cast<taxonomy::matrix4>(mapping_->map(c->Position()))->ccomponents();
auto segment_type = segment_type_;
auto start = start_; auto start = start_;
if (segment_type_ == ST_HORIZONTAL || segment_type_ == ST_VERTICAL) {
auto segment_type = segment_type_;
eval_ = [L, start, s, signX, fnX, signY, fnY, transformation_matrix, segment_type](double u) { eval_ = [L, start, s, signX, fnX, signY, fnY, transformation_matrix, segment_type](double u) {
using boost::math::quadrature::trapezoidal; using boost::math::quadrature::trapezoidal;
@@ -137,17 +140,21 @@ public:
m.col(1) = Eigen::Vector4d(0, 1, 0, 0); m.col(1) = Eigen::Vector4d(0, 1, 0, 0);
m.col(2) = Eigen::Vector4d(-dy, 0, dx, 0); m.col(2) = Eigen::Vector4d(-dy, 0, dx, 0);
m.col(3) = Eigen::Vector4d(0, 0, y, 1.0); // y is an elevation so store it as z m.col(3) = Eigen::Vector4d(0, 0, y, 1.0); // y is an elevation so store it as z
} else if (segment_type == ST_CANT) {
Logger::Warning(std::runtime_error("Use of IfcSpiral for cant is not supported"));
} else {
Logger::Error(std::runtime_error("Unexpected segment type encountered"));
} }
Eigen::Matrix4d result = transformation_matrix * m; Eigen::Matrix4d result = transformation_matrix * m;
return result; return result;
}; };
} }
else if (segment_type_ == ST_CANT) {
eval_ = [](double u) {
Eigen::Matrix4d result;
return result;
};
}
else {
Logger::Error(std::runtime_error("Unexpected segment type encountered"));
}
}
// Clothoid using Taylor Series approximation // Clothoid using Taylor Series approximation
@@ -426,7 +433,7 @@ public:
}; };
} }
else if (segment_type_ == ST_VERTICAL) { else if (segment_type_ == ST_VERTICAL || segment_type_ == ST_CANT) {
eval_ = [px, py, dx, dy](double u) { eval_ = [px, py, dx, dy](double u) {
// https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcGradientCurve.htm // https://standards.buildingsmart.org/IFC/RELEASE/IFC4_3/HTML/lexical/IfcGradientCurve.htm
@@ -447,9 +454,6 @@ public:
m.col(3) = Eigen::Vector4d(0, 0, y, 1.0); // y is an elevation so store it as z m.col(3) = Eigen::Vector4d(0, 0, y, 1.0); // y is an elevation so store it as z
return m; return m;
}; };
}
else if(segment_type_ == ST_CANT) {
Logger::Warning(std::runtime_error("Use of IfcLine for cant is not supported"), l);
} }
else { else {
Logger::Error(std::runtime_error("Unexpected segment type encountered"), l); Logger::Error(std::runtime_error("Unexpected segment type encountered"), l);