Chemical Data Processing Library C++ API - Version 1.3.0
STLObject3DWriter.hpp
Go to the documentation of this file.
1 /*
2  * STLObject3DWriter.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_VIS_STLOBJECT3DWRITER_HPP
30 #define CDPL_VIS_STLOBJECT3DWRITER_HPP
31 
32 #include <iosfwd>
33 #include <vector>
34 
35 #include "CDPL/Vis/APIPrefix.hpp"
37 #include "CDPL/Base/DataWriter.hpp"
38 #include "CDPL/Math/Matrix.hpp"
39 #include "CDPL/Math/Vector.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Vis
46  {
47 
48  class Object3D;
49 
55  {
56 
57  public:
62  STLObject3DWriter(std::ostream& os);
63 
65 
72 
73  operator const void*() const;
74  bool operator!() const;
75 
76  void close();
77 
78  private:
79  void process(const Object3D& obj);
80  void visitTriangleMesh(const TriangleMesh3D& mesh);
81 
82  typedef std::vector<Math::Vector3D> VertexArray;
83 
84  std::ostream& output;
85  bool state;
86  bool headerWritten;
87  Math::Matrix4D vtxTransform;
88  VertexArray transVertices;
89  };
90  } // namespace Vis
91 } // namespace CDPL
92 
93 #endif // CDPL_VIS_STLOBJECT3DWRITER_HPP
Definition of the class CDPL::Base::DataWriter.
Definition of matrix data types.
Definition of the class CDPL::Vis::Shape3DVisitor.
Definition of vector data types.
Definition of the preprocessor macro CDPL_VIS_API.
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
An interface for writing data objects of a given type to an arbitrary data sink.
Definition: DataWriter.hpp:63
Object3D.
Definition: Object3D.hpp:52
Outputs 3D visualization data represented by Vis::Object3D instances in the STL [STLFMT] format.
Definition: STLObject3DWriter.hpp:55
STLObject3DWriter(const STLObject3DWriter &)=delete
STLObject3DWriter(std::ostream &os)
Constructs a STLObject3DWriter instance that will write Vis::Object3D data to the output stream os.
Base::DataWriter< Object3D > & write(const Object3D &obj)
Outputs the Vis::Object3D instance obj.
bool operator!() const
Tells whether the writer is in a bad state.
void close()
Writes format dependent data (if required) to mark the end of output.
The base of all Vis::Shape3D visitor implementations [VPTN].
Definition: Shape3DVisitor.hpp:49
Data structure for describing the geometric shape of 3D objects by means of a triangle mesh.
Definition: TriangleMesh3D.hpp:50
The namespace of the Chemical Data Processing Library.