Class DwgFile


  • public class DwgFile
    extends Object
    The DwgFile class provides a revision-neutral interface for reading and handling DWG files Reading methods are useful for reading DWG files, and handling methods like calculateDwgPolylines() are useful for handling more complex objects in the DWG file
    Author:
    jmorell
    • Constructor Detail

      • DwgFile

        public DwgFile​(String filePath)
        Creates a new DwgFile object given the absolute path to a DWG file
        Parameters:
        filePath - an absolute path to the DWG file
    • Method Detail

      • read

        public void read()
                  throws IOException
        Reads a DWG file and put its objects in the dwgObjects Vector This method is version independent
        Throws:
        IOException - If the file location is wrong
      • applyExtrusions

        public void applyExtrusions()
        Modify the geometry of the objects applying the Extrusion vector where it is necessary
      • calculateGisModelDwgPolylines

        public void calculateGisModelDwgPolylines()
        Configure the geometry of the polylines in a DWG file from the vertex list in this DWG file. This geometry is given by an array of Points. Besides, manage closed polylines and polylines with bulges in a GIS Data model. It means that the arcs of the polylines will be done through a set of points and a distance between these points.
      • calculateCadModelDwgPolylines

        public void calculateCadModelDwgPolylines()
        Configure the geometry of the polylines in a DWG file from the vertex list in this DWG file. This geometry is given by an array of Points Besides, manage closed polylines and polylines with bulges in a GIS Data model. It means that the arcs of the polylines will be done through a curvature parameter called bulge associated with the points of the polyline.
      • blockManagement

        public void blockManagement()
        Modify the geometry of the objects contained in the blocks of a DWG file and add these objects to the DWG object list.
      • initializeLayerTable

        public void initializeLayerTable()
        Initialize a new Vector that contains the DWG file layers. Each layer have three parameters. These parameters are handle, name and color
      • getLayerName

        public String getLayerName​(DwgObject entity)
        Returns the name of the layer of a DWG object
        Parameters:
        entity - DWG object which we want to know its layer name
        Returns:
        String Layer name of the DWG object
      • getColorByLayer

        public int getColorByLayer​(DwgObject entity)
        Returns the color of the layer of a DWG object
        Parameters:
        entity - DWG object which we want to know its layer color
        Returns:
        int Layer color of the DWG object in the Autocad color code
      • testDwg3D

        public void testDwg3D()
        Test if the DWG file is 2D or 3D. If there is any object with a non cero elevation value, the file is considered 3D.
      • addDwgSectionOffset

        public void addDwgSectionOffset​(String key,
                                        int seek,
                                        int size)
        Add a DWG section offset to the dwgSectionOffsets vector
        Parameters:
        key - Define the DWG section
        seek - Offset of the section
        size - Size of the section
      • getDwgSectionOffset

        public int getDwgSectionOffset​(String key)
        Returns the offset of DWG section given by its key
        Parameters:
        key - Define the DWG section
        Returns:
        int Offset of the section in the DWG file
      • addDwgObjectOffset

        public void addDwgObjectOffset​(int handle,
                                       int offset)
        Add a DWG object offset to the dwgObjectOffsets vector
        Parameters:
        handle - Object handle
        offset - Offset of the object data in the DWG file
      • addDwgObject

        public void addDwgObject​(DwgObject dwgObject)
        Add a DWG object to the dwgObject vector
        Parameters:
        dwgObject - DWG object
      • addDwgClass

        public void addDwgClass​(DwgClass dwgClass)
        Add a DWG class to the dwgClasses vector
        Parameters:
        dwgClass - DWG class
      • getDwgObjectOffsets

        public Vector getDwgObjectOffsets()
        Returns:
        Returns the dwgObjectOffsets.
      • getDwgObjects

        public Vector getDwgObjects()
        Returns:
        Returns the dwgObjects.
      • getFileName

        public String getFileName()
        Returns:
        Returns the fileName.
      • isDwg3DFile

        public boolean isDwg3DFile()
        Returns:
        Returns the dwg3DFile.
      • setDwg3DFile

        public void setDwg3DFile​(boolean dwg3DFile)
        Parameters:
        dwg3DFile - The dwg3DFile to set.