xBimTeam / XbimGeometry

XbimGeometry contains the CLR interop libraries and the c++ engine used to compute the 3D geometry of models.
https://xbimteam.github.io/
Other
260 stars 131 forks source link

Bad position reading for IFCELLIPSEPROFILEDEF #398

Closed CDSguillaume closed 2 years ago

CDSguillaume commented 2 years ago

Hello,

I have an IFC file that contains ellipse shapes defined with IFCELLIPSEPROFILEDEF, and it seems that Position property is ignored on this class.

I can't attach the IFC file due to confidential purpose, but here below an extract of the IFC that illustrate the issue.

Extract of file to illustrate the issue:

16127 = IFCEXTRUDEDAREASOLID(#16128, #31, #37, 0.01);

16128 = IFCELLIPSEPROFILEDEF(.AREA., $, #16129, 0.061, 0.061);

16129 = IFCAXIS2PLACEMENT3D(#16130, #37, #35);

16130 = IFCCARTESIANPOINT((0.5, 11.5));

16131 = IFCSTYLEDITEM(#16127, (#16132), $);

16132 = IFCPRESENTATIONSTYLEASSIGNMENT((#16133));

16133 = IFCSURFACESTYLE('', .BOTH., (#16134));

16134 = IFCSURFACESTYLERENDERING(#16135, 0., $, $, $, $, IFCNORMALISEDRATIOMEASURE(0.5), IFCSPECULAREXPONENT(64.), .NOTDEFINED.);

16135 = IFCCOLOURRGB($,0.,0.9,1.);

16136 = IFCSHAPEREPRESENTATION(#30, 'Body', 'SweptSolid', (#16127));

16137 = IFCPRODUCTDEFINITIONSHAPE($, $, (#16136));

16138 = IFCCOVERING('2tcpuA1dnB$vzg9Mvg6YdN', #2, 'A1', 'Mesure', 'MesurePoint', #16139, #16137, $, .USERDEFINED.);

16139 = IFCLOCALPLACEMENT(#61, #16140);

16140 = IFCAXIS2PLACEMENT3D(#16141, #37, #35);

16141 = IFCCARTESIANPOINT((72.151, -85.572, 0.));

Observed problem:

The IFCELLIPSEPROFILEDEF has a Position property defined with the #16129 - IFCAXIS2PLACEMENT3D. When I read the IFC and I get the #16128 instance properties, Position is null (see last attached image).

As a result, when I read the shape instance built from #16138 IFCCOVERING, the associated tranform only contains the local placement transformation (#16139), but does not include the transform position from the Ellipse. The result is that the corresponding object is not displayed at the right position.

On the attached image below, a comparison of the same model imported in XbimWindowsUI (left) and in BIMVision software (right). In BIMVisision, the "ellipse" objects are in the right position, but in XBim, as the Ellipse position property is not taken into account in the transformation of the geometrical shape, the positions are wrong.

Assemblies and versions affected: Xbim.Common V5.1.341, Xbim.Essentials V5.1.341, Xbim.Geometry V5.1.437

Thank you in advance for any help or explanation. Please let me know if you need more information.

comparejpg cap

andyward commented 2 years ago

According to the standards the Position on an IfcEcllipseProfileDef should be a IFCAXIS2PLACEMENT2D - not a 3D. Which makes sense as this is a profile, before a sweep is applied.

In theory we could try to do something clever and just use X,Y of the 3D placement, which is presumably what BIMVision does - but really the model is wrong.

CDSguillaume commented 2 years ago

Thank you for this information.

I can try to correct the file to match the standard. However, in my sample, I tried to replace :

16129 = IFCAXIS2PLACEMENT3D(#16130, #37, #35);

by :

16129 = IFCAXIS2PLACEMENT2D(#16130, #37);

with :

37 = IFCDIRECTION((0., 0., 1.));

and I got an Access Violation Exception during the context creation (Xbim3DModelContext.CreateContext).

This exception doesn't occurs with IFCAXIS2PLACEMENT3D. Do you have a clue ?

Thank you in advance

andyward commented 2 years ago

Best bet is to see if the logs output anything. Try running the xbim validation to see what issues are identified before calling CreateContext. (Or try it in xbimXplorer with logging enabled).

It's probable there are other issues, putting the GE into an invalid state. What tool created the model?

Otherwise it's going to need debugging.

CDSguillaume commented 2 years ago

After a quick debug I found the cause of the exception :

The IFCAXIS2PLACEMENT2D expects a 2D IFCDIRECTION and in my sample it was (0, 0, 1), so in XBim.Geometry.Engine it was misinterpreted as a (0, 0, 0) vector (since the Z was ignored), and calculating a vector with a norm of 0 raises an exception (In this case in XbimWire.cpp, line 1972)

I replaced this with an IFCDIRECTION(1, 0, 0) and it works fine, and my ellipse object is displayed at the right position with the use of an IFCAXIS2PLACEMENT2D instead of an IFCAXIS2PLACEMENT3D.

Thank you for your help.