libsurf
Programmer's Documentation

stepfile.h (r6227/r5385)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_STEPFILE_H
16 #define SURF_STEPFILE_H
17 
18 #include "forward.h"
19 #include "stepentity.h"
20 
44 class StepFile
45 {
46 public:
47 
48  typedef StepEntitySet::iterator iterator;
49  typedef StepEntitySet::const_iterator const_iterator;
50 
52  StepFile() {}
53 
55  uint size() const {return entities.size();}
56 
58  iterator begin() {return entities.begin();}
59 
61  iterator end() {return entities.end();}
62 
64  const_iterator begin() const {return entities.begin();}
65 
67  const_iterator end() const {return entities.end();}
68 
70  StepEntityPtr operator[] (StepID eid) const {
71  StepEntitySet::const_iterator itr;
72  StepEntity dmy(eid);
73  itr = entities.find( StepEntityPtr(&dmy, null_deleter()) );
74  if (itr != entities.end())
75  return *itr;
76  else
77  return StepEntityPtr();
78  }
79 
81  template <class Entity>
82  bool as(StepID eid, const Entity **p) const {
83  *p = dynamic_cast<const Entity*>( ((*this)[eid]).get() );
84  return *p != 0;
85  }
86 
88  static bool isStepFile(const std::string & fname);
89 
91  void read(const std::string & fname);
92 
94  void write(std::ostream & os) const;
95 
96 private:
97 
99  void processLine(const std::string & line);
100 
101 public:
102 
104  std::string hdDescription, hdFileName, hdAuthor;
105 
107  std::string hdOrg, hdPpVersion, hdOrigSystem, hdAuth;
108 
109 private:
110 
112  StepEntitySet entities;
113 };
114 
115 #endif // STEPFILE_H
StepEntitySet entities
geometry and topology entities
Definition: stepfile.h:112
iterator begin()
allow iteration over entities
Definition: stepfile.h:58
uint size() const
number of entities in file
Definition: stepfile.h:55
iterator end()
allow iteration over entities
Definition: stepfile.h:61
void read(const std::string &fname)
read file from disk
Definition: stepfile.cpp:37
static bool isStepFile(const std::string &fname)
determine whether a file could be a step file by looking at the header
Definition: stepfile.cpp:112
void processLine(const std::string &line)
reading : process data section line
std::string hdDescription
header: description, filename, author
Definition: stepfile.h:104
std::string hdOrg
header: organisation, version, originating system, authorization
Definition: stepfile.h:107
StepFile()
create empty file
Definition: stepfile.h:52
const_iterator end() const
allow iteration over entities
Definition: stepfile.h:67
StepEntityPtr operator[](StepID eid) const
access entity by entity id
Definition: stepfile.h:70
void write(std::ostream &os) const
write file to stream
Definition: stepfile.cpp:74
bool as(StepID eid, const Entity **p) const
access as a certain entity type
Definition: stepfile.h:82
Common base class for all STEP entities.
Definition: stepentity.h:31
const_iterator begin() const
allow iteration over entities
Definition: stepfile.h:64
STEP File.
Definition: stepfile.h:44
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5