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
255 stars 128 forks source link

points of a RectangleProfileDef, i can only get the X and Y dimensions #422

Closed RoyTimmers1980 closed 1 year ago

RoyTimmers1980 commented 1 year ago

I cannot seem to get the points from a slab wich has a RectangleProfileDef, because i can only get the X and Y dimension from the dataset. Further the location off the slab in the is unclear to me, how can i get the exact location off the slab in het model

This is my code so far:

       ' Open het IFC-bestand
        Dim model As IfcStore = IfcStore.Open(frmIFC.IFCbestand)

        ' Haal de geselecteerde verdieping op
        Dim level As IIfcBuildingStorey = model.Instances.OfType(Of IIfcBuildingStorey)().FirstOrDefault(Function(x) x.Name = frmIFC.BasisLevel)

        '######################################################
        'VLOEREN
        '######################################################
        If frmIFC.cbVloer.Checked = True Then

            ' Haal alle vloeren op die zich op het niveau bevinden
            Dim slabs As IEnumerable(Of IIfcSlab) = model.Instances.OfType(Of IIfcSlab)().Where(Function(x) x.ContainedInStructure.FirstOrDefault(Function(y) y.RelatingStructure Is level) IsNot Nothing)

            For Each slab In slabs
                Dim Solid As IfcSweptAreaSolid = slab.Representation.Representations(0).Items(0)
                Dim AreaType As String = Solid.SweptArea.GetType.Name

                If Solid IsNot Nothing Then

                    'solid is een polyline
                    If AreaType = "IfcArbitraryClosedProfileDef" Then

                        Dim Area As IIfcArbitraryClosedProfileDef = Solid.SweptArea
                        Dim Curve As IIfcPolyline = Area.OuterCurve
                        Dim PointsVloer As New List(Of Point2d)

                        For Each point As IIfcCartesianPoint In Curve.Points

                            'MsgBox("X: " & point.X & " - Y : " & point.Y)
                            Dim objectPlacement As IfcLocalPlacement = slab.ObjectPlacement
                            Dim PlacementPoint As IfcAxis2Placement3D = objectPlacement.RelativePlacement
                            Dim PointsGobal As IIfcCartesianPoint = PlacementPoint.Location

                            Dim pointGX As Double = PlacementPoint.Location.X
                            Dim pointGY As Double = PlacementPoint.Location.Y

                            Dim PointModX As Double = pointGX + point.X
                            Dim PointModY As Double = pointGY + point.Y

                            'coordinaten toeveogen aan punten collectie tbv tekenen polyline
                            PointsVloer.Add(New Point2d(PointModX, PointModY))

                        Next
                        'tekenen van de vloercontour
                        Draw.Draw2DPolyline(PointsVloer, "0")

                    ElseIf AreaType = "IfcRectangleProfileDef" Then

                        'solid is een rechthoek
                        Dim Area As IIfcRectangleProfileDef = Solid.SweptArea
                        Dim Xdim As Double = Area.XDim
                        Dim Ydim As Double = Area.YDim

                        MsgBox(Xdim & " / " & Ydim)

                        'Draw.Draw2DPolyline(PointsVloer, "0")
                    Else
                        MsgBox("jammer deze moet je ff zelf tekenen ")
                    End If

                End If 'einde solid
            Next 'einde vloeren doorlopen
        End If 'controle vinkje vloeren
martin1cerny commented 1 year ago

Which points do you want to get? Triangulated mesh points? Currently, you are iterating over profile points, but there are many possible ways to express the profile, where most of them don't have exact points, but are defined by mathematical curves and compound curves.

Overall placement of the slab is defined as slab.ObjectPlacement. Bear in mind that placement of the product can have parent placement and you may also need to consider mapped representation transformations.

What are you trying to achieve?

RoyTimmers1980 commented 1 year ago

Martin, i'm trying to retrieve the points/coordinates of the slab/wall in the model so i can draw them in AutoCad to proces in our CAD-system

martin1cerny commented 1 year ago

Do you want to draw them as triangulated 3D mesh, or do you want to translate their parametric definition from IFC to AutoCAD?

RoyTimmers1980 commented 1 year ago

I want to draw them as 2D polylines in Autocad

andyward commented 1 year ago

See #421 also

andyward commented 1 year ago

As noted in the other issue I think you want to be using the Geometry Engine for this unless: 1) It's a trivial single use case or 2) You have a lot of time to re-interpret all the IFC Geometry concepts, implementors agreements etc

Creating a 2D Projection (Footprint) from a 3D mesh or solid is relatively much easier. We do have some private code to do this.

If you want to live life on the edge we have some new public code that creates 2D Footprints (essentially a collection of 2D Polylines) from the underlying OpenCascade solid/Brep. See this test: https://github.com/xBimTeam/XbimGeometry/blob/579ea9a3916e5849d3aac0edad509c41906949f5/Xbim.Geometry.Engine.Tests/ModelGeometryServiceTests/ProjectionFactoryTests.cs#LL36C27-L36C27

This is in the new netcore geometry engine which is not published yet, but is available from a private nuget repo - or build yourself.

image

(You can get a Brep file from and Geometry primititive via the ToBRep property)

andyward commented 1 year ago

Closing