function gm = importGeometry(self, geofilename, varargin)
% importGeometry - Creates a geometry object from the specified STL or STEP
%    geometry file.
%    G = importGeometry(PDEM,FILENAME) Constructs a geometry object from STL
%    or STEP data imported from a file. The STL data can represent a
%    3-D solid or a planar geometry. Planar geometry is supported by
%    STL format only. FILENAME is a character vector or string
%    specifying the name of the STL or STEP file ending with .stl, .STL,
%    .step, or .STEP and the path to it.
%    You can omit the path name if the file is in the
%    current directory or in a directory on the MATLAB path.
%    G is the new geometry object returned by importGeometry.
%    The new geometry object is assigned to the Geometry property of PDEM.
%    G is a handle to the new geometry object returned by importGeometry.
%
%    G = importGeometry(PDEM,FILENAME,'MaxRelativeDeviation',d) lets you
%    control the accuracy of the geometry import from a STEP file by
%    specifying the relative sag. This parameter is ignored for STL files.
%
%    Example 1:  Import a planar geometry from an STL file. Plot the geometry.
%      thePde = createpde();
%      gm = importGeometry(thePde,'PlateHolePlanar.stl')
%      pdegplot(gm, 'EdgeLabels','on')
%
%    Example 2:  Import a 3-D STL geometry from an STL file. Plot the geometry.
%      thePde = createpde();
%      gm = importGeometry(thePde,'Block.stl')
%      pdegplot(gm, 'FaceLabels','on')
%
%    Example 3:  Import a 3-D geometry from a STEP file. Plot the geometry.
%      thePde = createpde();
%      gm = importGeometry(thePde,'BlockWithHole.step')
%      pdegplot(gm, 'FaceLabels','on')
%
%    See also pdegplot, pde.DiscreteGeometry, pde.DiscreteGeometry/addVertex

% Copyright 2014-2022 The MathWorks, Inc.

        if nargin ~= 2 && nargin ~= 4
            error(message('pde:pdeGeometryClass:InvalidNumInputArgs'));
        end
        if ~isempty(self.Geometry)                        
           error(message('pde:pdeModel:noAssemSupport')); 
        end
        
        gm = importGeometry(geofilename,varargin{:});
        self.Geometry = gm;
    end
