add support to prism regions to be exported to VMD
This commit is contained in:
@ -164,9 +164,9 @@ if LAMMPS was built with that package. See the :doc:`Build package
|
||||
<Build_package>` page for more info.
|
||||
|
||||
Only the following region styles are currently supported: *block*,
|
||||
*cylinder*, *cone*, *sphere*. For region style *cone* one of the two
|
||||
radii must be zero, since the equivalent VMD graphics primitive does not
|
||||
support truncated cones.
|
||||
*cone*, *cylinder*, *prism*, and *sphere*. For region style *cone* one
|
||||
of the two radii must be zero, since the equivalent VMD graphics
|
||||
primitive does not support truncated cones.
|
||||
|
||||
Moving or rotating regions as well as unions or intersecting regions are
|
||||
also currently not supported.
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "region_block.h"
|
||||
#include "region_cone.h"
|
||||
#include "region_cylinder.h"
|
||||
#include "region_prism.h"
|
||||
#include "region_sphere.h"
|
||||
|
||||
#include <cstring>
|
||||
@ -97,7 +98,7 @@ void Region2VMD::command(int narg, char **arg)
|
||||
|
||||
if (thisarg == "color") {
|
||||
color = arg[iarg];
|
||||
if (const auto &search = vmdcolors.find(color); search == vmdcolors.end())
|
||||
if (const auto &search = vmdcolors.find(color); search == vmdcolors.end())
|
||||
error->all(FLERR, iarg, "Color {} is not a known VMD color", color);
|
||||
|
||||
} else if (thisarg == "material") {
|
||||
@ -239,6 +240,32 @@ void Region2VMD::write_region(FILE *fp, Region *region)
|
||||
}
|
||||
}
|
||||
|
||||
} else if (regstyle == "prism") {
|
||||
const auto prism = dynamic_cast<RegPrism *>(region);
|
||||
if (!prism) {
|
||||
error->one(FLERR, Error::NOLASTLINE, "Region {} is not of style 'prism'", region->id);
|
||||
} else {
|
||||
// a prism is represented by 12 triangles
|
||||
utils::print(fp,
|
||||
"draw triangle {{{0} {2} {4}}} {{{1} {2} {4}}} {{{7} {3} {4}}}\n"
|
||||
"draw triangle {{{0} {2} {4}}} {{{6} {3} {4}}} {{{7} {3} {4}}}\n"
|
||||
"draw triangle {{{0} {2} {4}}} {{{1} {2} {4}}} {{{8} {9} {5}}}\n"
|
||||
"draw triangle {{{0} {2} {4}}} {{{10} {9} {5}}} {{{8} {9} {5}}}\n"
|
||||
"draw triangle {{{1} {2} {4}}} {{{8} {9} {5}}} {{{7} {3} {4}}}\n"
|
||||
"draw triangle {{{11} {12} {5}}} {{{8} {9} {5}}} {{{7} {3} {4}}}\n"
|
||||
"draw triangle {{{0} {2} {4}}} {{{6} {3} {4}}} {{{13} {12} {5}}}\n"
|
||||
"draw triangle {{{0} {2} {4}}} {{{10} {9} {5}}} {{{13} {12} {5}}}\n"
|
||||
"draw triangle {{{10} {9} {5}}} {{{8} {9} {5}}} {{{11} {12} {5}}}\n"
|
||||
"draw triangle {{{10} {9} {5}}} {{{13} {12} {5}}} {{{11} {12} {5}}}\n"
|
||||
"draw triangle {{{6} {3} {4}}} {{{7} {3} {4}}} {{{11} {12} {5}}}\n"
|
||||
"draw triangle {{{6} {3} {4}}} {{{13} {12} {5}}} {{{11} {12} {5}}}\n",
|
||||
prism->xlo, prism->xhi, prism->ylo, prism->yhi, prism->zlo, prism->zhi,
|
||||
prism->xlo + prism->xy, prism->xhi + prism->xy, prism->xhi + prism->xz,
|
||||
prism->ylo + prism->yz, prism->xlo + prism->xz,
|
||||
prism->xhi + prism->xy + prism->xz, prism->yhi + prism->yz,
|
||||
prism->xlo + prism->xy + prism->xz);
|
||||
}
|
||||
|
||||
} else if (regstyle == "sphere") {
|
||||
const auto sphere = dynamic_cast<RegSphere *>(region);
|
||||
if (!sphere) {
|
||||
|
||||
@ -26,6 +26,7 @@ namespace LAMMPS_NS {
|
||||
|
||||
class RegPrism : public Region {
|
||||
friend class CreateBox;
|
||||
friend class Region2VMD;
|
||||
|
||||
public:
|
||||
RegPrism(class LAMMPS *, int, char **);
|
||||
|
||||
Reference in New Issue
Block a user