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 
67 
74 
75  operator const void*() const;
76  bool operator!() const;
77 
79 
80  void close();
81 
82  private:
83  void process(const Object3D& obj);
84  void visitTriangleMesh(const TriangleMesh3D& mesh);
85 
86  typedef std::vector<Math::Vector3D> VertexArray;
87 
88  std::ostream& output;
89  bool state;
90  bool headerWritten;
91  Math::Matrix4D vtxTransform;
92  VertexArray transVertices;
93  };
94  } // namespace Vis
95 } // namespace CDPL
96 
97 #endif // CDPL_VIS_STLOBJECT3DWRITER_HPP
Definition of class CDPL::Base::DataWriter.
Definition of matrix data types.
Definition of 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.
STLObject3DWriter & operator=(const STLObject3DWriter &)=delete
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.