| 1 |
gezelter |
1084 |
/********************************************************************** |
| 2 |
|
|
Copyright (C) 2002 by Steffen Reith <streit@streit.cc> |
| 3 |
|
|
Some portions Copyright (C) 2003-2005 by Geoffrey R. Hutchison |
| 4 |
|
|
Some portions Copyright (C) 2004 by Chris Morley |
| 5 |
|
|
|
| 6 |
|
|
This program is free software; you can redistribute it and/or modify |
| 7 |
|
|
it under the terms of the GNU General Public License as published by |
| 8 |
|
|
the Free Software Foundation version 2 of the License. |
| 9 |
|
|
|
| 10 |
|
|
This program is distributed in the hope that it will be useful, |
| 11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
|
|
GNU General Public License for more details. |
| 14 |
|
|
***********************************************************************/ |
| 15 |
|
|
|
| 16 |
|
|
#ifndef OB_POVRAYFORMAT_HPP |
| 17 |
|
|
#define OB_POVRAYFORMAT_HPP |
| 18 |
|
|
|
| 19 |
|
|
/* ---- C includes ---- */ |
| 20 |
|
|
#include <math.h> |
| 21 |
|
|
#include <time.h> |
| 22 |
|
|
#include <stdlib.h> |
| 23 |
|
|
|
| 24 |
|
|
/* ---- OpenBabel include ---- */ |
| 25 |
|
|
#include "config.h" |
| 26 |
|
|
#include "mol.hpp" |
| 27 |
|
|
#include "obconversion.hpp" |
| 28 |
|
|
|
| 29 |
|
|
/* ---- C++ includes ---- */ |
| 30 |
|
|
#include <string> |
| 31 |
|
|
#if defined(HAVE_SSTREAM) |
| 32 |
|
|
#include <sstream> |
| 33 |
|
|
#else |
| 34 |
|
|
#include <strstream> |
| 35 |
|
|
#endif |
| 36 |
|
|
|
| 37 |
|
|
/* ---- Max. length of a atom-label ---- */ |
| 38 |
|
|
#define StrLen 32 |
| 39 |
|
|
|
| 40 |
|
|
/* ---- Define max. length of domainname ---- */ |
| 41 |
|
|
#define MAXDOMAINNAMELEN 256 |
| 42 |
|
|
|
| 43 |
|
|
/* ---- Maximal radius of an atom. Needed for bounding box ---- */ |
| 44 |
|
|
#define MAXRADIUS (double) 3.0 |
| 45 |
|
|
|
| 46 |
|
|
/* ---- Define index of first atom if needed ---- */ |
| 47 |
|
|
#ifndef MIN_ATOM |
| 48 |
|
|
#define MIN_ATOM 1 |
| 49 |
|
|
#endif |
| 50 |
|
|
|
| 51 |
|
|
/* ---- Size of time-string ---- */ |
| 52 |
|
|
#define TIME_STR_SIZE 64 |
| 53 |
|
|
|
| 54 |
|
|
/* ---- if x < = EPSILON then x = 0.0 ---- */ |
| 55 |
|
|
#define EPSILON (double) 1e-4 |
| 56 |
|
|
|
| 57 |
|
|
/* ---- Define makro for calculating x^2 ---- */ |
| 58 |
|
|
#ifdef SQUARE |
| 59 |
|
|
#undef SQUARE |
| 60 |
|
|
#endif |
| 61 |
|
|
#define SQUARE(x) ((x) * (x)) |
| 62 |
|
|
|
| 63 |
|
|
/* ---- Define PI (if needed) ---- */ |
| 64 |
|
|
#ifndef PI |
| 65 |
|
|
#define PI ((double) 3.1415926535897932384626433) |
| 66 |
|
|
#endif |
| 67 |
|
|
|
| 68 |
|
|
/* ---- Convert RAD to DEG ---- */ |
| 69 |
|
|
#define RAD2DEG(r) (((double) 180.0 * r) / PI) |
| 70 |
|
|
|
| 71 |
|
|
using namespace std; |
| 72 |
|
|
namespace OpenBabel |
| 73 |
|
|
{ |
| 74 |
|
|
|
| 75 |
|
|
class PovrayFormat : public OBFormat |
| 76 |
|
|
{ |
| 77 |
|
|
public: |
| 78 |
|
|
//Register this format type ID |
| 79 |
|
|
PovrayFormat() |
| 80 |
|
|
{ |
| 81 |
|
|
OBConversion::RegisterFormat("pov",this); |
| 82 |
|
|
} |
| 83 |
|
|
|
| 84 |
|
|
virtual const char* Description() //required |
| 85 |
|
|
{ |
| 86 |
|
|
return |
| 87 |
|
|
"POV-Ray input format\n \ |
| 88 |
|
|
No comments yet\n"; |
| 89 |
|
|
}; |
| 90 |
|
|
|
| 91 |
|
|
virtual const char* SpecificationURL() |
| 92 |
|
|
{return "http://www.povray.org/";}; //optional |
| 93 |
|
|
|
| 94 |
|
|
//Flags() can return be any the following combined by | or be omitted if none apply |
| 95 |
|
|
// NOTREADABLE READONEONLY NOTWRITABLE WRITEONEONLY |
| 96 |
|
|
virtual unsigned int Flags() |
| 97 |
|
|
{ |
| 98 |
|
|
return NOTREADABLE | WRITEONEONLY; |
| 99 |
|
|
}; |
| 100 |
|
|
|
| 101 |
|
|
//////////////////////////////////////////////////// |
| 102 |
|
|
/// The "API" interface functions |
| 103 |
|
|
virtual bool WriteMolecule(OBBase* pOb, OBConversion* pConv); |
| 104 |
|
|
|
| 105 |
|
|
//////////////////////////////////////////////////// |
| 106 |
|
|
/// The "Convert" interface functions |
| 107 |
|
|
virtual bool WriteChemObject(OBConversion* pConv) |
| 108 |
|
|
{ |
| 109 |
|
|
//Retrieve the target OBMol |
| 110 |
|
|
OBBase* pOb = pConv->GetChemObject(); |
| 111 |
|
|
OBMol* pmol = dynamic_cast<OBMol*> (pOb); |
| 112 |
|
|
bool ret=false; |
| 113 |
|
|
if(pmol) |
| 114 |
|
|
ret=WriteMolecule(pmol,pConv); |
| 115 |
|
|
|
| 116 |
|
|
std::string auditMsg = "OpenBabel::Write molecule "; |
| 117 |
|
|
std::string description(Description()); |
| 118 |
|
|
auditMsg += description.substr( 0, description.find('\n') ); |
| 119 |
|
|
obErrorLog.ThrowError(__func__, |
| 120 |
|
|
auditMsg, |
| 121 |
|
|
obAuditMsg); |
| 122 |
|
|
delete pOb; |
| 123 |
|
|
return ret; |
| 124 |
|
|
}; |
| 125 |
|
|
}; |
| 126 |
|
|
|
| 127 |
|
|
} |
| 128 |
|
|
#endif |
| 129 |
|
|
|