Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect curve parameters when creating XbimCurve for trimmed ellipse #447

Open
ChernyshevDS opened this issue Sep 14, 2023 · 2 comments
Open

Comments

@ChernyshevDS
Copy link

Hello again. I've encountered a problem with incorrect mesh generation when trying to load a specific IFC4 model (stripped file is attached below). Some of the elements seem to have distorted geometry:

изображение

I beleive that I've managed to find the source of the issue. When loading the model I've received a number of the same warnings like:

Failed to project vertex to edge geometry, start point assumed

This warning is generated in XbimCompound::InitAdvancedFaces(IEnumerable<IIfcFace^>^ faces, ILogger^ logger), specifically for the entity IfcEdgeCurve #189964. It has underlying EdgeGeometry of IfcTrimmedCurve #189961 which trims an IfcEllipse #189960 with trimming defined with cartesian points.

The end trimming point clearly lies on the ellipse, but XbimCurve::LocatePointOnCurve returns false. I beleive it is caused by incorrect Geom_Curve construction in void XbimCurve::Init(IIfcTrimmedCurve^ curve, ILogger^ logger).

OpenCascade has a limitation for ellipse shape: unlike IfcEllipse, it should always have a major radius greater than minor radius. To overcome this limitation there is an additional rotation by Pi/2 applied to ellipse in XbimCurve::Init(IIfcEllipse^, ILogger^) in case when SemiAxis1 < SemiAxis2. This rotation of course has to be taken into account when adjusting trimming parameters.

There is a piece of code in XbimCurve::Init(IIfcTrimmedCurve^ curve, ILogger^ logger) that does exactly that:

if (isEllipse)
{
	IIfcEllipse^ ellipse = (IIfcEllipse^)curve->BasisCurve;
	if (ellipse->SemiAxis1 < ellipse->SemiAxis2)
	{
		u1 -= Math::PI / 2;
		u2 -= Math::PI / 2;
	}
}

However, it should not be applied to parameters u1 and u2 if they were previously calculated from cartesian points with GeomLib_Tool::Parameter, because they are already calculated from ellipse rotated by Pi/2.

I've made some corrections and created a patch:
fix_trimmed_ellipse.patch

Corrected model:
изображение

Assemblies and versions affected:

XbimGeometry 5.1.403, commit 24a3db9

Minimal file to reproduce the issue:

IFC VK L4.ifc.stripped.ifc.txt

@andyward
Copy link
Member

Thanks for this detailed investigation! Any chance you can submit as a PR rather than a patch? Ideally you'll add a quick test using your stripped model (that'll help ensure we keep this fixed as we merge with the incoming v6 changes.)

@ChernyshevDS
Copy link
Author

@andyward Done: #449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants