Comments (9)
Yes it is possible but not easy or straightforward. Some models contain 2D representation of some kind already but it is usually not complete or usable for floorplans. At the same time 3D geometry is usually not enough to create a proper floor plan either as some objects tend to be represented by symbols. By combining both you might be able to create some usable floorplans. xBIM can give you all information contained in IFC file but there is no high-level support/API for creation of floorplans.
from xbimgeometry.
We created floor plans from 3d geometry data. But still we have some issues with Brep and Surface model objects. Can we upload the code for extracting 2D. Can you help me to solve 2D from Brep
from xbimgeometry.
Hi @divyalp , I'm genuinely interested in your extraction method but I can't promise I'll be able to help you with this kind of issues.
from xbimgeometry.
How can I upload the code ?
from xbimgeometry.
Either as a zip package which you drag&drop on a comment or you can share it as a repository on GitHub.
from xbimgeometry.
Hi @divyalp, I'm interested in a 2d floor plans from 3d geometry too.
from xbimgeometry.
I've create a code to convert a mesh 3D to a 2D Polyline, and works for breps too
It's not 100% stable, and I know that I will have to optimize it, but works
I just call this function:
Public Function ConvertMesh3DToPolylineX(ByVal vMesh3D As MeshGeometry3D,
ByVal isClosed As Boolean) As Point3DCollection
If vMesh3D Is Nothing Then Return New Point3DCollection
'Flat the Object
Dim vPoint3DCol As New Point3DCollection
For i = 0 To vMesh3D.Positions.Count - 1
vPoint3DCol.Add(New Point3D(vMesh3D.Positions(i).X, vMesh3D.Positions(i).Y, 0))
Next
'Now, I will cut all equal points, there are points in the same (X,Y) position, but with another Z
Dim vNewIndices As New Windows.Media.Int32Collection
Dim vNewPos As New Point3DCollection
Dim vIndex1 As Integer
Dim vIndex2 As Integer
Dim vIndex3 As Integer
Dim vTriangle As Triangle
Dim vListTriangles As New List(Of Triangle)
Dim p1, p2, p3 As Point3D
For i = 0 To vMesh3D.TriangleIndices.Count - 1 Step 3
p1 = vPoint3DCol(vMesh3D.TriangleIndices(i))
p2 = vPoint3DCol(vMesh3D.TriangleIndices(i + 1))
p3 = vPoint3DCol(vMesh3D.TriangleIndices(i + 2))
vTriangle = New Triangle(p1, p2, p3)
If Not vTriangle.IsValid Then Continue For
vIndex1 = vNewPos.IndexOf(p1)
vIndex2 = vNewPos.IndexOf(p2)
vIndex3 = vNewPos.IndexOf(p3)
If Not vListTriangles.Contains(vTriangle) Then
vListTriangles.Add(vTriangle)
If vIndex1 <> -1 Then
vNewIndices.Add(vIndex1)
Else
vNewIndices.Add(vNewPos.Count)
vNewPos.Add(p1)
End If
If vIndex2 <> -1 Then
vNewIndices.Add(vIndex2)
Else
vNewIndices.Add(vNewPos.Count)
vNewPos.Add(p2)
End If
If vIndex3 <> -1 Then
vNewIndices.Add(vIndex3)
Else
vNewIndices.Add(vNewPos.Count)
vNewPos.Add(p3)
End If
End If
Next
Return Get2DOutline(vNewIndices, vNewPos, isClosed)
End Function
That function calls Get2DOutline, that are a function to really get outline from the flatted mesh
Private Function Get2DOutline(vIndices As Windows.Media.Int32Collection, vPositions As Point3DCollection, isClosed As Boolean) As Point3DCollection
Dim vPathResult As New Windows.Media.PathGeometry
Dim p1, p2, p3 As Point3D
'Add all triangles in a PathGeometry
For i = 0 To vIndices.Count - 1 Step 3
p1 = vPositions(vIndices(i))
p2 = vPositions(vIndices(i + 1))
p3 = vPositions(vIndices(i + 2))
Dim geo As New Windows.Media.StreamGeometry
Using ctx As Windows.Media.StreamGeometryContext = geo.Open
ctx.BeginFigure(New Windows.Point(p1.X, p1.Y), True, True)
ctx.LineTo(New Windows.Point(p2.X, p2.Y), True, True)
ctx.LineTo(New Windows.Point(p3.X, p3.Y), True, True)
ctx.LineTo(New Windows.Point(p1.X, p1.Y), True, True)
ctx.Close()
End Using
vPathResult = Windows.Media.Geometry.Combine(vPathResult, geo, Windows.Media.GeometryCombineMode.Union, Nothing)
Next
vPathResult = vPathResult.GetWidenedPathGeometry(New Windows.Media.Pen(Windows.Media.Brushes.Black, 0.000002), 0.000001, Windows.Media.ToleranceType.Absolute)
Dim vPoly As New Point3DCollection
Dim p As System.Windows.Point
Dim tg As System.Windows.Point
'600 points of precision
For i = 600 To 1200 - 1
vPathResult.GetPointAtFractionLength(i / 1200, p, tg)
vPoly.Add(New Point3D(p.X, p.Y, 0))
Next
vPoly.Add(vPoly(0))
'Simplify the list of points
SimplifyPoints(vPoly)
Return vPoly
End Function
And there are the Triangle Class, and the SimplifyPoints function
Public Class Triangle
Implements IEquatable(Of Triangle)
Public p1 As Point3D
Public p2 As Point3D
Public p3 As Point3D
''' <summary>
''' Return if the triangle has two points equals, so isnot valid
''' </summary>
''' <returns></returns>
Public ReadOnly Property IsValid() As Boolean
Get
If p1.Equals(p2) Then Return False
If p1.Equals(p3) Then Return False
If p2.Equals(p3) Then Return False
Return True
End Get
End Property
Public Sub New(ByVal vP1 As Point3D, ByVal vP2 As Point3D, ByVal vP3 As Point3D)
p1 = vP1
p2 = vP2
p3 = vP3
End Sub
Public Function Equals(other As Triangle) As Boolean Implements IEquatable(Of Triangle).Equals
'the order not cares
If p1.Equals(other.p1) Or p1.Equals(other.p2) Or p1.Equals(other.p3) Then
If p2.Equals(other.p1) Or p2.Equals(other.p2) Or p2.Equals(other.p3) Then
If p3.Equals(other.p1) Or p3.Equals(other.p2) Or p3.Equals(other.p3) Then
Return True
End If
End If
End If
Return False
End Function
End Class
Public Sub SimplifyPoints(ByRef vPoints As Point3DCollection)
Dim angulo As Single
Dim listRemove As New Point3DCollection
Dim doRecursion As Boolean = False
For i As Integer = 0 To vPoints.Count - 3 Step 2
angulo = angleByVectors(New Point(vPoints(i).X, vPoints(i).Y), New Point(vPoints(i + 1).X, vPoints(i + 1).Y), New Point(vPoints(i + 2).X, vPoints(i + 2).Y))
If angulo >= -0.05 And angulo <= 0.05 Then
listRemove.Add(vPoints(i + 1))
End If
Next
For i As Integer = 0 To listRemove.Count - 1
vPoints.Remove(listRemove(i))
doRecursion = True
Next
If doRecursion Then
SimplificaPontos(vPoints)
End If
End Sub
And the function angleByVectors
Public Shared Function angleByVectors(ByVal ponto1 As Point, ByVal ponto2 As Point, ByVal ponto3 As Point) As Single
Dim vet1 As Point
Dim vet2 As Point
Dim prodEscalar As Single
Dim multNorma As Single
vet1 = New Point(ponto2.X - ponto1.X, ponto2.Y - ponto1.Y)
vet2 = New Point(ponto3.X - ponto2.X, ponto3.Y - ponto2.Y)
prodEscalar = vet1.X * vet2.X + vet1.Y * vet2.Y
multNorma = Math.Sqrt(vet1.X ^ 2 + vet1.Y ^ 2) * Math.Sqrt(vet2.X ^ 2 + vet2.Y ^ 2)
Return Math.Acos(prodEscalar / multNorma)
End Function
If anyone has another solution, or did something to optmize this code, please share here :)
from xbimgeometry.
I've added the code (converted to c#) to xbim.windowsui for review.
from xbimgeometry.
see #132 for resolution
from xbimgeometry.
Related Issues (20)
- net6.0 support HOT 4
- Cant create valid IfcSurfaceCurveSweptAreaSolid HOT 1
- Getting correct position of the model in world coordinates
- How to set up local development environment to fix bug's and create PR to contribute in xbim repositories. HOT 1
- How to get outer Edges for an IfcEntity using Xbim library ? HOT 8
- Load Ifc File System.AccessViolationException HOT 4
- Big size of result IFC file HOT 3
- XbimShapeInstance.Transformation places instance in world coordinates HOT 1
- Setting model units HOT 3
- Is v6 geometry engine currently much slower than v5?? HOT 2
- System.OutOfMemoryException. Array dimensions exceeded supported range. HOT 5
- GetShellPoints of a component HOT 1
- Failed to load IFC file: failed to load Xbim.Geometry.Engine64.dll HOT 6
- We need to get plot line bounding box distance for all levels. HOT 1
- We need to get shellpoints of any Building elements. HOT 1
- How to get face points of any building element. HOT 1
- ShapeUpgrade_UnifySameDomain causes a freeze HOT 5
- How to find Width of IfcRamp element?
- Degenerate wire leads to crash (BRepAdaptor_CompCurve) HOT 1
- WexBim viewer is not showing the geometry correctly HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xbimgeometry.