mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 15:53:00 +00:00
ifcparse: widen all integer attribute types to int64_t for consistency
Follow-up to the scalar-only fix in #8754, per aothms's direct request on that PR ("Please do make all int types consistent") and his own original 2023 design intent on issue #3058 ("make all integers (incl. schema namespaces) an int64_t"). Widens the remaining inconsistent spots now that compatibility isn't a constraint on this v0.9 branch: - Integer aggregates (IfcTriangulatedFaceSet.CoordIndex and similar List<int> attributes), including the SWIG to_vec_int/to_vec_vec_int helpers, which previously silently truncated via static_cast<int> on the Python-set path - the same bug class as the original scalar issue. - The schema code generator (express/mapping.py's integer type mapping), and all 12 generated schema header/source pairs regenerated to match, so every schema-typed getter/setter (e.g. IfcOwnerHistory::CreationDate) is int64_t end to end, not just the dynamic attribute-value path. Instance/reference identifiers (STEP #123 ids) are deliberately left at 32-bit: they're a file-local index into internal maps, not an EXPRESS domain value an application chooses, and no realistic STEP file has billions of entities. The lexer's Token_IDENTIFIER parsing still funnels through a 32-bit int for this reason - flagged as a known, low-risk gap rather than fixed, since fixing it would mean touching indexing/hashing code for no realistic benefit. Verified: original PR's round-trip tests extended with aggregate cases (IfcTriangulatedFaceSet.CoordIndex, InnerCoordIndices) at 64-bit boundary values, in memory and through STEP text, IFC2X3 and IFC4. A standalone C++ program exercising the generated schema API directly (Ifc4::IfcOwnerHistory ::setCreationDate/CreationDate, IfcTriangulatedFaceSet::setCoordIndex/ CoordIndex) confirms int64_t end to end, bypassing SWIG. Full build (BUILD_IFCGEOM, WITH_OPENCASCADE, BUILD_IFCPYTHON, IFC2X3+IFC4) clean. test/util/test_attribute.py and test_file.py pass unchanged. This contribution was produced with the assistance of an AI coding tool.
This commit is contained in:
committed by
Thomas Krijnen
parent
d5076bded3
commit
f23db9440f
@@ -33,12 +33,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineCurveWithKnots& inst)
|
||||
std::transform(cps.begin(), cps.end(), std::back_inserter(points), [this](const IfcSchema::IfcCartesianPoint& cp) { return taxonomy::cast<taxonomy::point3>(map(cp)); });
|
||||
bc->control_points = points;
|
||||
|
||||
bc->multiplicities = inst.KnotMultiplicities();
|
||||
auto knot_multiplicities = inst.KnotMultiplicities();
|
||||
bc->multiplicities.assign(knot_multiplicities.begin(), knot_multiplicities.end());
|
||||
bc->knots = inst.Knots();
|
||||
if (inst.as<IfcSchema::IfcRationalBSplineCurveWithKnots>()) {
|
||||
bc->weights = inst.as<IfcSchema::IfcRationalBSplineCurveWithKnots>().WeightsData();
|
||||
}
|
||||
bc->degree = inst.Degree();
|
||||
bc->degree = (int) inst.Degree();
|
||||
|
||||
return bc;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,15 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcBSplineSurfaceWithKnots& ins
|
||||
return ps;
|
||||
});
|
||||
|
||||
bs->multiplicities = { inst.UMultiplicities(), inst.VMultiplicities() };
|
||||
auto to_int_vector = [](const std::vector<int64_t>& v) {
|
||||
return std::vector<int>(v.begin(), v.end());
|
||||
};
|
||||
bs->multiplicities = { to_int_vector(inst.UMultiplicities()), to_int_vector(inst.VMultiplicities()) };
|
||||
bs->knots = { inst.UKnots(), inst.VKnots() };
|
||||
if (inst.as<IfcSchema::IfcRationalBSplineSurfaceWithKnots>()) {
|
||||
bs->weights = inst.as<IfcSchema::IfcRationalBSplineSurfaceWithKnots>().WeightsData();
|
||||
}
|
||||
bs->degree = { inst.UDegree(), inst.VDegree() };
|
||||
bs->degree = { (int) inst.UDegree(), (int) inst.VDegree() };
|
||||
|
||||
return bs;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve& inst) {
|
||||
auto segments = inst.Segments();
|
||||
for (auto& segment : *segments) {
|
||||
if (auto line = segment.as<IfcSchema::IfcLineIndex>()) {
|
||||
std::vector<int> indices = line;
|
||||
std::vector<int64_t> indices = line;
|
||||
taxonomy::point3::ptr previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
for (std::vector<int64_t>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw ifcopenshell::exception("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
@@ -67,12 +67,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve& inst) {
|
||||
previous = current;
|
||||
}
|
||||
} else if (auto arc = segment.as<IfcSchema::IfcArcIndex>()) {
|
||||
std::vector<int> indices = arc;
|
||||
std::vector<int64_t> indices = arc;
|
||||
if (indices.size() != 3) {
|
||||
throw ifcopenshell::exception("Invalid IfcArcIndex encountered");
|
||||
}
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const int& idx = indices[i];
|
||||
const int64_t& idx = indices[i];
|
||||
if (idx < 1 || idx > max_index) {
|
||||
throw ifcopenshell::exception("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(idx));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet& inst) {
|
||||
loop->external = true;
|
||||
auto indices = f.CoordIndex();
|
||||
taxonomy::point3::ptr previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
for (std::vector<int64_t>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw ifcopenshell::exception("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
@@ -76,7 +76,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcPolygonalFaceSet& inst) {
|
||||
fa->children.push_back(loop);
|
||||
loop->external = false;
|
||||
|
||||
for (std::vector<int>::const_iterator jt = li.begin(); jt != li.end(); ++jt) {
|
||||
for (std::vector<int64_t>::const_iterator jt = li.begin(); jt != li.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw ifcopenshell::exception("IfcPolygonalFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ using namespace ifcopenshell::geometry;
|
||||
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet& inst) {
|
||||
auto point_list = inst.Coordinates();
|
||||
auto coordinates = point_list.CoordList();
|
||||
std::vector<std::vector<int>> indices_list = inst.CoordIndex();
|
||||
std::vector<std::vector<int64_t>> indices_list = inst.CoordIndex();
|
||||
|
||||
std::vector<taxonomy::point3::ptr> points;
|
||||
points.reserve(coordinates.size());
|
||||
@@ -50,7 +50,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet& inst) {
|
||||
fa->children = { loop };
|
||||
loop->external = true;
|
||||
taxonomy::point3::ptr first, previous;
|
||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
for (std::vector<int64_t>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
||||
if (*jt < 1 || *jt > max_index) {
|
||||
throw ifcopenshell::exception("IfcTriangulatedFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user