IfcPolyline and AbstractEList
dkurillo opened this issue · comments
According to IFC specification for IfcPolyline (https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC2/HTML/schema/ifcgeometryresource/lexical/ifcpolyline.htm)
If the first and the last Cartesian point in the list are identical, then the polyline is a closed curve, otherwise it is an open curve
But if you to add the same point to polyline.getPoints() list it won't work because org.eclipse.emf.common.util.AbstractEList checks for contains:
public boolean add(E object) {
if (this.isUnique() && this.contains(object)) {
return false;
} else {
this.addUnique(object);
return true;
}
}
How to define closed polyline in BimServer?
Sorry, it was my fault. I get first and last point from the cache. That's why they look identical to the list
In fact, org.eclipse.emf.common.util.AbstractEList
only checks for containment and refuses addition if the list is a unique list and hence isUnique()
returns true. The Ecore model defines no uniqueness for the Points feature of IfcPolyline.
<eClassifiers xsi:type="ecore:EClass" name="IfcPolyline" eSuperTypes="//IfcBoundedCurve">
<eStructuralFeatures xsi:type="ecore:EReference" name="Points" unique="false" upperBound="-1" eType="//IfcCartesianPoint"/>
</eClassifiers>
I have been confused by the method name addUnique(E object)
in the past. It does not check for uniqueness. Whereas add(E object)
does the check, addUnique(...)
assumes the check to be done already and does not care.