| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_RENDERING_PLYVISITOR_H |
| 7 |
#define AVOGADRO_RENDERING_PLYVISITOR_H |
| 8 |
|
| 9 |
#include "visitor.h" |
| 10 |
|
| 11 |
#include "avogadrorendering.h" |
| 12 |
#include "spheregeometry.h" |
| 13 |
#include "cylindergeometry.h" |
| 14 |
#include "ambientocclusionspheregeometry.h" |
| 15 |
#include "linestripgeometry.h" |
| 16 |
#include "meshgeometry.h" |
| 17 |
#include "camera.h" |
| 18 |
#include <string> |
| 19 |
#include <vector> |
| 20 |
#include <iostream> |
| 21 |
#include <ostream> |
| 22 |
|
| 23 |
namespace Avogadro { |
| 24 |
namespace Rendering { |
| 25 |
|
| 26 |
/** |
| 27 |
* @class PLYVisitor plyvisitor.h <avogadro/rendering/plyvisitor.h> |
| 28 |
* @brief Visitor that visits scene elements and creates a PLY input file. |
| 29 |
* |
| 30 |
* This visitor will render elements in the scene to a text file that contains |
| 31 |
* elements that can be rendered as PLY. |
| 32 |
*/ |
| 33 |
|
| 34 |
class AVOGADRORENDERING_EXPORT PLYVisitor : public Visitor |
| 35 |
{ |
| 36 |
public: |
| 37 |
explicit PLYVisitor(const Camera& camera); |
| 38 |
~PLYVisitor() override; |
| 39 |
|
| 40 |
void begin(); |
| 41 |
std::string end(); |
| 42 |
|
| 43 |
/** |
| 44 |
* The overloaded visit functions, the base versions of which do nothing. |
| 45 |
*/ |
| 46 |
void visit(Node&) override { return; } |
| 47 |
void visit(GroupNode&) override { return; } |
| 48 |
void visit(GeometryNode&) override { return; } |
| 49 |
void visit(Drawable&) override; |
| 50 |
void visit(SphereGeometry&) override; |
| 51 |
void visit(AmbientOcclusionSphereGeometry&) override; |
| 52 |
void visit(CurveGeometry&) override { return; } |
| 53 |
void visit(CylinderGeometry&) override; |
| 54 |
void visit(MeshGeometry&) override; |
| 55 |
void visit(TextLabel2D&) override { return; } |
| 56 |
void visit(TextLabel3D&) override { return; } |
| 57 |
void visit(LineStripGeometry& geometry) override; |
| 58 |
|
| 59 |
void setCamera(const Camera& c) { m_camera = c; } |
| 60 |
Camera camera() const { return m_camera; } |
| 61 |
|
| 62 |
void setBackgroundColor(const Vector3ub& c) { m_backgroundColor = c; } |
| 63 |
void setAmbientColor(const Vector3ub& c) { m_ambientColor = c; } |
| 64 |
void setAspectRatio(float ratio) { m_aspectRatio = ratio; } |
| 65 |
|
| 66 |
private: |
| 67 |
Camera m_camera; |
| 68 |
Vector3ub m_backgroundColor; |
| 69 |
Vector3ub m_ambientColor; |
| 70 |
float m_aspectRatio; |
| 71 |
long m_vertexCount = 0; |
| 72 |
long m_faceCount = 0; |
| 73 |
std::string m_sceneVertices = ""; |
| 74 |
std::string m_sceneFaces = ""; |
| 75 |
|
| 76 |
void visitSphereIcosphereRecursionMethod(const SphereColor& geometry, |
| 77 |
unsigned int subdivisions); |
| 78 |
void visitCylinderLateralMethod(const CylinderColor& geometry, |
| 79 |
unsigned int lateralFaces); |
| 80 |
}; |
| 81 |
|
| 82 |
} // End namespace Rendering |
| 83 |
} // End namespace Avogadro |
| 84 |
|
| 85 |
#endif // AVOGADRO_RENDERING_PLYVISITOR_H |