dxfLayerMap.cxx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file dxfLayerMap.cxx
  10. * @author drose
  11. * @date 2004-05-04
  12. */
  13. #include "dxfLayerMap.h"
  14. #include "dxfFile.h"
  15. /**
  16. * Looks up the layer name in the map, and returns a pointer to the associated
  17. * DXFLayer. If this is the first time this layer name has been used, creates
  18. * a new DXFLayer by the given name. In this case, it calls
  19. * dxffile->new_layer() to create the layer, allowing user code to override
  20. * this function to create a specialized time, if desired.
  21. */
  22. DXFLayer *DXFLayerMap::
  23. get_layer(const std::string &name, DXFFile *dxffile) {
  24. iterator lmi;
  25. lmi = find(name);
  26. if (lmi != end()) {
  27. // The layer was already here.
  28. return (*lmi).second;
  29. }
  30. // Need a new layer.
  31. DXFLayer *layer = dxffile->new_layer(name);
  32. (*this)[name] = layer;
  33. return layer;
  34. }