www.cemf.ir
stlFile.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #ifndef __stlFile_hpp__
23 #define __stlFile_hpp__
24 
25 #include "types.hpp"
26 #include "Vectors.hpp"
27 #include "Lists.hpp"
28 #include "fileSystem.hpp"
29 
30 
31 
32 namespace pFlow
33 {
34 
35 
36 class iIstream;
37 
38 class stlFile
39 {
40 protected:
41 
43 
44  // - list of verticies of all solids
46 
47  // - list of names of all solids
49 
50  // - file name of stl file (used for reading and writing)
51  mutable fileSystem file_;
52 
53  // - protected members
54 
55  bool readSolid(iIstream& is, realx3x3Vector & vertecies, word & name);
56 
57  bool readFacet(iIstream& is, realx3x3& tri);
58 
59  bool writeSolid(iOstream& os, const realx3x3Vector& vertecies, const word& name)const;
60 
61  bool writeFacet(iOstream& os, const realx3x3& tri)const;
62 
63 
64 public:
65 
67  // - construct with file name
68  // an empty stlFile
69  stlFile( fileSystem file );
70 
71  // - construct with file name and one solid (copy)
72  stlFile( fileSystem file, const word& name, const realx3x3Vector& vertecies);
73 
74  // - construct with file name and one solid (copy)
75  stlFile( fileSystem file, const word& name, realx3x3Vector&& vertecies);
76 
77  // - copy construct
78  stlFile(const stlFile&) = default;
79 
80  // - move construct
81  stlFile(stlFile&&) = default;
82 
83  ~stlFile() = default;
84 
86 
87  // - add a solid at the end of list, with copy operation
88  void addSolid(const word& name, const realx3x3Vector& vertecies);
89 
90  // - add a solid at the end of list, with move operation
91  void addSolid(const word& name, realx3x3Vector&& vertecies);
92 
93  // - clear current content and read from file
94  bool read();
95 
96  // - write the current contnet to file
97  bool write()const;
98 
99  // - set stl file path
100  void setFile(fileSystem file) const;
101 
102  // - name of solids
103  const wordList& names()const;
104 
105  // - number of solids
106  size_t size()const;
107 
108  // - vertecies of ith solid
109  const realx3x3Vector& solid(size_t i)const;
110 
111  // - name of ith solid
112  const word& name(size_t i)const;
113 
114 };
115 
116 
117 } // pFlow
118 
119 #endif //__stlFile_hpp__
pFlow::List< word >
pFlow::ListPtr
Definition: ListPtr.hpp:37
Lists.hpp
types.hpp
pFlow::stlFile::stlFile
stlFile(fileSystem file)
Definition: stlFile.cpp:238
pFlow::stlFile::file_
fileSystem file_
Definition: stlFile.hpp:51
pFlow::stlFile::solid
const realx3x3Vector & solid(size_t i) const
Definition: stlFile.cpp:355
pFlow::stlFile::writeFacet
bool writeFacet(iOstream &os, const realx3x3 &tri) const
Definition: stlFile.cpp:178
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::stlFile
Definition: stlFile.hpp:38
Vectors.hpp
pFlow::stlFile::writeSolid
bool writeSolid(iOstream &os, const realx3x3Vector &vertecies, const word &name) const
Definition: stlFile.cpp:222
pFlow::stlFile::name
const word & name(size_t i) const
Definition: stlFile.cpp:371
fileSystem.hpp
pFlow
Definition: demGeometry.hpp:27
pFlow::stlFile::size
size_t size() const
Definition: stlFile.cpp:349
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::stlFile::addSolid
void addSolid(const word &name, const realx3x3Vector &vertecies)
Definition: stlFile.cpp:270
pFlow::stlFile::solidNames_
wordList solidNames_
Definition: stlFile.hpp:48
pFlow::stlFile::~stlFile
~stlFile()=default
pFlow::stlFile::readSolid
bool readSolid(iIstream &is, realx3x3Vector &vertecies, word &name)
Definition: stlFile.cpp:52
pFlow::stlFile::names
const wordList & names() const
Definition: stlFile.cpp:344
pFlow::stlFile::setFile
void setFile(fileSystem file) const
Definition: stlFile.cpp:337
pFlow::stlFile::readFacet
bool readFacet(iIstream &is, realx3x3 &tri)
Definition: stlFile.cpp:127
pFlow::stlFile::read
bool read()
Definition: stlFile.cpp:292
pFlow::triple
A set of 3 variables that can be used for vector variables.
Definition: triple.hpp:36
pFlow::Vector
Definition: Vector.hpp:48
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::stlFile::write
bool write() const
Definition: stlFile.cpp:324
pFlow::stlFile::solids_
ListPtr< realx3x3Vector > solids_
Definition: stlFile.hpp:45