Portal    Foro    Buscar    FAQ    Registrarse    Conectarse

Lector DXF

Lector DXF
Artículo
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
He escrito este Modulo principal DXF.module  y otras Clases secundarias.

He mantenido tres funciones externas de C para acelerar la traducción de todo el proyecto de C++ en Gambas.

Espero no haber cometido errores de distracción.    
Asì, por favor, compruebe mi traducción con los archivos de la biblioteca C++ en cuestión que me has pasado.

saludos

DXF-0.0.1.tar.gz
Descripción:  
Descargar
Nombre del archivo: DXF-0.0.1.tar.gz
Tamaño: 12.74 KB
Descargado: 69 veces
DXF-0.0.1.tar.gz
Descripción:  
Descargar
Nombre del archivo: DXF-0.0.1.tar.gz
Tamaño: 12.74 KB
Descargado: 69 veces
DXF-0.0.1.tar.gz
Descripción:  
Descargar
Nombre del archivo: DXF-0.0.1.tar.gz
Tamaño: 12.74 KB
Descargado: 69 veces




 
última edición por vuott el Miercoles, 06 May 2020, 18:36; editado 2 veces 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Miercoles, 06 May 2020, 18:34 ]
 


Lector DXF
Comentarios
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
Adapte alguna cosas para alejarnos del perverso C++ y ya funciona!!!
captura_de_pantalla_de_2020_05_06_17_27_28



 
última edición por tercoIDE el Miercoles, 06 May 2020, 21:28; editado 1 vez 
tercoIDE - Ver perfil del usuario Enviar mensaje privado  
tercoIDE [ Miercoles, 06 May 2020, 19:14 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
Usaste, cambiandola, mi traducción o escribiste otra ?



 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Miercoles, 06 May 2020, 22:00 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
vuott escribió: [Ver mensaje]
Usaste, cambiandola, mi traducción o escribiste otra ?


tu traduccion , y un poco de Buscar y Reemplazar



 
tercoIDE - Ver perfil del usuario Enviar mensaje privado  
tercoIDE [ Miercoles, 06 May 2020, 22:14 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
Hiciste bien.
La has mejorada.



 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Miercoles, 06 May 2020, 22:47 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
Codigo final que funciona para: Line, PolyLine, Circle, SPline, Arc

Tuve que cambiar los codigos de la PolyLine porque cambio el Standard.

Habria que ampliar para otras entidades.

Gracias, gran Jedi del inframundo

' gambas module file

Public Struct lineSt
    
    layer As Integer
    x1 As Float
    y1 As Float
    x2 As Float
    y2 As Float
    
End Struct


Public Struct circleSt
    
    layer As Integer
    x As Float
    y As Float
    r As Float
    
End Struct

Public Struct arcSt
    
    layer As Integer
    x As Float
    y As Float
    r As Float
    sa As Float
    ea As Float
    
End Struct


Public Struct StructpolylineSt
    
    layer As Integer
    vertexcount As Integer
    poliflag As Integer
    x As Float[]
    y As Float[]
    
End Struct

Public Struct StructsplineeSt
    
    layer As Integer
    m_FitPointCount As Integer
    x As Float[]
    y As Float[]
    
End Struct



Public m_Line As New LineSt
Public m_Circle As New CircleSt
Public m_PolyLine As New StructpolylineSt

Public m_Spline As New StructsplineeSt
Public m_Arc As New ArcSt

Private m_LineCount As Integer
Private m_PolyLineCount As Integer
Private m_CircleCount As Integer
Private m_ArcCount As Integer
Private m_SplineCount As Integer
'
' Private m_Line As CLine[]
' Private m_PolyLine As CPolyLine[]
' Private m_Circle As CCircle[]
' Private m_Arc As CArc[]
' Private m_Spline As CSpline[]


' Library "libc:6"
'
' ' FILE *fopen (const char *__restrict __filename, const char *__restrict __modes)
' ' Open a file and create a new stream for it.
' Private Extern fopen(__filename As String, __modes As String) As Pointer
'
' ' int feof (FILE *__stream)
' ' Return the EOF indicator for STREAM.
' Private Extern feof(__stream As Pointer) As Integer
'
' ' int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...)
' ' Read formatted input from STREAM.
' Private Extern fscanf(__stream As Pointer, __format As String, array1 As Pointer, __array2 As Pointer) As Integer
'
' ' int fclose (FILE *__stream)
' ' Close STREAM.
' Private Extern fclose(__stream As Pointer) As Integer


Public Procedure LoadFile(stn As String)


  
  Dim fp As File
  Dim lpCode, lpValue As String
  Dim i As Integer
  Dim m_LoadStatus As Boolean

    m_PolyLine.x = New Float[]
    m_PolyLine.y = New Float[]

    m_Spline.x = New Float[]
    m_Spline.y = New Float[]

  
  fp = Open stn For Read
  If Not fp Then Error.Raise("Error !")
    
  ' While Not Eof(fp)
  '    
  '   Read #fp, lpCode, lpValue
  '      
  '   If (trim(lpcode) =  "0") and not eof(fp) And (lpvalue =  "LINE") and not eof(fp) Then
  '     Inc m_LineCount
  '   Else If
  '     (trim(lpcode) =  "0") and not eof(fp) And (lpvalue =  "LWPOLYLINE") and not eof(fp) Then
  '     Inc m_PolyLineCount
  '   Else If
  '     (trim(lpcode) =  "0") and not eof(fp) And (lpvalue =  "CIRCLE") and not eof(fp) Then
  '     Inc m_CircleCount
  '   Else If
  '     (trim(lpcode) =  "0") and not eof(fp) And (lpvalue =  "ARC") and not eof(fp) Then
  '     Inc m_ArcCount
  '   Else If
  '     (trim(lpcode) =  "0") and not eof(fp) And (lpvalue =  "SPLINE") and not eof(fp) Then
  '     Inc m_SplineCount
  '   Endif
  '    
  ' Wend
  '  
  ' fclose(fp)
  '
  ' ' AllocMemory()
  ' '
  ' m_LineCount = 0
  ' m_CircleCount = 0
  ' m_ArcCount = 0
  ' m_PolyLineCount = 0
  ' m_SplineCount = 0
  '
  ' fp = fopen(stn, "r") and not eof(fp)
  ' If fp <> 0 Then
  '
  '   m_LoadStatus = True
  '
  '   lpCode.Fill(&00, 0, lpCode.Count)
  '   lpValue.Fill(&00, 0, lpCode.Count)
  
    While Not Eof(fp)
        
        Line Input #fp, lpcode
        Line Input #fp, lpValue
        'Print lpcode, lpvalue
        If (lpvalue = "LINE") And Not Eof(fp) Then

        While (Trim(lpcode) <> "8") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        
        Wend
        If Trim(lpcode) = "8" Then m_Line.layer = CInt(lpvalue)
        While (Trim(lpcode) <> "10") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        
        Wend
        If Trim(lpcode) = "10" Then m_Line.x1 = CFloat(lpValue)
        While (Trim(lpcode) <> "20") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        
        Wend
        If Trim(lpcode) = "20" Then m_Line.y1 = CFloat(lpValue)
        While (Trim(lpcode) <> "11") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        
        Wend
        If Trim(lpcode) = "11" Then m_Line.x2 = CFloat(lpValue)
        While (Trim(lpcode) <> "21") And Not Eof(fp)
            Line Input #fp, lpcode
            Line Input #fp, lpValue
            
        Wend
        If Trim(lpcode) = "21" Then m_Line.y2 = CFloat(lpValue)
        Inc m_LineCount
        
        
        Print "Line", m_Line.layer, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2
      
        '' Lwpolyline command:
      Else If (Trim(lpcode) = "0") And (lpvalue = "LWPOLYLINE") Then
        While (Trim(lpcode) <> "8") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "8" Then m_PolyLine.layer = CInt(lpvalue)
        While (Trim(lpcode) <> "90") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "90" Then m_PolyLine.vertexcount = Val(lpValue)
        While (Trim(lpcode) <> "70") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "70" Then m_PolyLine.poliflag = Val(lpValue)
        
        For i = 0 To m_PolyLine.vertexcount - 1
          While (Trim(lpcode) <> "10") And Not Eof(fp)
            Line Input #fp, lpcode
          Line Input #fp, lpValue
          Wend
          If Trim(lpcode) = "10" Then m_PolyLine.x.Add(CFloat(lpValue))
          While (Trim(lpcode) <> "20") And Not Eof(fp)
            Line Input #fp, lpcode
          Line Input #fp, lpValue
          Wend
          If Trim(lpcode) = "20" Then m_PolyLine.y.Add(CFloat(lpValue))
        Next
        Inc m_PolyLineCount
        
        Print "PolyLine", m_PolyLine.layer, m_PolyLine.poliflag, m_PolyLine.vertexcount
        For i = 0 To m_PolyLine.x.Max
            Print "PolyLine vertex", m_PolyLine.x[i], m_PolyLine.y[i]
        Next
            
      
         '' Circle command:
      Else If (Trim(lpcode) = "0") And (lpvalue = "CIRCLE") Then
        While (Trim(lpcode) <> "8") And Not Eof(fp)
            Line Input #fp, lpcode
            Line Input #fp, lpValue
            
        Wend
        If Trim(lpcode) = "8" Then m_Circle.layer = CInt(lpvalue)
        While (Trim(lpcode) <> "10") And Not Eof(fp)
          Line Input #fp, lpcode
            Line Input #fp, lpValue
            
        Wend
        If Trim(lpcode) = "10" Then m_Circle.x = CFloat(lpValue)
        While (Trim(lpcode) <> "20") And Not Eof(fp)
              Line Input #fp, lpcode
            Line Input #fp, lpValue
            
        Wend
        If Trim(lpcode) = "20" Then m_Circle.y = CFloat(lpValue)
        While (Trim(lpcode) <> "40") And Not Eof(fp)
           Line Input #fp, lpcode
            Line Input #fp, lpValue
            
        Wend
        If Trim(lpcode) = "40" Then m_Circle.r = CFloat(lpValue)
        Inc m_CircleCount
      
      Print "Circle", m_Circle.layer, m_Circle.x, m_Circle.y, m_Circle.r
      ' Arc command
      Else If (Trim(lpcode) = "0") And (lpvalue = "ARC") Then
        While (Trim(lpcode) <> "8") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "8" Then m_Arc.layer = CInt(lpvalue)
        While (Trim(lpcode) <> "10") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "10" Then m_Arc.x = CFloat(lpValue)
        While (Trim(lpcode) <> "20") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "20" Then m_Arc.y = CFloat(lpValue)
        While (Trim(lpcode) <> "40") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "40" Then m_Arc.r = CFloat(lpValue)
        While (Trim(lpcode) <> "50") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "50" Then m_Arc.sa = CFloat(lpValue)
        While (Trim(lpcode) <> "51") And Not Eof(fp)
          Line Input #fp, lpcode
          Line Input #fp, lpValue
        Wend
        If Trim(lpcode) = "51" Then m_Arc.ea = CFloat(lpValue)
        Inc m_ArcCount
        
        Print "Arc", m_Arc.layer, m_Arc.x, m_Arc.y, m_Arc.r, m_Arc.sa, m_Arc.ea
        
        
      Else If (Trim(lpcode) = "0") And (lpvalue = "SPLINE") Then
        While (Trim(lpcode) <> "8") And Not Eof(fp)
              Line Input #fp, lpcode
              Line Input #fp, lpValue
            
        Wend
      If Trim(lpcode) = "8" Then m_Spline.layer = CInt(lpvalue)
        While (Trim(lpcode) <> "73") And Not Eof(fp)
              Line Input #fp, lpcode
              Line Input #fp, lpValue
            
        Wend
      If Trim(lpcode) = "73" Then m_Spline.m_FitPointCount = Val(lpValue)
      For i = 0 To m_Spline.m_FitPointCount - 1
        While (Trim(lpcode) <> "10") And Not Eof(fp)
            Line Input #fp, lpcode
            Line Input #fp, lpValue
          
        Wend
        If Trim(lpcode) = "10" Then m_Spline.x.Add(CFloat(lpValue))
        While (Trim(lpcode) <> "20") And Not Eof(fp)
            Line Input #fp, lpcode
            Line Input #fp, lpValue
          
        Wend
        If Trim(lpcode) = "20" Then m_Spline.y.Add(CFloat(lpValue))
      Next
      Inc m_SplineCount
      
      Print "SPLine", m_Spline.layer, m_Spline.m_FitPointCount
        For i = 0 To m_Spline.x.Max
            Print "SPLine vertex", m_Spline.x[i], m_Spline.y[i]
        Next
        
      
      
      Endif
  
  
  
    Wend
    
  ' Else
  '   m_LoadStatus = False
  ' Endif
  fp.Close
  
  
End

'
' Private Procedure AllocMemory()
'  
'   m_Line = New CLine
'       m_Arc = New CArc
'       m_Circle = New CCircle
'       m_PolyLine = New CPolyLine
'       m_Spline = New CSpline
'  
' End


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'
' Public Function GetLineCount() As Integer
'  
'   Return m_LineCount
'  
' End
'
' Public Function GetCircleCount() As Integer
'  
'   Return m_CircleCount
'  
' End
'
' Public Function GetArcCount() As Integer
'  
'   Return m_ArcCount
'  
' End
'
' Public Function GetLwPolyLineCount() As Integer
'  
'   Return m_PolyLineCount
'  
' End
'
' Public Function GetSplineCount() As Integer
'  
'   Return m_SplineCount
'  
' End




 
tercoIDE - Ver perfil del usuario Enviar mensaje privado  
tercoIDE [ Miercoles, 06 May 2020, 23:31 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
Bravo, Has sido hábil y capáz,  y más paciente que yo.
Interesante tu solución con Estructuras: por otra parte, las Estructuras son Clases sin eventos.

Bonum fecisti, melius egisti !



 
última edición por vuott el Jueves, 07 May 2020, 00:20; editado 2 veces 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Jueves, 07 May 2020, 00:16 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
vuott escribió: [Ver mensaje]
Bravo, Has sido hábil y capáz,  y más paciente que yo.
Interesante tu solución con Estructuras: por otra parte, las Estructuras son Clases sin eventos.

Bonum fecisti, melius egisti !


yo andaba con las Struct hasta que conocí a las Class y me enamore



 
tercoIDE - Ver perfil del usuario Enviar mensaje privado  
tercoIDE [ Jueves, 07 May 2020, 00:43 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 
Por si se quieren divertir un poco mas
https://www.gnu.org/software/libredwg/
Saludos.



 
tincho - Ver perfil del usuario Enviar mensaje privado  
tincho [ Domingo, 10 May 2020, 16:59 ]
Responder citando    Descargar mensaje  
Mensaje Re: Lector DXF 
 




 
vuott - Ver perfil del usuario Enviar mensaje privado  
vuott [ Domingo, 10 May 2020, 17:31 ]
Mostrar mensajes anteriores:    
 
Publicar nuevo tema  Responder al tema  Página 3 de 4
Ir a la página Anterior  1, 2, 3, 4  Siguiente
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 



 

cron