xBimTeam / XbimWindowsUI

The home of XbimXplorer and WPF components for your desktop BIM applications.
Other
252 stars 149 forks source link

Issue with rendering IfcSweptDiskSolid #174

Open IbrahimMassoud opened 3 years ago

IbrahimMassoud commented 3 years ago

I have a problem with rendering IfcSweptDiskSolid if its curve has more than one plane, although it works well with other viewers like Autodesk Viewer

down here is the sample of code I used.

using (var txn = model.BeginTransaction()) {

                ICollection<IfcCartesianPoint> barVertices = new List<IfcCartesianPoint>();
                barVertices.Add(model.Instances.New<IfcCartesianPoint>(c => c.SetXYZ(1000, 250, 150)));
                barVertices.Add(model.Instances.New<IfcCartesianPoint>(c => c.SetXYZ(1000, 250, -150)));
                barVertices.Add(model.Instances.New<IfcCartesianPoint>(c => c.SetXYZ(1000, -250, -150)));
                barVertices.Add(model.Instances.New<IfcCartesianPoint>(c => c.SetXYZ(1000, -250, 150)));
                barVertices.Add(model.Instances.New<IfcCartesianPoint>(c => c.SetXYZ(1000, 250, 150)));

                model.Instances.New<IfcSweptDiskSolidPolygonal>(sds =>
                {
                    sds.Directrix = model.Instances.New<IfcCompositeCurve>(cc =>
                    {
                        cc.Segments.Add(model.Instances.New<IfcCompositeCurveSegment>(ccs =>
                        {
                            ccs.Transition = IfcTransitionCode.DISCONTINUOUS;
                            ccs.SameSense = true;
                            ccs.ParentCurve = model.Instances.New<IfcPolyline>(pl =>
                            {
                                pl.Points.AddRange(barVertices);
                            });
                        }
                        ));
                        cc.SelfIntersect = false;
                    });
                    sds.Radius = 18;
                });

                txn.Commit();
            }

You can check this image to find the difference between the expected behavior and the actual one. bar

This is the output ifc file: stirrup.zip

ChernyshevDS commented 2 weeks ago

The provided model does not conform to the standard, because according to the description of the IfcSweptDiskSolidPolygonal the directrix curve may only be IfcPolyline, and in this model we have IfcCompositeCurve containing single IfcPolyLine. However, I think Xbim could allow this. The problem can be fixed in void XbimSolid::Init(IIfcSweptDiskSolid^ repItem, ILogger^ logger) by setting transitionMode to BRepBuilderAPI_TransitionMode::BRepBuilderAPI_RightCorner. The is already some logic to determine the transitionMode value based on directrix curve type, but using IfcCompositeCurve breaks it.