Code: Select all
Imports System.Windows.Forms.VisualStyles
Imports Teigha.BoundaryRepresentation
Imports Teigha.DatabaseServices
Imports Teigha.Geometry
Public Class FEMBrepFace
Public Property Id As Integer
Public Property Normal As Vector3d
Public Property Pontos As New List(Of Point3d)
Public Property Arestas As New List(Of FEMBrepAresta)
End Class
Public Class FEMBrepAresta
Public Property Inicio As Point3d
Public Property Fim As Point3d
End Class
Public Class FEMBrepSolido
Public Property ObjectId As ObjectId
Public Property Faces As New List(Of FEMBrepFace)
End Class
Public Class FEMExtratorBrep3D
Public Shared Function ExtrairSolido(
tr As Transaction,
idSolido As ObjectId) As FEMBrepSolido
Dim ent As Entity =
CType(tr.GetObject(idSolido, OpenMode.ForRead), Entity)
Dim solido As Solid3d = TryCast(ent, Solid3d)
If solido Is Nothing Then
Throw New System.Exception("Objeto selecionado não é Solid3d.")
End If
Dim resultado As New FEMBrepSolido With {
.ObjectId = idSolido
}
Using brep As New Brep(solido)
Dim indiceFace As Integer = 0
For Each face As Face In brep.Faces
Dim f As New FEMBrepFace With {
.Id = indiceFace
}
For Each loopFace As Loop In face.Loops
For Each edge As Edge In loopFace.Edges
Dim curva As Curve3d = edge.Curve
Dim p0 As Point3d = curva.StartPoint
Dim p1 As Point3d = curva.EndPoint
f.Arestas.Add(New FEMBrepAresta With {
.Inicio = p0,
.Fim = p1
})
f.Pontos.Add(p0)
f.Pontos.Add(p1)
Next
Next
resultado.Faces.Add(f)
indiceFace += 1
Next
End Using
Return resultado
End Function
End Class