LegalizeAdulthood / cgm

Computer Graphics Metafile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Computer Graphics Metafile

The Computer Graphics Metafile (CGM) is an ISO/ANSI standard for the interchange of 2D picture descriptions created in 1986. Graphical data for interchange must conform to uniform semantics in different software applications in order for the interchange to be useflu. CGM defines the semantics of the data elements in a functional specifiation, and one or more element encodings.

When CGM was originally defined, three encodings were standardized: binary, character and clear text. The binary and clear text encodings are publicly documented, while the character encoding is considered obsolete.

CGM is not to be confused with the metafile format described in Annex E to the Graphical Kernel System standard, often referred to as a GKS Metafile (GKSM). GKS metafiles map directly to the functional specification of GKS, whereas the CGM functional description provides for some facililities that cannot be directly expressed by standard GKS functions.

This Library

This library implements writing of binary and clear text encoded metafiles as a C++ API. The implementation is lifted from an old release of the GR Framework and adapted to write to a std::ostream instead of a C FILE.

Unit tests have been written in Catch2 to cover the supported elements in the clear text and binary encodings.

This library has limitations based on its origin:

  • Output only
  • No character encoding
  • Some parameter byte counts for binary elements appear incorrect
  • Some assumptions of precision are made
  • VDC coordinates are assumed to be integer (e.g. pixel) coordinates

This library is intended for use in historical simulations of graphic environments and in particular is intended to serve as the basis for reading and writing CGM files via a GKS metafile workstation type. The original code was created purely for such a metafile output (MO) workstation in the implementation of GKS for the GR Framework.

It is useful to have a generic CGM library for the purposes of other CGM tools such as analyzers, inspectors, encoding converters, etc.

To achieve the goals beyond of a GKS MO workstation with the assumed constraints, new code will need to be written. However, starting from an existing implementation is easier than starting from scratch.

Building

This repository uses VcPkg to obtain the Catch2 unit test framework and uses CMake to describe the build. Clone the VcPkg repo from github to somewhere on your machine and invoke the bootstrap script in the repo to get vcpkg downloaded and configured. Then invoke CMake using the toolchain file provided by vcpkg to generate the necessary build files.

> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
> cmake --build [build directory]

Once you've generated the necessary build files with CMake, you will have a target for the library and a target for the test executable.

About

Computer Graphics Metafile


Languages

Language:C++ 96.2%Language:C 3.4%Language:CMake 0.4%