pax_global_header 0000666 0000000 0000000 00000000064 14112012703 0014501 g ustar 00root root 0000000 0000000 52 comment=11044b0bd7844a5241529e7f9c45ff6ed5ab22bf
avogadrolibs-1.95.1/ 0000775 0000000 0000000 00000000000 14112012703 0014252 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/.clang-format 0000664 0000000 0000000 00000005337 14112012703 0016635 0 ustar 00root root 0000000 0000000 ---
# This was based on the Mozilla style from clang-format 3.8.
# Effectively creating a snapshot to produce more consistent results with later
# versions of clang-format.
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Mozilla
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
avogadrolibs-1.95.1/.github/ 0000775 0000000 0000000 00000000000 14112012703 0015612 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/.github/FUNDING.yml 0000664 0000000 0000000 00000000172 14112012703 0017427 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
open_collective: avogadro # Replace with a single Open Collective username
avogadrolibs-1.95.1/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14112012703 0017775 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/.github/ISSUE_TEMPLATE/bug_report.md 0000664 0000000 0000000 00000001531 14112012703 0022467 0 ustar 00root root 0000000 0000000 ---
name: Bug report
about: Create a report to help us improve
---
**Avogadro version: (please complete the following information from the About box):**
- Avogadrolibs: (e.g. 1.90.0-316-g6d14770)
- Qt: (e.g., 5.9.5)
**Desktop version: (please complete the following information):**
- OS: [e.g. MacOS]
- Version [e.g. 10.12.4]
- Compiler (if you built from source)
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here. **Please consider uploading or linking test files.**
avogadrolibs-1.95.1/.github/ISSUE_TEMPLATE/feature_request.md 0000664 0000000 0000000 00000001425 14112012703 0023524 0 ustar 00root root 0000000 0000000 ---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I wish Avogadro calculated XYQ moments to render with ..
**Describe the solution you'd like**
A clear and concise description of what you want to happen. Please be detailed. How might this feature work (e.g., first a window would open and you'd click to …)
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
Please consider opening a topic on https://discuss.avogadro.cc/ to allow further public discussion
avogadrolibs-1.95.1/.github/PULL_REQUEST_TEMPLATE 0000664 0000000 0000000 00000002615 14112012703 0021020 0 ustar 00root root 0000000 0000000 Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
avogadrolibs-1.95.1/.github/config.yml 0000664 0000000 0000000 00000001770 14112012703 0017607 0 ustar 00root root 0000000 0000000 # Configuration for welcome - https://github.com/behaviorbot/welcome
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
# Comment to be posted to on first time issues
newIssueWelcomeComment: >
Thanks for opening your first issue here! Please try to include example files and screenshots if possible.
If you're looking for support, please post on our forum: https://discuss.avogadro.cc/
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
# Comment to be posted to on PRs from first time contributors in your repository
newPRWelcomeComment: >
Thanks for opening this pull request! Please check out our contributing guidelines and check for the automated tests.
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
# Comment to be posted to on pull requests merged by a first time user
firstPRMergeComment: >
Congrats on merging your first pull request! 🎉 Thanks for making Avogadro better for everyone!
avogadrolibs-1.95.1/.github/release-drafter.yml 0000664 0000000 0000000 00000002000 14112012703 0021372 0 ustar 00root root 0000000 0000000 name-template: 'Avogadro $RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
- title: '✨ Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'chore'
- 'build'
- title: '📚 Translations'
labels:
- 'i18n'
autolabeler:
- label: 'build'
branch:
- '/build\/.+/'
title:
- '/build/i'
- label: 'bug'
branch:
- '/fix\/.+/'
title:
- '/fix/i'
- label: 'i18n'
branch:
- '/weblate\/.+/'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: minor
template: |
## Changes
$CHANGES
## Credits
Thanks to many contributors, including: $CONTRIBUTORS
avogadrolibs-1.95.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14112012703 0017647 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/.github/workflows/add_artifact_urls.yml 0000664 0000000 0000000 00000001223 14112012703 0024042 0 ustar 00root root 0000000 0000000 name: add artifact links to pull request and related issues
on:
workflow_run:
workflows: ['CMake Build Matrix']
types: [completed]
jobs:
artifacts-url-comments:
name: add artifact links to pull request and related issues job
runs-on: windows-2019
steps:
- name: add artifact links to pull request and related issues step
uses: tonyhallett/artifacts-url-comments@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prefix: Here are the build results
suffix: Artifacts will only be retained for 90 days.
format: name
addTo: pullandissues
avogadrolibs-1.95.1/.github/workflows/build_cmake.yml 0000664 0000000 0000000 00000017401 14112012703 0022634 0 ustar 00root root 0000000 0000000 name: CMake Build Matrix
# Many thanks to Cristian Adam for examples
# e.g. https://github.com/cristianadam/HelloWorld/blob/master/.github/workflows/build_cmake.yml
# https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/
on: [push, pull_request, workflow_dispatch]
env:
BUILD_TYPE: Release
QT_VERSION: 5.12.10
# this is different from MACOSX_DEPLOYMENT_TARGET to prevent build problems
# we set MACOSX_DEPLOYMENT_TARGET later
MACOS_TARGET: 10.12
FEATURES: -DUSE_VTK=ON -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04 GCC", artifact: "Ubuntu-2004.tar.gz",
os: ubuntu-20.04,
cc: "gcc", cxx: "g++",
cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF",
cpack: "",
}
- {
name: "Ubuntu 18.04 GCC", artifact: "",
os: ubuntu-18.04,
cc: "gcc", cxx: "g++",
cmake_flags: "-G Ninja -DENABLE_TESTING=ON -DTEST_QTGL=OFF",
cpack: "",
}
- {
name: "macOS Latest Clang", artifact: "macOS.dmg",
os: macos-latest,
cc: "clang", cxx: "clang++",
cmake_flags: "-G Ninja",
cpack_flags: "-G DragNDrop",
}
- {
name: "Windows Latest MSVC", artifact: "Win64.exe",
os: windows-latest,
cc: "cl", cxx: "cl",
cmake_flags: " ",
build_flags: "-j 2",
cpack_flags: "-G NSIS",
}
steps:
- name: Install Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get -qq update
sudo apt-get -qq install ninja-build libeigen3-dev libboost-all-dev libglew-dev libxml2-dev qt5-default libqt5x11extras5-dev libqt5svg5-dev
- name: Install Dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install ninja eigen glew
- name: Install Dependencies (Windows)
if: runner.os == 'Windows'
run: choco install ninja
- name: Checkout openchemistry
uses: actions/checkout@v2
with:
repository: openchemistry/openchemistry
submodules: recursive
- name: Checkout avogadroapp
uses: actions/checkout@v2
with:
repository: openchemistry/avogadroapp
path: avogadroapp
- name: Checkout avogadrolibs
uses: actions/checkout@v2
with:
path: avogadrolibs
- name: Cache Qt
id: cache-qt
uses: actions/cache@v2
with:
path: ../Qt
key: ${{ runner.os }}-QtCache
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
cached: ${{ steps.cache-qt.outputs.cache-hit }}
version: ${{ env.QT_VERSION }}
- name: Configure MSVC Command Prompt
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Grab cache files
uses: actions/cache@v2
if: runner.os != 'Windows'
with:
path: |
${{ runner.workspace }}/build/thirdparty
${{ runner.workspace }}/build/Downloads
key: ${{ matrix.config.name }}-thirdparty
- name: Configure
run: |
if [ ! -d "${{ runner.workspace }}/build" ]; then mkdir "${{ runner.workspace }}/build"; fi
cd "${{ runner.workspace }}/build"
# won't have any effect except on Mac
echo "MACOSX_DEPLOYMENT_TARGET=${{ env.MACOS_TARGET }}" >> $GITHUB_ENV
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE ${{env.FEATURES}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{matrix.config.cmake_flags}}
shell: bash
- name: Build
run: |
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake --build . --config ${{env.BUILD_TYPE}} ${{matrix.config.build_flags}}
shell: bash
working-directory: ${{ runner.workspace }}/build
- name: Fix Mac plugins
if: runner.os == 'macOS'
working-directory: ${{ runner.workspace }}/build/prefix/lib/openbabel
run: |
for plugin in *.so; do
for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do
export lib=`echo $libpath | cut -d '/' -f 9`;
echo "Fixing $plugin $lib $libpath"
install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
done
done
cd .. # build/prefix/lib
for plugin in libinchi.?.?.?.dylib; do
for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do
export lib=`echo $libpath | cut -d '/' -f 9`;
echo "Fixing $plugin $lib $libpath"
install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
done
done
otool -L libinchi.?.?.?.dylib
cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/
- name: Run tests
if: runner.os == 'Linux'
shell: cmake -P {0}
run: |
include(ProcessorCount)
ProcessorCount(N)
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
execute_process(
COMMAND ctest -j ${N}
WORKING_DIRECTORY ${{ runner.workspace }}/build/avogadrolibs
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Running tests failed!")
endif()
- name: Pack
if: matrix.config.artifact != 0
run: cpack ${{ matrix.config.cpack_flags }}
working-directory: ${{ runner.workspace }}/build/avogadroapp
- name: Upload
if: matrix.config.artifact != 0
uses: actions/upload-artifact@v2
with:
path: ${{ runner.workspace }}/build/avogadroapp/Avogadro2*.*
name: ${{ matrix.config.artifact }}
release:
if: contains(github.ref, 'tags/')
runs-on: ubuntu-latest
needs: build
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Avogadro ${{ github.ref }}
draft: true
prerelease: true
- name: Store Release url
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- uses: actions/upload-artifact@v2
with:
path: ./upload_url
name: upload_url
publish:
if: contains(github.ref, 'tags/')
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu Latest GCC", artifact: "Ubuntu-2004.tar.gz",
os: ubuntu-latest
}
- {
name: "Windows Latest MSVC", artifact: "Win64.exe",
os: ubuntu-latest
}
- {
name: "macOS Latest Clang", artifact: "macOS.dmg",
os: ubuntu-latest
}
needs: release
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ matrix.config.artifact }}
path: ./
- name: Download URL
uses: actions/download-artifact@v1
with:
name: upload_url
path: ./
- id: set_upload_url
run: |
upload_url=`cat ./upload_url`
echo ::set-output name=upload_url::$upload_url
- name: Upload to Release
id: upload_to_release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ./${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact }}
asset_content_type: application/x-gtar
avogadrolibs-1.95.1/.github/workflows/build_wheels.yml 0000664 0000000 0000000 00000004167 14112012703 0023050 0 ustar 00root root 0000000 0000000 name: Build Wheels
on: [push, pull_request]
env:
# Don't build python 2.7, pypy, or 32-bit wheels
CIBW_SKIP: "cp27-* pp* *-manylinux_i686 *-win32"
# This has some of the software we need pre-installed on it
CIBW_MANYLINUX_X86_64_IMAGE: openchemistry/avogadro_manylinux2010_x86_64
# Need to do some setup before repairing the wheel on linux...
CIBW_REPAIR_WHEEL_COMMAND_LINUX: bash scripts/github-actions/repair_command_linux.sh
# Specify eigen location for windows
CIBW_ENVIRONMENT_WINDOWS: "EXTRA_CMAKE_ARGS=-DEIGEN3_INCLUDE_DIR:PATH=/c/eigen"
CIBW_TEST_REQUIRES: pytest
# Run a very simple test to make sure the wheels are working
CIBW_TEST_COMMAND: pytest {project}/scripts/github-actions/simple_test.py
# Use bash by default for the run command
defaults:
run:
shell: bash
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# For Windows, we have to use visual studio 2017, which is on windows-2016
os: [ubuntu-20.04, macos-latest, windows-2016]
steps:
- uses: actions/checkout@v2
with:
# Grab the whole history so that setuptools-scm can see the tags and
# give it a correct version even on non-tag push.
fetch-depth: 0
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'
- name: Install dependencies
run: . ./scripts/github-actions/install.sh
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
upload_pypi:
needs: build_wheels
name: Upload wheels to PyPI
runs-on: ubuntu-latest
# upload to PyPI on every tag push
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_api_token }}
avogadrolibs-1.95.1/.github/workflows/clang-format-check.yml 0000664 0000000 0000000 00000004705 14112012703 0024025 0 ustar 00root root 0000000 0000000 name: clang-format Check
on: [push, pull_request]
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- name: 'Install clang-format'
run: sudo apt-get -qq install clang-format-6.0
- uses: actions/checkout@v2
- name: Get branch name
run: |
echo "::set-env name=GITHUB_BRANCH=${GITHUB_REF##*/}"
- name: 'Run clang-format-diff'
run: |
if [ ${GITHUB_BRANCH} != "master" ]; then
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/openchemistry/avogadrolibs
git fetch origin master:master
echo `which clang-format-diff-6.0`
export MASTER_SHA=`cat .git/refs/heads/master`
echo MASTER_SHA=${MASTER_SHA}
git diff `cat .git/refs/heads/master` --name-only
DIFF=`git diff -U0 ${MASTER_SHA} -- '*.h' '*.cpp' | clang-format-diff-6.0 -p1`
if [ -z "$DIFF" ]; then
printf "clang-format-diff reports no problems"
exit 0
else
git diff -U0 ${MASTER_SHA} -- '*.h' '*.cpp' | clang-format-diff-6.0 -p1 >${{ runner.workspace }}/clang-format.diff
exit 1
fi
fi
- name: Upload patch
if: failure()
uses: actions/upload-artifact@v1
with:
path: ${{ runner.workspace }}/clang-format.diff
name: clang-format.diff
- name: Comment on diff
if: failure()
run: |
export NAME=`curl "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | jq '.artifacts[].name'`
export DL=`curl "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | jq '.artifacts[].archive_download_url'`
export URL="https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts"
echo URL=${URL}
echo NAME=${NAME}
echo DL=${DL}
curl "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts"
jq -nc "{\"body\": \"ERROR: clang-format-diff detected formatting issues. See the artifact for a patch or run clang-format on your branch.\"}" | \
curl -sL -X POST -d @- \
-H "Content-Type: application/json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments"
avogadrolibs-1.95.1/.github/workflows/clang-tidy.yml 0000664 0000000 0000000 00000007455 14112012703 0022440 0 ustar 00root root 0000000 0000000 name: Static Analysis
on:
push:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
env:
FEATURES: -DBUILD_GPL_PLUGINS=ON -DWITH_COORDGEN=OFF
BUILD_TYPE: RelWithDebInfo
CLAZY_VERSION: 1.8
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu Analysis",
os: ubuntu-20.04,
cc: "clang", cxx: "clang++",
cmake_flags: "-G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DUSE_SYSTEM_LIBXML2=ON -USE_SYSTEM_ZLIB=ON",
cpack: "",
}
steps:
- name: Install Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get -qq update
sudo apt-get -qq install ninja-build bear libeigen3-dev libboost-all-dev libglew-dev libxml2-dev qt5-default libqt5x11extras5-dev libqt5svg5-dev
- name: Checkout openchemistry
uses: actions/checkout@v2
with:
repository: openchemistry/openchemistry
submodules: recursive
- name: Checkout avogadroapp
uses: actions/checkout@v2
with:
repository: openchemistry/avogadroapp
path: avogadroapp
- name: Checkout avogadrolibs
uses: actions/checkout@v2
with:
path: avogadrolibs
- name: Grab cache files
uses: actions/cache@v2
if: runner.os != 'Windows'
with:
path: ${{ runner.workspace }}/build/thirdparty
key: ${{ matrix.config.name }}-thirdparty
- name: Configure
run: |
if [ ! -d "${{ runner.workspace }}/build" ]; then mkdir "${{ runner.workspace }}/build"; fi
cd "${{ runner.workspace }}/build"
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} cmake $GITHUB_WORKSPACE ${{env.FEATURES}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{matrix.config.cmake_flags}}
shell: bash
- name: Build
run: |
CC=${{matrix.config.cc}} CXX=${{matrix.config.cxx}} ninja
# only re-compile avogadrolibs
(cd avogadrolibs; ninja clean)
bear ninja
shell: bash
working-directory: ${{ runner.workspace }}/build
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
- name: Check C++ changes with clang-tidy
id: static_analysis
working-directory: ${{ runner.workspace }}/build
run : |
sudo apt-get -qq install clang-tidy-11
run-clang-tidy-11 -j=2 -checks='-*,performance-*,readability-*,bugprone-*,clang-analyzer-*,cppcoreguidelines-*,concurrency-*,modernize-*,portability-*,misc-*' -export-fixes=fixes.yaml
- name: Download and run Clazy
shell: bash
working-directory: ${{ runner.workspace }}/build
run : |
wget https://downloads.kdab.com/clazy/${{ env.CLAZY_VERSION }}/Clazy-x86_64-${{env.CLAZY_VERSION}}.AppImage
export CLAZY_CHECKS="level0,level1,qt6-deprecated-api-fixes,qt6-header-fixes,function-args-by-value,missing-qobject-macro"
chmod u+x ./Clazy-x86_64-${{env.CLAZY_VERSION}}.AppImage
./Clazy-x86_64-${{env.CLAZY_VERSION}}.AppImage -j 2 --standalone -export-fixes=clazy.yaml
- name: Upload
uses: actions/upload-artifact@v2
with:
path: ${{ runner.workspace }}/build/*.yaml
name: clang-tidy-fixes.yaml
- name: Run clang-tidy-pr-comments action
if: always()
uses: platisd/clang-tidy-pr-comments@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clang_tidy_fixes: ${{ runner.workspace }}/build/fixes.yaml
avogadrolibs-1.95.1/.github/workflows/misspell-fixer.yml 0000664 0000000 0000000 00000000460 14112012703 0023335 0 ustar 00root root 0000000 0000000 name: misspell-fixer
on: [push]
jobs:
spelling-check:
name: Spelling Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: misspell-fixer check for code and comments
uses: sobolevn/misspell-fixer-action@master
with:
options: '-rsvn avogadro/'
avogadrolibs-1.95.1/.github/workflows/release-drafter.yml 0000664 0000000 0000000 00000001515 14112012703 0023441 0 ustar 00root root 0000000 0000000 name: Release Drafter
# https://github.com/release-drafter/release-drafter
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
avogadrolibs-1.95.1/.github/workflows/update-i18n-templates.yml 0000664 0000000 0000000 00000001133 14112012703 0024423 0 ustar 00root root 0000000 0000000 name: update-i18n-templates
on:
schedule:
# * is a special character in YAML so you have to quote this string
# run weekly, every Sunday at 01:31
- cron: '31 1 * * 0'
jobs:
update-i18n:
name: Update translation templates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run extract-messages
run: |
sh scripts/extract-messages.sh
- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
commit-message: "Automated translation updates"
signoff: true
branch-suffix: timestamp
avogadrolibs-1.95.1/.gitignore 0000664 0000000 0000000 00000000013 14112012703 0016234 0 ustar 00root root 0000000 0000000 docs/build
avogadrolibs-1.95.1/.misspell-fixer.ignore 0000664 0000000 0000000 00000000041 14112012703 0020473 0 ustar 00root root 0000000 0000000 ^avogadro/quantumio/gamessus.cpp
avogadrolibs-1.95.1/CMakeLists.txt 0000664 0000000 0000000 00000010173 14112012703 0017014 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(AvogadroLibs)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Request C++11 standard when building Python wheels due to old compiler/glibc.
# Use C++17 otherwise, and hopefully globally once the pip infra is updated.
option(PYTHON_WHEEL_BUILD "Is this a Python wheel build?" OFF)
mark_as_advanced(PYTHON_WHEEL_BUILD)
if(PYTHON_WHEEL_BUILD)
set(CMAKE_CXX_STANDARD 11)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
# Set symbol visibility defaults for all targets.
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN True)
include(BuildType)
include(BuildLocation)
include(CompilerFlags)
include(InstallLocation)
include(DetermineVersion)
# Set up our version.
set(AvogadroLibs_VERSION_MAJOR "1")
set(AvogadroLibs_VERSION_MINOR "95")
set(AvogadroLibs_VERSION_PATCH "1")
set(AvogadroLibs_VERSION
"${AvogadroLibs_VERSION_MAJOR}.${AvogadroLibs_VERSION_MINOR}.${AvogadroLibs_VERSION_PATCH}")
find_package(Git)
determine_version(${AvogadroLibs_SOURCE_DIR} ${GIT_EXECUTABLE} "AvogadroLibs")
option(BUILD_SHARED_LIBS "Build with shared libraries" ON)
# Before any plugins are defined, and before any add_subdirectory calls:
set_property(GLOBAL PROPERTY AvogadroLibs_PLUGINS)
set_property(GLOBAL PROPERTY AvogadroLibs_STATIC_PLUGINS)
if(MSVC)
add_definitions("-D_CRT_SECURE_NO_WARNINGS" "-DNOMINMAX -D_USE_MATH_DEFINES")
endif()
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR})
option(ENABLE_TESTING "Enable testing and building the tests." OFF)
option(TEST_QTGL "Build the Qt OpenGL test application" OFF)
option(ENABLE_TRANSLATIONS "Enable building translations with Qt5 Linguist" OFF)
option(USE_OPENGL "Enable libraries that use OpenGL" ON)
option(USE_HDF5 "Enable optional HDF5 features" OFF)
option(USE_QT "Enable libraries that use Qt 5" ON)
option(USE_VTK "Enable libraries that use VTK" OFF)
option(USE_LIBARCHIVE "Enable optional Libarchive features" ON)
option(USE_LIBMSYM "Enable optional features using libmsym" ON)
option(USE_SPGLIB "Enable optional features using spglib" ON)
option(USE_MMTF "Enable optional features using mmtf" ON)
option(USE_PROTOCALL "Enable libraries that use ProtoCall" OFF)
option(USE_PYTHON "Use Python to wrap some of our API" OFF)
add_subdirectory(utilities)
add_subdirectory(thirdparty)
add_subdirectory(avogadro)
if(ENABLE_TESTING)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()
option(BUILD_DOCUMENTATION "Build project documentation" OFF)
if(BUILD_DOCUMENTATION)
add_subdirectory(docs)
endif()
if(USE_PYTHON)
add_subdirectory(python)
endif()
if(ENABLE_TRANSLATIONS)
find_package(Qt5LinguistTools)
endif()
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
install(
FILES
README.md
CONTRIBUTING.md
LICENSE
DESTINATION "${INSTALL_DOC_DIR}/avogadrolibs")
endif()
# After all add_subdirectory calls, so the list of plugins is complete:
get_property(AvogadroLibs_PLUGINS GLOBAL PROPERTY AvogadroLibs_PLUGINS)
get_property(AvogadroLibs_STATIC_PLUGINS GLOBAL
PROPERTY AvogadroLibs_STATIC_PLUGINS)
configure_file(${AvogadroLibs_SOURCE_DIR}/cmake/CTestCustom.cmake.in
${AvogadroLibs_BINARY_DIR}/CTestCustom.cmake)
configure_file("${AvogadroLibs_SOURCE_DIR}/cmake/AvogadroLibsConfig.cmake.in"
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfig.cmake" @ONLY)
configure_file("${AvogadroLibs_SOURCE_DIR}/cmake/AvogadroLibsConfigVersion.cmake.in"
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfigVersion.cmake" @ONLY)
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
install(FILES
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfig.cmake"
"${AvogadroLibs_BINARY_DIR}/AvogadroLibsConfigVersion.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindEigen3.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGLEW.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibArchive.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findlibmsym.cmake"
DESTINATION "${INSTALL_LIBRARY_DIR}/cmake/avogadrolibs")
install(EXPORT "AvogadroLibsTargets"
DESTINATION "${INSTALL_LIBRARY_DIR}/cmake/avogadrolibs")
endif()
avogadrolibs-1.95.1/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006241 14112012703 0017054 0 ustar 00root root 0000000 0000000 # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at avogadro-devel@lists.sourceforge.net. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
avogadrolibs-1.95.1/CONTRIBUTING.md 0000664 0000000 0000000 00000001576 14112012703 0016514 0 ustar 00root root 0000000 0000000 Contributing
------------
Our project uses the standard GitHub pull request process for code review
and integration. Please check our [development][Development] guide for more
details on developing and contributing to the project. The GitHub issue
tracker can be used to report bugs, make feature requests, etc.
Our [wiki][Wiki] is used to document features, flesh out designs and host other
documentation. Our API is [documented using Doxygen][Doxygen] with updated
documentation generated nightly. We have several [mailing lists][MailingLists]
to coordinate development and to provide support.
[Development]: http://wiki.openchemistry.org/Development "Development guide"
[Wiki]: http://wiki.openchemistry.org/ "Open Chemistry wiki"
[Doxygen]: http://doc.openchemistry.org/avogadrolibs/api/ "API documentation"
[MailingLists]: http://openchemistry.org/mailing-lists "Mailing Lists"
avogadrolibs-1.95.1/CTestConfig.cmake 0000664 0000000 0000000 00000000376 14112012703 0017432 0 ustar 00root root 0000000 0000000 set(CTEST_PROJECT_NAME "AvogadroLibs")
set(CTEST_NIGHTLY_START_TIME "23:59:59 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "cdash.openchemistry.org")
set(CTEST_DROP_LOCATION "/submit.php?project=AvogadroLibs")
set(CTEST_DROP_SITE_CDASH TRUE)
avogadrolibs-1.95.1/LICENSE 0000664 0000000 0000000 00000002745 14112012703 0015267 0 ustar 00root root 0000000 0000000 Copyright (c) 2011-2020, Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
avogadrolibs-1.95.1/README.md 0000664 0000000 0000000 00000011273 14112012703 0015535 0 ustar 00root root 0000000 0000000 ![Avogadro 2][Avogadro2Logo] Avogadro 2
==========
[](https://github.com/OpenChemistry/avogadrolibs/releases) [](https://github.com/OpenChemistry/avogadrolibs/blob/master/LICENSE) [](https://github.com/OpenChemistry/avogadrolibs/actions) [](http://makeapullrequest.com) [](https://github.com/OpenChemistry/avogadrolibs/graphs/contributors) [](https://opencollective.com/open-chemistry)
Introduction
------------
Avogadro is an advanced molecular editor designed for cross-platform use in
computational chemistry, molecular modeling, bioinformatics, materials science,
and related areas. It offers flexible rendering and a powerful plugin
architecture.
Core features and goals of the Avogadro project include:
* Open source distributed under the liberal 3-clause BSD license
* Cross platform with builds on Linux, Mac OS X and Windows
* Intuitive interface designed to be useful to whole community
* Fast and efficient embracing the latest technologies
* Extensible, making extensive use of a plugin architecture
* Flexible supporting a range of chemical data formats and packages
The code in this repository is a rewrite of Avogadro with source
code split across
a [libraries repository](https://github.com/openchemistry/avogadrolibs)
and an [application repository](https://github.com/openchemistry/avogadroapp).
The new code architecture provides a high-performance rendering engine, modern
code development, and significantly improved speed and stability.
Avogadro 2 is being developed as part of the [Open Chemistry][OpenChemistry]
project by an open community, and was started at [Kitware][Kitware] as
an open source community project. The Avogadro 1.x series currently has more
features, and can be found [here][Avogadro1]. We will be porting more features
to the Avogadro 2 code base, and making regular releases to get feedback from
the community.
We are actively working to finish Avogadro 2.0 in 2021.
Installing
----------
We provide nightly binaries built by GitHub actions for:
* [MacOS](https://nightly.link/OpenChemistry/avogadrolibs/workflows/build_cmake/master/macOS.dmg.zip)
* [Windows 64-bit](https://nightly.link/OpenChemistry/avogadrolibs/workflows/build_cmake/master/Win64.exe.zip)
* [Ubuntu LTS](https://nightly.link/OpenChemistry/avogadrolibs/workflows/build_cmake/master/Ubuntu2004.tar.gz.zip)
If you would like to build from source we recommend that you
follow our [building Open Chemistry][Build] guide that will take care of
building most dependencies.
Contributing
------------
Our project uses the standard GitHub pull request process for code review
and integration. Please check our [development][Development] guide for more
details on developing and contributing to the project. The GitHub issue
tracker can be used to report bugs, make feature requests, etc.
Our [wiki][Wiki] is used to document features, flesh out designs and host other
documentation. Our API is [documented using Doxygen][Doxygen] with updated
documentation generated nightly. We have several [mailing lists][MailingLists]
to coordinate development and to provide support.
Contributors Hall of Fame:
[Avogadro2Logo]: https://raw.githubusercontent.com/OpenChemistry/avogadrolibs/master/docs/avogadro2_64.png "Avogadro2"
[OpenChemistry]: http://openchemistry.org/ "Open Chemistry Project"
[OpenChemistryLogo]: https://raw.githubusercontent.com/OpenChemistry/avogadrolibs/master/docs/OpenChemistry128.png "Open Chemistry"
[Kitware]: http://kitware.com/ "Kitware, Inc."
[KitwareLogo]: http://www.kitware.com/img/small_logo_over.png "Kitware"
[Avogadro1]: http://avogadro.cc/ "Avogadro 1"
[Dashboard]: http://cdash.openchemistry.org/index.php?project=AvogadroLibs "Avogadro Dashboard"
[Build]: http://wiki.openchemistry.org/Build "Building Avogadro"
[Development]: http://wiki.openchemistry.org/Development "Development guide"
[Wiki]: http://wiki.openchemistry.org/ "Open Chemistry wiki"
[Doxygen]: http://doc.openchemistry.org/avogadrolibs/api/ "API documentation"
[MailingLists]: http://openchemistry.org/mailing-lists "Mailing Lists"
avogadrolibs-1.95.1/STYLE.md 0000664 0000000 0000000 00000013061 14112012703 0015475 0 ustar 00root root 0000000 0000000 clang-format
------------
We use [clang-format][clang-format] to keep formatting in the code base
consistent. Please run clang-format on your patches before submitting.
clang-format ships with a Python script ```clang/tools/clang-format-diff.py```
that can be used to reformat patches. For example the following command will
reformat all the lines in the latest commit
```shell
git diff -U0 HEAD^ | clang-format-diff.py -i -p1
```
clang-format also provides [git-clang-format][git-clang-format], a script that
more closely integrates with git. If you add this script to your path you can
using the following command to reformat all the lines in the latest commit.
```shell
git clang-format HEAD~1
```
### clang-format-diff locations by platform
The exact location of the Python script varies by platform/distro. The table
below provides the location on some common platform/distro's
| Platform/Distro. | Location |
| ---------------- |:-------------------------------------:|
| Arch Linux | /usr/share/clang/clang-format-diff.py |
| Ubuntu | /usr/bin/clang-format-diff-3.8 |
The script can also be downloaded [here][clang-format-diff].
Code style
----------
This project is developed primarily in C++ and Python. Please follow these code
style guidelines when contributing code to our project.
* Alphabetize includes
* Use #include "xxx" for local includes, #include \ for external includes.
* Do not add comment separators before function definitions.
* Split long lines, when reasonable, to avoid going over 80 characters per line.
* Add a space after the commas in parameter lists, e.g.,
function(a, b, c), not function(a,b,c)
* Add spaces between operators, e.g. 5 - 2, not 5-2.
* For class names, use CamelCase, starting their names with an upper-case
letter.
* For local variables and function names, use camelCase, starting names with a
lower-case letter.
* For member variables, prefix them with m\_, i.e. m\_camelCase, starting the
name with a lower-case letter.
* For comments, add a space between // and the beginning of the comment, e.g.,
* // A comment
* \# Python comment
* Use 2 spaces when indenting C++ code, 4 spaces for Python code.
* Do not indent inside namespaces, e.g.,
namespace Avogadro {
namespace Core {
void foo();
}
}
* Curly braces marking the start and end of a code block should be on
separate lines and aligned vertically with the statement preceding
the block, e.g.,
if (condition) {
statement;
}
for (int i = 0; i < n; ++i) {
statement;
}
* Assume that C++11 features are available, and prefer them over legacy macros,
defines, etc. A few examples follow, but are not exhaustive.
* Use override to specify member overrides in derived classes.
* Set default values of member variables directly in definitions.
* Use nullptr instead of NULL.
### C++ Features
* Don't use exceptions
* Prefer solutions from the Qt library over others in Qt dependent code
* Minimize dependencies on third party libraries, think carefully before adding
more
* Use templates where they make sense
### Including Headers
* In public headers, always use this form to include project headers:
#include
* Prefer declaration of types in public headers over including headers for the
type
namespace Avogadro {
class MyClass;
}
* In source files include specialized headers first, then dependency headers,
then generic headers
#include "myapiheader.h" // Our header
#include // Avogadro header from a different module
#include // Qt header
#include // STL
* If you need to include the export header for the module do it as the first include
#include "avogadrorenderingexport.h"
* Private headers are denoted by _p.h endings, and should not be included in
public headers
* Use the Qt module and camel-cased header
* Never include Qt module headers such as QtGui, instead include the header for
the class being used
#include // WRONG (module header)!
#include // Correct
### Namespaces
* Avogadro uses nested namespaces
* Everything is inside the Avogadro namespace
* Code in the core module is in the Avogadro::Core namespace
* Don't overspecify, i.e. code in the Avogadro namespace doesn't need to use
Avogadro::
* Qt signals and slots are one exception where MOC often needs a little help
* Never use using inside a public header
* Only pull in specific symbols in source files, i.e. using
Avogadro::Core::Molecule;
### Casting
* Avoid C-style casts, prefer C++ (static_cast, dynamic_cast, const_cast,
reinterpret_cast)
* For Qt classes, and Qt derived classes prefer qobject_cast over dynamic_cast
### Aesthetics
* Prefer enums to define constants over static const int or defines
* Prefer verbose argument names in headers
* Most IDEs show the argument names in their autocompletion
* It looks better in the generated documentation
* Poor style making people guess what an argument is for
* Avoid abbreviations, as they are often ambiguous and we can afford the extra
bytes
[clang-format]: http://llvm.org/releases/3.8.0/tools/clang/docs/ClangFormatStyleOptions.html
[git-clang-format]: https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
[flake8]: https://pypi.python.org/pypi/flake8
[clang-format-diff]: https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py
avogadrolibs-1.95.1/avogadro/ 0000775 0000000 0000000 00000000000 14112012703 0016054 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/avogadro/CMakeLists.txt 0000664 0000000 0000000 00000004655 14112012703 0020626 0 ustar 00root root 0000000 0000000 include(GenerateExportHeader)
function(avogadro_add_library name)
add_library(${name} ${ARGN})
# Use the new AUTOMOC support for Qt libraries (CMake 2.8.6).
if(${name} MATCHES "^AvogadroQt")
set_target_properties(${name} PROPERTIES AUTOMOC TRUE)
endif()
if(BUILD_SHARED_LIBS)
set_target_properties(${name} PROPERTIES VERSION "${AvogadroLibs_VERSION_MAJOR}.${AvogadroLibs_VERSION_MINOR}.${AvogadroLibs_VERSION_PATCH}"
SOVERSION ${AvogadroLibs_VERSION_MAJOR})
endif()
string(TOLOWER ${name} lowerName)
# Generate the necessary export headers.
generate_export_header(${name} EXPORT_FILE_NAME ${lowerName}export.h)
list(APPEND HEADERS "${CMAKE_CURRENT_BINARY_DIR}/${lowerName}export.h")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Now install everything.
string(REGEX REPLACE "^avogadro" "" module ${lowerName})
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
install(FILES ${HEADERS}
DESTINATION "${INSTALL_INCLUDE_DIR}/avogadro/${module}")
else()
# For MACOSX
set_target_properties(${name} PROPERTIES INSTALL_NAME_DIR "@rpath")
set(INSTALL_RUNTIME_DIR avogadro)
set(INSTALL_LIBRARY_DIR avogadro)
set(INSTALL_ARCHIVE_DIR avogadro)
endif()
install(TARGETS ${name}
EXPORT "AvogadroLibsTargets"
RUNTIME DESTINATION "${INSTALL_RUNTIME_DIR}"
LIBRARY DESTINATION "${INSTALL_LIBRARY_DIR}"
ARCHIVE DESTINATION "${INSTALL_ARCHIVE_DIR}")
endfunction()
add_subdirectory(core)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/core)
add_subdirectory(io)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/io)
add_subdirectory(quantumio)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/quantumio)
# SKBUILD is set for binary wheel
if (NOT SKBUILD)
add_subdirectory(command)
endif()
if(USE_OPENGL)
add_subdirectory(rendering)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/rendering)
endif()
if(USE_QT)
add_subdirectory(qtgui)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/qtgui)
if(USE_OPENGL)
add_subdirectory(qtopengl)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/qtopengl)
endif()
# Add unconditionally as this talks to MoleQueue, but doesn't depend on it.
add_subdirectory(molequeue)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/molequeue)
if(USE_VTK)
add_subdirectory(vtk)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/vtk)
endif()
add_subdirectory(qtplugins)
endif()
if(USE_PROTOCALL)
add_subdirectory(protocall)
endif()
avogadrolibs-1.95.1/avogadro/command/ 0000775 0000000 0000000 00000000000 14112012703 0017472 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/avogadro/command/CMakeLists.txt 0000664 0000000 0000000 00000000532 14112012703 0022232 0 ustar 00root root 0000000 0000000 find_package(Eigen3 REQUIRED)
include_directories(SYSTEM "${EIGEN3_INCLUDE_DIR}")
add_executable(avocjsontocml cjsontocml.cpp)
target_link_libraries(avocjsontocml AvogadroIO)
add_executable(avobabel avobabel.cpp)
target_link_libraries(avobabel AvogadroIO)
add_executable(qube qube.cpp)
target_link_libraries(qube AvogadroQuantumIO AvogadroIO)
avogadrolibs-1.95.1/avogadro/command/avobabel.cpp 0000664 0000000 0000000 00000006043 14112012703 0021754 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2014 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#include
#include
#include
#include
#include
#include
using Avogadro::Io::FileFormatManager;
using Avogadro::Core::Molecule;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::ostringstream;
void printHelp();
int main(int argc, char* argv[])
{
// Process the command line arguments, see what has been requested.
string inFormat;
string outFormat;
string inFile;
string outFile;
for (int i = 1; i < argc; ++i) {
string current(argv[i]);
if (current == "--help" || current == "-h") {
printHelp();
return 0;
} else if (current == "--version" || current == "-v") {
cout << "Version: " << Avogadro::version() << endl;
return 0;
} else if (current == "-i" && i + 1 < argc) {
inFormat = argv[++i];
cout << "input format " << inFormat << endl;
} else if (current == "-o" && i + 1 < argc) {
outFormat = argv[++i];
cout << "output format " << outFormat << endl;
} else if (inFile.empty()) {
inFile = argv[i];
} else if (outFile.empty()) {
outFile = argv[i];
}
}
// Now read/write the molecule, if possible. Otherwise output errors.
FileFormatManager& mgr = FileFormatManager::instance();
Molecule mol;
if (!inFile.empty()) {
if (!mgr.readFile(mol, inFile, inFormat)) {
cout << "Failed to read " << inFile << " (" << inFormat << ")" << endl;
return 1;
}
} else if (!inFormat.empty()) {
ostringstream inFileString;
string line;
while (getline(cin, line))
inFileString << line;
if (!inFileString.str().empty()) {
if (!mgr.readString(mol, inFileString.str(), inFormat)) {
cout << "Failed to read input stream: " << inFileString.str() << endl;
return 1;
}
}
} else {
cout << "Error, no input file or stream supplied with format." << endl;
}
if (!outFile.empty()) {
if (!mgr.writeFile(mol, outFile, outFormat)) {
cout << "Failed to write " << outFile << " (" << outFormat << ")" << endl;
return 1;
}
} else {
if (outFormat.empty())
outFormat = "cjson";
string out;
mgr.writeString(mol, out, outFormat);
cout << out << endl;
}
return 0;
}
void printHelp()
{
cout << "Usage: avobabel [-i ] [-o ] "
"\n"
<< endl;
}
avogadrolibs-1.95.1/avogadro/command/cjsontocml.cpp 0000664 0000000 0000000 00000002313 14112012703 0022350 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2013-2014 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#include "avogadro/core/molecule.h"
#include "avogadro/io/fileformatmanager.h"
#include
#include
#include
using Avogadro::Io::FileFormatManager;
using Avogadro::Core::Molecule;
using std::cin;
using std::cout;
using std::string;
using std::ostringstream;
int main()
{
FileFormatManager& mgr = FileFormatManager::instance();
Molecule mol;
ostringstream cjson;
string line;
while (getline(cin, line)) {
cjson << line;
}
mgr.readString(mol, cjson.str(), "cjson");
string cml;
mgr.writeString(mol, cml, "cml");
cout << cml;
}
avogadrolibs-1.95.1/avogadro/command/qube.cpp 0000664 0000000 0000000 00000012676 14112012703 0021146 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2014 Albert DeFusco University of Pittsburgh
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using Avogadro::Io::FileFormatManager;
using Avogadro::Core::Cube;
using Avogadro::Core::Molecule;
using Avogadro::Core::GaussianSetTools;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::ostringstream;
using Eigen::Vector3d;
using Eigen::Vector3i;
static const double BOHR_TO_ANGSTROM = 0.529177249;
static const double ANGSTROM_TO_BOHR = 1.0 / BOHR_TO_ANGSTROM;
void printHelp();
int main(int argc, char* argv[])
{
// Register our quantum file format.
FileFormatManager& mgr = FileFormatManager::instance();
mgr.registerFormat(new Avogadro::QuantumIO::GAMESSUSOutput);
mgr.registerFormat(new Avogadro::QuantumIO::GaussianFchk);
mgr.registerFormat(new Avogadro::QuantumIO::MoldenFile);
mgr.registerFormat(new Avogadro::QuantumIO::MopacAux);
// Process the command line arguments, see what has been requested.
string inFormat;
int orbitalNumber = 0;
string inFile;
bool density = false;
for (int i = 1; i < argc; ++i) {
string current(argv[i]);
if (current == "--help" || current == "-h") {
printHelp();
return 0;
} else if (current == "--version" || current == "-v") {
cout << "Version: " << Avogadro::version() << endl;
return 0;
} else if (current == "-i" && i + 1 < argc) {
inFormat = argv[++i];
cout << "input format " << inFormat << endl;
} else if (current == "-orb" && i + 1 < argc) {
orbitalNumber = atoi(argv[++i]);
// cout << "plot orbital " << orbitalNumber << endl;
} else if (current == "-dens" && i < argc) {
density = true;
} else if (inFile.empty()) {
inFile = argv[i];
}
}
// Now read/write the molecule, if possible. Otherwise output errors.
Molecule mol;
if (!inFile.empty()) {
if (!mgr.readFile(mol, inFile, inFormat)) {
cout << "Failed to read " << inFile << " (" << inFormat << ")" << endl;
return 1;
}
} else if (!inFormat.empty()) {
ostringstream inFileString;
string line;
while (getline(cin, line))
inFileString << line;
if (!inFileString.str().empty()) {
if (!mgr.readString(mol, inFileString.str(), inFormat)) {
cout << "Failed to read input stream: " << inFileString.str() << endl;
return 1;
}
}
} else {
cout << "Error, no input file or stream supplied with format." << endl;
}
if ((orbitalNumber > 0) && density) {
cout << "Error, choose either density or a single orbital, not both."
<< endl;
return 1;
}
// cube header
cout << "Avogadro generated cube" << endl;
if (orbitalNumber > 0)
cout << "Orbital " << orbitalNumber << endl;
else
cout << "Electron Density" << endl;
// set box dimensions in Bohr
Vector3d min = Vector3d(-10.0, -10.0, -10.0);
Vector3d max = Vector3d(10.0, 10.0, 10.0);
Vector3i points = Vector3i(61, 61, 61);
Cube* m_qube = new Cube;
m_qube->setLimits(min * BOHR_TO_ANGSTROM, max * BOHR_TO_ANGSTROM, points);
min = m_qube->position(0) * ANGSTROM_TO_BOHR;
Vector3d spacing = m_qube->spacing() * ANGSTROM_TO_BOHR;
int nat = mol.atomCount();
printf("%4d %11.6f %11.6f %11.6f\n", nat, min.x(), min.y(), min.z());
printf("%4d %11.6f %11.6f %11.6f\n", points.x(), spacing.x(), 0.0, 0.0);
printf("%4d %11.6f %11.6f %11.6f\n", points.y(), 0.0, spacing.y(), .0);
printf("%4d %11.6f %11.6f %11.6f\n", points.z(), 0.0, 0.0, spacing.z());
// atoms
for (int iatom = 0; iatom < nat; iatom++) {
printf("%4d %11.6f %11.6f %11.6f %11.6f\n", mol.atomicNumber(iatom), 0.0,
mol.atomPosition3d(iatom).x() * ANGSTROM_TO_BOHR,
mol.atomPosition3d(iatom).y() * ANGSTROM_TO_BOHR,
mol.atomPosition3d(iatom).z() * ANGSTROM_TO_BOHR);
}
if (orbitalNumber > 0)
cout << "1 " << orbitalNumber << endl;
GaussianSetTools* m_tools = new GaussianSetTools(&mol);
// print the qube values
int linecount = 0;
for (unsigned int i = 0; i < m_qube->data()->size(); i++) {
if (i % points.z() == 0 && i > 0) {
linecount = 0;
printf("\n");
}
double value =
m_tools->calculateMolecularOrbital(m_qube->position(i), orbitalNumber);
printf("%13.5E", value);
// line wrapping
linecount++;
if (linecount % 6 == 0 && i > 0)
printf("\n");
else
printf(" ");
}
printf("\n");
return 0;
}
void printHelp()
{
cout << "Usage: qube [-i ] [-dens] [-orb ] [-v / --version] \n"
<< endl;
}
avogadrolibs-1.95.1/avogadro/core/ 0000775 0000000 0000000 00000000000 14112012703 0017004 5 ustar 00root root 0000000 0000000 avogadrolibs-1.95.1/avogadro/core/CMakeLists.txt 0000664 0000000 0000000 00000004262 14112012703 0021550 0 ustar 00root root 0000000 0000000 find_package(Eigen3 REQUIRED)
# Add as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})
if(USE_SPGLIB)
find_package(Spglib REQUIRED)
include_directories(SYSTEM ${SPGLIB_INCLUDE_DIR})
endif()
# configure the version header
configure_file("${PROJECT_SOURCE_DIR}/cmake/version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.h")
set(HEADERS
angletools.h
angleiterator.h
array.h
atom.h
atomtyper.h
atomtyper-inline.h
avogadrocore.h
basisset.h
connectedgroup.h
bond.h
color3f.h
coordinateset.h
coordinateblockgenerator.h
crystaltools.h
cube.h
dihedraliterator.h
elements.h
gaussianset.h
gaussiansettools.h
graph.h
layer.h
layermanager.h
matrix.h
mesh.h
molecule.h
mutex.h
nameatomtyper.h
residue.h
ringperceiver.h
secondarystructure.h
slaterset.h
slatersettools.h
spacegroups.h
symbolatomtyper.h
types.h
unitcell.h
utilities.h
variant.h
variant-inline.h
variantmap.h
vector.h
"${CMAKE_CURRENT_BINARY_DIR}/version.h"
)
set(SOURCES
angleiterator.cpp
connectedgroup.cpp
coordinateblockgenerator.cpp
crystaltools.cpp
cube.cpp
elements.cpp
dihedraliterator.cpp
gaussianset.cpp
gaussiansettools.cpp
graph.cpp
layer.cpp
layermanager.cpp
mesh.cpp
mdlvalence_p.h
molecule.cpp
mutex.cpp
nameatomtyper.cpp
residue.cpp
ringperceiver.cpp
secondarystructure.cpp
slaterset.cpp
slatersettools.cpp
spacegroups.cpp
symbolatomtyper.cpp
unitcell.cpp
variantmap.cpp
version.cpp
)
# We currently build core without shared_mutex for Python wheels.
if(NOT PYTHON_WHEEL_BUILD)
list(APPEND HEADERS sharedmutex.h)
list(APPEND SOURCES sharedmutex.cpp)
endif()
if(USE_SPGLIB)
list(APPEND HEADERS avospglib.h)
list(APPEND SOURCES avospglib.cpp)
endif()
# The std::shared_mutex class needs pthreads on Linux.
if(UNIX AND NOT APPLE AND NOT PYTHON_WHEEL_BUILD)
find_package(Threads)
set(EXTRA_LINK_LIB ${CMAKE_THREAD_LIBS_INIT})
else()
set(EXTRA_LINK_LIB "")
endif()
avogadro_add_library(AvogadroCore ${HEADERS} ${SOURCES})
target_link_libraries(AvogadroCore
PRIVATE ${SPGLIB_LIBRARY} ${EXTRA_LINK_LIB})
avogadrolibs-1.95.1/avogadro/core/angleiterator.cpp 0000664 0000000 0000000 00000004331 14112012703 0022351 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/
#include "angleiterator.h"
#include
#include
#include
namespace Avogadro {
namespace Core {
using namespace std;
AngleIterator::AngleIterator(const Molecule* mol)
: m_current(0, 0, 0), m_mol(mol)
{}
Angle AngleIterator::begin()
{
return ++(*this);
}
Angle AngleIterator::operator++()
{
if (m_mol == nullptr)
return make_tuple(MaxIndex, MaxIndex, MaxIndex);
Index a, b, c;
std::tie(a, b, c) = m_current;
Graph graph = m_mol->graph();
Index count = m_mol->atomCount();
// true if we have a valid current state
// (i.e. false at the start since a == b == c)
bool valid = (b != a);
do { // vertex
do { // find good edges
if (valid) {
// we have a valid current angle, try to find a new edge
for (const auto maybeC : graph.neighbors(b)) {
if (maybeC != a
&& (!valid || maybeC > c)) {
m_current = make_tuple(a, b, maybeC);
return m_current;
}
} // end "c" loop
valid = false; // we couldn't find a "c", so find a new "a"
} // end if()
// can we find a new edge?
for (const auto maybeA : graph.neighbors(b)) {
if (maybeA > a && maybeA != c) {
a = maybeA;
c = a;
valid = true;
break;
}
} // end "a" loop
// if we don't have a valid "a", move out to find a new "b"
} while (valid);
while(!valid && b + 1 < count) {
++b; // try going to the next atom
const auto neighbors = graph.neighbors(b);
if (neighbors.size() < 2)
continue;
a = neighbors[0];
c = neighbors[0]; // we'll move to the next one in the loop
valid = true;
}
} while (valid && b < count);
// can't find anything
return make_tuple(MaxIndex, MaxIndex, MaxIndex);
} // end ++ operator
} // namespace Core
} // namespace Avogadro
avogadrolibs-1.95.1/avogadro/core/angleiterator.h 0000664 0000000 0000000 00000002111 14112012703 0022010 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/
#ifndef AVOGADRO_CORE_ANGLEITERATOR_H
#define AVOGADRO_CORE_ANGLEITERATOR_H
#include "avogadrocore.h"
#include
#include
namespace Avogadro {
namespace Core {
class Molecule;
typedef std::tuple Angle;
class AVOGADROCORE_EXPORT AngleIterator
{
public:
/**
* Constructor.
*/
AngleIterator(const Molecule *mol);
~AngleIterator() {}
Angle* operator*() {
return &m_current;
}
Angle begin();
Angle end() const {
return std::make_tuple(MaxIndex, MaxIndex, MaxIndex);
}
Angle operator++();
bool operator!=(const AngleIterator& other ) {
return m_current != other.m_current;
}
private:
Angle m_current;
const Molecule* m_mol;
};
} // namespace Core
} // namespace Avogadro
#endif // AVOGADRO_CORE_ANGLEITERATOR_H
avogadrolibs-1.95.1/avogadro/core/angletools.h 0000664 0000000 0000000 00000003303 14112012703 0021323 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/
#ifndef AVOGADRO_CORE_ANGLETOOLS_H
#define AVOGADRO_CORE_ANGLETOOLS_H
#include
#include
namespace Avogadro {
inline Real bondAngle(const Vector3& b0, const Vector3& b1) {
// standard formula, e.g.
// https://scicomp.stackexchange.com/q/27689/14517
// Since we're using bonds, v. small angles are okay
// only problem is if bond lengths are v. v. small
// but that's unlikely in practice
const Real dot = -1.0*b0.dot(b1);
const Real norms = b0.norm() * b1.norm();
return std::acos(dot / norms) * RAD_TO_DEG_D;
}
inline Real dihedralAngle(const Vector3& b0, const Vector3& b1, const Vector3& b2)
{
// See https://stackoverflow.com/a/34245697/131896
// Thanks to @Praxeolitic
const Vector3 n0 = -1.0*b0;
const Vector3 n1 = b1.normalized();
const Vector3 v = n0 - n0.dot(n1)*n1;
const Vector3 w = b2 - b2.dot(n1)*n1;
const Real x(v.dot(w));
const Real y(w.dot(b1.cross(v)));
return std::atan2(y, x) * RAD_TO_DEG_D;
}
inline Real calcAngle(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) {
Vector3 v12 = v1 - v2;
Vector3 v23 = v2 - v3;
return bondAngle(v12, v23);
}
inline Real calcDihedral(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &v4) {
Vector3 v12 = v1 - v2;
Vector3 v23 = v2 - v3;
Vector3 v34 = v3 - v4;
return dihedralAngle(v12, v23, v34);
}
} // end Avogadro namespace
#endif // AVOGADRO_CORE_ANGLETOOLS_H
avogadrolibs-1.95.1/avogadro/core/array.h 0000664 0000000 0000000 00000023150 14112012703 0020274 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/
#ifndef AVOGADRO_CORE_ARRAY_H
#define AVOGADRO_CORE_ARRAY_H
#include "avogadrocore.h"
#include
#include
namespace Avogadro {
namespace Core {
using std::size_t;
namespace internal {
template
class ArrayRefContainer
{
public:
typedef T ValueType;
typedef std::vector Parent; // The parent container for iterators etc
// STL compatibility, forward typedefs from std::vector:
typedef typename Parent::value_type value_type;
typedef typename Parent::allocator_type allocator_type;
typedef typename Parent::reference reference;
typedef typename Parent::const_reference const_reference;
typedef typename Parent::pointer pointer;
typedef typename Parent::const_pointer const_pointer;
typedef typename Parent::iterator iterator;
typedef typename Parent::const_iterator const_iterator;
typedef typename Parent::reverse_iterator reverse_iterator;
typedef typename Parent::const_reverse_iterator const_reverse_iterator;
typedef typename Parent::difference_type difference_type;
typedef typename Parent::size_type size_type;
ArrayRefContainer() : m_ref(1), data() {}
explicit ArrayRefContainer(const size_t n,
const ValueType& value = ValueType())
: m_ref(1), data(n, value)
{}
ArrayRefContainer(const ArrayRefContainer& other) : m_ref(1), data(other.data)
{}
template
ArrayRefContainer(InputIterator first, InputIterator last)
: m_ref(1), data(first, last)
{}
// Increment the reference count.
void reref() { ++m_ref; }
// Decrement the reference count, return true unless the reference count has
// dropped to zero. When it returns false, this object should be deleted.
bool deref()
{
if (m_ref)
--m_ref;
return m_ref > 0;
}
unsigned int ref() const { return m_ref; }
// Reference count
unsigned int m_ref;
// Container for our data
std::vector data;
};
} // namespace internal
/**
* @class Array array.h
* @brief Base class for array containers.
*
* This templated class gives us a container with copy-on-write semantics,
* allowing for functions to effectively share data without exposing access or
* copying large amounts of data until the container is changed.
*
* All const functions can be called without copying any data, but a call to a
* non-const function will trigger a detach call. This is a no-op when the
* reference count is 1, and will perform a deep copy when the reference count
* is greater than 1.
*/
template
class Array
{
public:
typedef internal::ArrayRefContainer Container;
public:
typedef T ValueType;
/** Typedefs for STL compatibility @{ */
typedef typename Container::value_type value_type;
typedef typename Container::allocator_type allocator_type;
typedef typename Container::reference reference;
typedef typename Container::const_reference const_reference;
typedef typename Container::pointer pointer;
typedef typename Container::const_pointer const_pointer;
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;
typedef typename Container::reverse_iterator reverse_iterator;
typedef typename Container::const_reverse_iterator const_reverse_iterator;
typedef typename Container::difference_type difference_type;
typedef typename Container::size_type size_type;
/** @} */
/** Constructors for new containers. */
Array() : d(new Container()) {}
explicit Array(const size_t n, const ValueType& value = ValueType())
: d(new Container(n, value))
{}
template
Array(InputIterator first, InputIterator last) : d(new Container(first, last))
{}
/** Copy constructor, note the copy made of the internal data of other. */
Array(const Array& other)
{
other.d->reref();
d = other.d;
}
~Array();
/**
* Explicitly detach from any other implicitly shared containers. This is not
* normally necessary, but can be useful when you want to ensure you have a
* copy of all data.
*/
void detachWithCopy();
/**
* Explicitly detach from any other implicitly shared containers. This
* version does not copy the data.
*/
void detach();
/** Retrieve a pointer to the underlying data. */
T* data()
{
detachWithCopy();
return d->data.data();
}
const T* data() const { return d->data.data(); }
const T* constData() const { return d->data.data(); }
size_t size() const { return d->data.size(); }
size_t max_size() const { return d->data.max_size(); }
bool empty() const { return d->data.empty(); }
size_t capacity() const { return d->data.capacity(); }
void reserve(const size_t& sz)
{
detachWithCopy();
d->data.reserve(sz);
}
void resize(const size_t& sz, const ValueType& t = ValueType())
{
detachWithCopy();
d->data.resize(sz, t);
}
void clear()
{
detach();
d->data.clear();
}
const_iterator begin() const { return d->data.begin(); }
const_iterator end() const { return d->data.end(); }
iterator begin()
{
detachWithCopy();
return d->data.begin();
}
iterator end()
{
detachWithCopy();
return d->data.end();
}
const_reverse_iterator rbegin() const { return d->data.rbegin(); }
const_reverse_iterator rend() const { return d->data.rend(); }
reverse_iterator rbegin()
{
detachWithCopy();
return d->data.rbegin();
}
reverse_iterator rend()
{
detachWithCopy();
return d->data.rend();
}
reference front()
{
detachWithCopy();
return d->data.front();
}
const_reference front() const { return d->data.front(); }
reference back()
{
detachWithCopy();
return d->data.back();
}
const_reference back() const { return d->data.back(); }
template
void assign(InputIterator first, InputIterator last)
{
detachWithCopy();
d->data.assign(first, last);
}
void assign(size_type n, const value_type& val)
{
detachWithCopy();
d->data.assign(n, val);
}
void push_back(const ValueType& v)
{
detachWithCopy();
d->data.push_back(v);
}
void pop_back()
{
detachWithCopy();
d->data.pop_back();
}
iterator insert(iterator position, const value_type& val)
{
detachWithCopy();
return d->data.insert(position, val);
}
void insert(iterator position, size_type n, const value_type& val)
{
detachWithCopy();
d->data.insert(position, n, val);
}
template
void insert(iterator position, InputIterator first, InputIterator last)
{
detachWithCopy();
d->data.insert(position, first, last);
}
iterator erase(iterator position)
{
detachWithCopy();
return d->data.erase(position);
}
iterator erase(iterator first, iterator last)
{
detachWithCopy();
return d->data.erase(first, last);
}
const ValueType& operator[](const std::size_t& idx) const
{
return d->data[idx];
}
ValueType& operator[](const std::size_t& idx)
{
detachWithCopy();
return d->data[idx];
}
ValueType at(const std::size_t& idx) const { return d->data.at(idx); }
template
Array& operator=(const std::vector& v)
{
detach();
d->data = v;
return *this;
}
template
Array& operator=(const Array& v)
{
detach();
d->data = v.d->data;
return *this;
}
Array& operator=(const Array& v)
{
if (this != &v) {
detach();
d->data = v.d->data;
}
return *this;
}
void swap(Array& other)
{
using std::swap;
swap(d, other.d);
}
/**
* @param index array position to delete
* if the index is valid swap it with the last position and pop back.
* This function does not preserve the elements order.
*/
void swapAndPop(Index index)
{
if (index >= d->data.size()) {
return;
}
if (index != d->data.size() - 1) {
d->data[index] = d->data.back();
}
d->data.pop_back();
}
protected:
Container* d;
};
template
inline Array::~Array()
{
if (d && !d->deref())
delete d;
}
template
inline void Array::detachWithCopy()
{
if (d && d->ref() != 1) {
Container* o = new Container(*d);
d->deref();
d = o;
}
}
template
inline void Array::detach()
{
if (d && d->ref() != 1) {
d->deref();
d = new Container;
}
}
template
inline bool operator==(const Array& lhs, const Array& rhs)
{
return lhs.size() == rhs.size() &&
std::equal(lhs.begin(), lhs.end(), rhs.begin());
}
template
inline bool operator!=(const Array& lhs, const Array& rhs)
{
return !(lhs == rhs);
}
template
inline bool operator<(const Array& lhs, const Array& rhs)
{
return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(),
rhs.end());
}
template
inline bool operator>(const Array& lhs, const Array& rhs)
{
return rhs < lhs;
}
template
inline bool operator<=(const Array& lhs, const Array& rhs)
{
return !(rhs < lhs);
}
template
inline bool operator>=(const Array& lhs, const Array& rhs)
{
return !(lhs < rhs);
}
template
inline void swap(Array& lhs, Array& rhs)
{
lhs.swap(rhs);
}
} // namespace Core
} // namespace Avogadro
#endif // AVOGADRO_CORE_ARRAY_H
avogadrolibs-1.95.1/avogadro/core/atom.h 0000664 0000000 0000000 00000022350 14112012703 0020117 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2011-2012 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_ATOM_H
#define AVOGADRO_CORE_ATOM_H
#include "avogadrocore.h"
#include "vector.h"
namespace Avogadro {
namespace Core {
enum AtomHybridization
{
PerceivedOctaheadral = -6,
PerceivedTrigonalBipyramidal = -5,
PerceivedSquarePlanar = -4,
PerceivedSP3 = -3,
PerceivedSP2 = -2,
PerceivedSP = -1,
HybridizationUnknown = 0,
SP = 1,
SP2 = 2,
SP3 = 3,
SquarePlanar = 4,
TrigonalBipyramidal = 5,
Octahedral = 6
};
enum AtomicNumber : unsigned char
{
Hydrogen = 1,
Carbon = 6,
Nitrogen = 7,
Oxygen = 8
};
/**
* @class Atom atom.h
* The atom class represents an atom in a molecule.
* To use the appropriate atom implementation for a specific molecule
* implementation, use the [MoleculeClass]::AtomType typedef.
*/
template
class AtomTemplate
{
public:
typedef Molecule_T MoleculeType;
/** Creates a new, invalid atom object. */
AtomTemplate();
/**
* Creates a new atom object representing the atom at index @p i in molecule
* @p m.
*/
AtomTemplate(MoleculeType* m, Index i);
/**
* @return True if @a this and @a other share the same index and molecule.
*/
bool operator==(const AtomTemplate& other) const;
/**
* @return True if @a this and @a other do not share the same index or
* molecule.
*/
bool operator!=(const AtomTemplate& other) const;
/**
* Prefix increment operator. Increment this Atom's index by 1 and return a
* self-reference. Check isValid() before calling any other methods.
*/
AtomTemplate& operator++();
/**
* Postfix increment operator. Increment this Atom's index by 1 and return a
* copy of the current Atom. Check isValid() before calling any other methods.
*/
AtomTemplate operator++(int);
/**
* Prefix decrement operator. Decrement this Atom's index by 1 and return a
* self-reference. Check isValid() before calling any other methods.
*/
AtomTemplate& operator--();
/**
* Postfix decrement operator. Decrement this Atom's index by 1 and return a
* copy of the current Atom. Check isValid() before calling any other methods.
*/
AtomTemplate operator--(int);
/**
* @return True if the molecule is set and the index is less than the number
* of atoms.
*/
bool isValid() const;
/**
* @return The molecule that contains this Atom.
*/
MoleculeType* molecule() const;
/**
* @return The index of this atom in molecule().
*/
Index index() const;
/**
* The proton count of the atom.
* @{
*/
void setAtomicNumber(unsigned char num);
unsigned char atomicNumber() const;
/** @} */
/**
* The 2D position of this atom.
* @note Not all molecule types support 2D positions. If the current
* MoleculeType class does not, calling this method will result in a
* compilation error.
* @{
*/
void setPosition2d(const Vector2& pos);
Vector2 position2d() const;
/** @} */
/**
* The 3D position of this atom.
* @{
*/
void setPosition3d(const Vector3& pos);
Vector3 position3d() const;
/** @} */
/**
* The hybridization / coordination of this atom
* @{
*/
void setHybridization(AtomHybridization hyb);
AtomHybridization hybridization() const;
/** @} */
/**
* The formal charge of this atom
* @{
*/
void setFormalCharge(signed char charge);
signed char formalCharge() const;
/** @} */
/**
* The color of this atom
* @{
*/
void setColor(Vector3ub color);
Vector3ub color() const;
/** @} */
/**
* The layer of this atom
* @{
*/
void setLayer(size_t layer);
size_t layer() const;
/** @} */
/**
* Is the atom selected.
* {@
*/
void setSelected(bool selected);
bool selected() const;
/** @} */
/**
* The force on this atom.
* {@
*/
void setForceVector(const Vector3& force);
Vector3 forceVector() const;
void setLabel(const std::string& label);
std::string label() const;
/** @} */
private:
MoleculeType* m_molecule;
Index m_index;
};
template
AtomTemplate::AtomTemplate()
: m_molecule(nullptr), m_index(MaxIndex)
{}
template
AtomTemplate::AtomTemplate(MoleculeType* m, Index i)
: m_molecule(m), m_index(i)
{}
template
bool AtomTemplate::operator==(
const AtomTemplate& other) const
{
return m_molecule == other.m_molecule && m_index == other.m_index;
}
template
bool AtomTemplate::operator!=(
const AtomTemplate& other) const
{
return m_molecule != other.m_molecule || m_index != other.m_index;
}
template
AtomTemplate& AtomTemplate::operator++()
{
++m_index;
return *this;
}
template
AtomTemplate AtomTemplate::operator++(int)
{
AtomTemplate result(m_molecule, m_index++);
return result;
}
template
AtomTemplate& AtomTemplate::operator--()
{
--m_index;
return *this;
}
template
AtomTemplate AtomTemplate::operator--(int)
{
AtomTemplate result(m_molecule, m_index--);
return result;
}
template
bool AtomTemplate::isValid() const
{
return m_molecule && m_index < m_molecule->atomCount();
}
template
typename AtomTemplate::MoleculeType*
AtomTemplate::molecule() const
{
return m_molecule;
}
template
Index AtomTemplate::index() const
{
return m_index;
}
template
void AtomTemplate::setAtomicNumber(unsigned char num)
{
m_molecule->setAtomicNumber(m_index, num);
}
template
unsigned char AtomTemplate::atomicNumber() const
{
return m_molecule->atomicNumber(m_index);
}
template
void AtomTemplate::setPosition2d(const Vector2& pos)
{
m_molecule->setAtomPosition2d(m_index, pos);
}
template
Vector2 AtomTemplate::position2d() const
{
return m_molecule->atomPositions2d().size() > 0
? m_molecule->atomPositions2d()[m_index]
: Vector2::Zero();
}
template
void AtomTemplate::setPosition3d(const Vector3& pos)
{
m_molecule->setAtomPosition3d(m_index, pos);
}
template
Vector3 AtomTemplate::position3d() const
{
return m_molecule->atomPositions3d().size() > 0
? m_molecule->atomPositions3d()[m_index]
: Vector3::Zero();
}
template
void AtomTemplate::setHybridization(AtomHybridization hyb)
{
m_molecule->setHybridization(m_index, hyb);
}
template
AtomHybridization AtomTemplate::hybridization() const
{
return m_molecule->hybridization(m_index);
}
template
void AtomTemplate::setFormalCharge(signed char charge)
{
m_molecule->setFormalCharge(m_index, charge);
}
template
signed char AtomTemplate::formalCharge() const
{
return m_molecule->formalCharge(m_index);
}
template
void AtomTemplate::setColor(Vector3ub color)
{
m_molecule->setColor(m_index, std::move(color));
}
template
Vector3ub AtomTemplate::color() const
{
return m_molecule->color(m_index);
}
template
void AtomTemplate::setLayer(size_t layer)
{
m_molecule->setLayer(m_index, layer);
}
template
size_t AtomTemplate::layer() const
{
return m_molecule->layer(m_index);
}
template
void AtomTemplate::setSelected(bool selected)
{
m_molecule->setAtomSelected(m_index, selected);
}
template
bool AtomTemplate::selected() const
{
return m_molecule->atomSelected(m_index);
}
template
void AtomTemplate::setForceVector(const Vector3& force)
{
m_molecule->setForceVector(m_index, force);
}
template
Vector3 AtomTemplate::forceVector() const
{
return m_molecule->forceVectors().size() > 0
? m_molecule->forceVectors()[m_index]
: Vector3::Zero();
}
template
void AtomTemplate::setLabel(const std::string& label)
{
m_molecule->setLabel(m_index, label);
}
template
std::string AtomTemplate::label() const
{
return m_molecule->label(m_index);
}
} // namespace Core
} // namespace Avogadro
#endif // AVOGADRO_CORE_ATOM_H
avogadrolibs-1.95.1/avogadro/core/atomtyper-inline.h 0000664 0000000 0000000 00000004361 14112012703 0022461 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2013 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_ATOMTYPER_INLINE_H
#define AVOGADRO_CORE_ATOMTYPER_INLINE_H
#include "atomtyper.h"
#include "atom.h"
#include "molecule.h"
namespace Avogadro {
namespace Core {
template
AtomTyper::AtomTyper(const Molecule* mol) : m_molecule(mol)
{
}
template
AtomTyper::~AtomTyper()
{
}
template
void AtomTyper::setMolecule(const Molecule* mol)
{
if (m_molecule != mol) {
m_molecule = mol;
reset();
}
}
template
void AtomTyper::run()
{
initialize();
Index numAtoms = m_molecule ? m_molecule->atomCount() : 0;
for (Index atomId = 0; atomId < numAtoms; ++atomId) {
Atom atom = m_molecule->atom(atomId);
m_types.push_back(type(atom));
}
}
template
OutputType AtomTyper::atomType(const Atom& atom)
{
OutputType result;
if (atom.isValid() && atom.molecule() == m_molecule) {
// Return the calculated value if we've already run the typer.
if (atom.index() < m_types.size()) {
result = m_types[atom.index()];
} else {
initialize();
result = type(atom);
}
}
return result;
}
template
Array AtomTyper::types() const
{
return m_types;
}
template
void AtomTyper::reset()
{
m_types.clear();
}
template
void AtomTyper::initialize()
{
m_types.reserve(m_molecule ? m_molecule->atomCount() : 0);
}
} // namespace Core
} // namespace Avogadro
#endif // AVOGADRO_CORE_ATOMTYPER_INLINE_H
avogadrolibs-1.95.1/avogadro/core/atomtyper.h 0000664 0000000 0000000 00000005314 14112012703 0021204 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2013 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_ATOMTYPER_H
#define AVOGADRO_CORE_ATOMTYPER_H
#include
namespace Avogadro {
namespace Core {
class Atom;
class Molecule;
/**
* @class AtomTyper atomtyper.h
* @brief The AtomTyper class provides a base interface for generating a list of
* type identifiers describing the atoms in a molecule.
*/
template
class AtomTyper
{
public:
typedef OutputType ValueType;
explicit AtomTyper(const Molecule* mol = nullptr);
virtual ~AtomTyper();
/**
* @param mol The molecule with atoms to type.
*/
void setMolecule(const Molecule* mol);
/**
* Iterate through the molecule and generate type descriptions for each atom.
* The results can be obtained by calling types().
*/
virtual void run();
/**
* Perform a type lookup on the specified atom. If run() has been called
* previously, a cached result is returned.
* @return The type of @a atom.
*/
virtual OutputType atomType(const Atom& atom);
/**
* @return An Array of OutputType objects. There will be one object for each
* atom of the input Molecule, and they are ordered by the corresponding
* atom's index.
*/
Array types() const;
/**
* Reset the typer's internal state. This is called when the molecule is
* changed. The base implementation clears the m_types Array.
*/
virtual void reset();
protected:
/**
* Perform any setup needed that needs to be done prior to calling type(). The
* base implementation of this function reserves enough room in the m_types
* Array for the current Molecule.
*/
virtual void initialize();
/**
* Determines the type of the atom.
* @param atom The atom to type.
* @return The type of @a atom.
*/
virtual OutputType type(const Atom& atom) = 0;
/** The molecule on which to operate. */
const Molecule* m_molecule;
/** The array of types to be populated. */
Array m_types;
};
} // namespace Core
} // namespace Avogadro
#include
#endif // AVOGADRO_CORE_ATOMTYPER_H
avogadrolibs-1.95.1/avogadro/core/avogadrocore.h 0000664 0000000 0000000 00000006407 14112012703 0021637 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2011-2013 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_H
#define AVOGADRO_CORE_H
#include "avogadrocoreexport.h"
#include
#include
/** Prevent compiler error when using std::numeric_limits::max() */
#if defined(_MSC_VER) && defined(max)
#undef max
#endif
/**
* This macro marks a parameter as unused. Its purpose is to disable the
* compiler from emitting unused parameter warnings.
*/
#define AVO_UNUSED(variable) (void)variable
/**
* This macro marks a class as not copyable. It should be used in the private
* section of a class's declaration.
*/
#define AVO_DISABLE_COPY(Class) \
Class(const Class&); \
Class& operator=(const Class&);
namespace Avogadro {
/** Typedef for a real number. */
typedef double Real;
/** Typedef for indices and sizes. */
typedef size_t Index;
const Index MaxIndex = std::numeric_limits::max();
/** Used to represent an invalid atomic number. */
const unsigned char InvalidElement = 255;
/**
* Minimum value for atomic numbers that represent custom, non-elemental
* particles. */
const unsigned char CustomElementMin = 128;
/**
* Maximum value for atomic numbers that represent custom, non-elemental
* particles. */
const unsigned char CustomElementMax = 254;
/**
* Count of atomic number values that are used to represent custom,
* non-elemental particles. */
const unsigned char CustomElementCount =
CustomElementMax - CustomElementMin + 1;
/**
* @return True if @a atomicNumber denotes a custom element type.
*/
namespace Core {
inline bool isCustomElement(unsigned char atomicNumber)
{
return atomicNumber >= CustomElementMin && atomicNumber <= CustomElementMax;
}
}
/** Unit conversion factors. @{ */
const double PI_D = 3.141592653589793238462643;
const float PI_F = static_cast(PI_D);
const Real PI = static_cast(PI_D);
const double DEG_TO_RAD_D = PI_D / 180.0;
const float DEG_TO_RAD_F = static_cast(DEG_TO_RAD_D);
const Real DEG_TO_RAD = static_cast(DEG_TO_RAD_D);
const double RAD_TO_DEG_D = 180.0 / PI_D;
const float RAD_TO_DEG_F = static_cast(RAD_TO_DEG_D);
const Real RAD_TO_DEG = static_cast(RAD_TO_DEG_D);
const double BOHR_TO_ANGSTROM_D = 0.52917721092;
const float BOHR_TO_ANGSTROM_F = static_cast(BOHR_TO_ANGSTROM_D);
const Real BOHR_TO_ANGSTROM = static_cast(BOHR_TO_ANGSTROM_D);
const double ANGSTROM_TO_BOHR_D = 1.0 / BOHR_TO_ANGSTROM_D;
const float ANGSTROM_TO_BOHR_F = static_cast(ANGSTROM_TO_BOHR_D);
const Real ANGSTROM_TO_BOHR = static_cast(ANGSTROM_TO_BOHR_D);
/** @} */
} // end Avogadro namespace
#endif // AVOGADRO_CORE_H
avogadrolibs-1.95.1/avogadro/core/avospglib.cpp 0000664 0000000 0000000 00000011776 14112012703 0021512 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2016 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#include "avospglib.h"
#include "array.h"
#include "matrix.h"
#include "molecule.h"
#include "unitcell.h"
#include "vector.h"
#include
extern "C" {
#include "spglib.h"
}
namespace Avogadro {
namespace Core {
unsigned short AvoSpglib::getHallNumber(Molecule& mol, double cartTol)
{
if (!mol.unitCell())
return 0;
const UnitCell* uc = mol.unitCell();
Matrix3 cellMat = uc->cellMatrix();
double lattice[3][3];
// Spglib expects column vectors
for (Index i = 0; i < 3; ++i) {
for (Index j = 0; j < 3; ++j) {
lattice[i][j] = cellMat(i, j);
}
}
Index numAtoms = mol.atomCount();
double(*positions)[3] = new double[numAtoms][3];
int* types = new int[numAtoms];
const Array& atomicNums = mol.atomicNumbers();
const Array& pos = mol.atomPositions3d();
// Positions need to be in fractional coordinates
for (Index i = 0; i < numAtoms; ++i) {
Vector3 fracCoords = uc->toFractional(pos[i]);
positions[i][0] = fracCoords[0];
positions[i][1] = fracCoords[1];
positions[i][2] = fracCoords[2];
types[i] = atomicNums[i];
}
SpglibDataset* data =
spg_get_dataset(lattice, positions, types, numAtoms, cartTol);
if (!data) {
std::cerr << "Cannot determine spacegroup.\n";
delete[] positions;
delete[] types;
return 0;
}
unsigned short hallNumber = data->hall_number;
// Cleanup time
spg_free_dataset(data);
delete[] positions;
delete[] types;
mol.setHallNumber(hallNumber);
return hallNumber;
}
bool AvoSpglib::reduceToPrimitive(Molecule& mol, double cartTol)
{
return standardizeCell(mol, cartTol, true, false);
}
bool AvoSpglib::conventionalizeCell(Molecule& mol, double cartTol)
{
return standardizeCell(mol, cartTol, false, true);
}
bool AvoSpglib::symmetrize(Molecule& mol, double cartTol)
{
return standardizeCell(mol, cartTol, true, true);
}
bool AvoSpglib::standardizeCell(Molecule& mol, double cartTol, bool toPrimitive,
bool idealize)
{
if (!mol.unitCell())
return false;
const UnitCell* uc = mol.unitCell();
Matrix3 cellMat = uc->cellMatrix();
double lattice[3][3];
// Spglib expects column vectors
for (Index i = 0; i < 3; ++i) {
for (Index j = 0; j < 3; ++j) {
lattice[i][j] = cellMat(i, j);
}
}
Index numAtoms = mol.atomCount();
// spg_standardize_cell() can cause the number of atoms to increase by
// as much as 4x if toPrimitive is false.
// So, we must make these arrays at least 4x the number of atoms.
// If toPrimitive is true, then we will just use the number of atoms.
// See http://atztogo.github.io/spglib/api.html#spg-standardize-cell
int numAtomsMultiplier = toPrimitive ? 1 : 4;
double(*positions)[3] = new double[numAtoms * numAtomsMultiplier][3];
int* types = new int[numAtoms * numAtomsMultiplier];
const Array& atomicNums = mol.atomicNumbers();
const Array& pos = mol.atomPositions3d();
// Positions need to be in fractional coordinates
for (Index i = 0; i < numAtoms; ++i) {
Vector3 fracCoords = uc->toFractional(pos[i]);
positions[i][0] = fracCoords[0];
positions[i][1] = fracCoords[1];
positions[i][2] = fracCoords[2];
types[i] = atomicNums[i];
}
// Run the spglib algorithm
Index newNumAtoms = spg_standardize_cell(lattice, positions, types, numAtoms,
toPrimitive, !idealize, cartTol);
// If 0 is returned, the algorithm failed.
if (newNumAtoms == 0) {
delete[] positions;
delete[] types;
return false;
}
// Let's create a new molecule with the information
Molecule newMol;
// First, we will make the unit cell
Matrix3 newCellMat;
for (Index i = 0; i < 3; ++i) {
for (Index j = 0; j < 3; ++j) {
newCellMat(i, j) = lattice[i][j];
}
}
UnitCell* newCell = new UnitCell(newCellMat);
newMol.setUnitCell(newCell);
// Next, add in the atoms
for (Index i = 0; i < newNumAtoms; ++i) {
Atom newAtom = newMol.addAtom(types[i]);
Vector3 newAtomPos(positions[i][0], positions[i][1], positions[i][2]);
// We must convert it back to cartesian before adding it
newAtom.setPosition3d(newCell->toCartesian(newAtomPos));
}
delete[] positions;
delete[] types;
// Set the new molecule
mol = newMol;
// Set the space group in the molecule
getHallNumber(mol, cartTol);
return true;
}
} // end Core namespace
} // end Avogadro namespace
avogadrolibs-1.95.1/avogadro/core/avospglib.h 0000664 0000000 0000000 00000007041 14112012703 0021145 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2016 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_AVO_SPGLIB_H
#define AVOGADRO_CORE_AVO_SPGLIB_H
#include "avogadrocore.h"
#include "molecule.h"
namespace Avogadro {
namespace Core {
/**
* @class AvoSpglib avospglib.h
* @brief The AvoSpglib class provides an interface between Avogadro and Spglib.
*/
class AVOGADROCORE_EXPORT AvoSpglib
{
public:
AvoSpglib();
~AvoSpglib();
/**
* Use spglib to find the Hall number for a crystal. If the unit cell does not
* exist or if the algorithm fails, 0 will be returned.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be handled.
* @param cartTol The cartesian tolerance for spglib.
* @return The Hall number for the crystal.
*/
static unsigned short getHallNumber(Molecule& mol,
double cartTol = 1e-5);
/**
* Use spglib to reduce the crystal to a primitive cell. Unless the molecule
* is missing its unit cell, it will be edited by spglib. Positions are
* not idealized.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be reduced to its primitive cell.
* @param cartTol The cartesian tolerance for spglib.
* @return False if the molecule has no unit cell or if the
spglib algorithm failed. True otherwise.
*/
static bool reduceToPrimitive(Molecule& mol, double cartTol = 1e-5);
/**
* Use spglib to refine the crystal to its conventional cell. Unless the
* molecule is missing its unit cell, it will be edited by spglib. Positions
* are idealized.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be conventionalized.
* @param cartTol The cartesian tolerance for spglib.
* @return False if the molecule has no unit cell or if the
* spglib algorithm failed. True otherwise.
*/
static bool conventionalizeCell(Molecule& mol, double cartTol = 1e-5);
/**
* Use spglib to symmetrize the crystal. Unless the molecule is missing
* its unit cell, it will be edited by spglib. It will be reduced
* to its primitive form, and positions will be idealized.
*
* If the algorithm succeeds, the hall number will be set in the molecule.
*
* @param mol The molecule to be conventionalized.
* @param cartTol The cartesian tolerance for spglib.
* @return False if the molecule has no unit cell or if the
* spglib algorithm failed. True otherwise.
*/
static bool symmetrize(Molecule& mol, double cartTol = 1e-5);
private:
// Called by reduceToPrimitive(), conventionalizeCell(), and symmetrize()
// Calls spg_standardize_cell()
static bool standardizeCell(Molecule& mol, double cartTol, bool toPrimitive,
bool idealize);
};
} // end Core namespace
} // end Avogadro namespace
#endif // AVOGADRO_CORE_AVO_SPGLIB_H
avogadrolibs-1.95.1/avogadro/core/basisset.h 0000664 0000000 0000000 00000012264 14112012703 0020777 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2008-2009 Marcus D. Hanwell
Copyright 2010-2013 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_BASISSET_H
#define AVOGADRO_CORE_BASISSET_H
#include "avogadrocore.h"
#include
namespace Avogadro {
namespace Core {
class Molecule;
/**
* @class BasisSet basisset.h
* @brief BasisSet contains basis set data.
* @author Marcus D. Hanwell
*
* This is the base class for basis sets, and has two derived classes -
* GaussianSet and SlaterSet. It must be populated with data, with other classes
* capable of performing calculations on the data or writing it out.
*/
class AVOGADROCORE_EXPORT BasisSet
{
public:
/**
* Constructor.
*/
BasisSet() {}
/**
* Destructor.
*/
virtual ~BasisSet() {}
/**
* Clone.
*/
virtual BasisSet* clone() const = 0;
/**
* @brief The ElectronType enum describes the type of electrons being set or
* retrieved. If Paired, then Alpha and Beta cannot be set, if Alpha or Beta
* then both must be set.
*/
enum ElectronType
{
Paired,
Alpha,
Beta
};
/**
* Set the number of electrons in the BasisSet.
* @param n The number of electrons in the BasisSet.
* @param type The type of the electrons (Alpha, Beta, or Paired).
*/
virtual void setElectronCount(unsigned int n, ElectronType type = Paired);
/**
* @param type The type of the electrons (Alpha, Beta, or Paired).
* @return The number of electrons in the molecule.
*/
unsigned int electronCount(ElectronType type = Paired) const;
/**
* Set the molecule for the basis set.
*/
void setMolecule(Molecule* molecule_) { m_molecule = molecule_; }
/**
* Get the molecule this basis set belongs to.
*/
Molecule* molecule() { return m_molecule; }
const Molecule* molecule() const { return m_molecule; }
/**
* Set the name of the basis set.
*/
void setName(const std::string& name) { m_name = name; }
/**
* Get the name of the basis set.
*/
std::string name() const { return m_name; }
/**
* Set the name of the basis set.
*/
void setTheoryName(const std::string& name) { m_theoryName = name; }
/**
* Get the name of the basis set.
*/
std::string theoryName() const { return m_theoryName; }
/**
* @return The number of molecular orbitals in the BasisSet.
*/
virtual unsigned int molecularOrbitalCount(ElectronType type = Paired) = 0;
/**
* Check if the given MO number is the HOMO or not.
* @param n The MO number.
* @return True if the given MO number is the HOMO.
*/
bool homo(unsigned int n) { return n == homo(); }
/**
* @return The molecular orbital number corresponding to the HOMO orbital.
*/
unsigned int homo() const { return m_electrons[0] / 2; }
/**
* Check if the given MO number is the LUMO or not.
* @param n The MO number.
* @return True if the given MO number is the LUMO.
*/
bool lumo(unsigned int n) { return n == lumo(); }
/**
* @return The molecular orbital number corresponding to the LUMO orbital.
*/
unsigned int lumo() const { return m_electrons[0] / 2 + 1; }
/**
* @return True of the basis set is valid, false otherwise.
* Default is true, if false then the basis set is likely unusable.
*/
virtual bool isValid() = 0;
protected:
/**
* Total number of electrons, 0 is alpha electrons and 1 is beta electrons.
* For closed shell calculations alpha is doubly occupied and there are no
* beta electrons.
*/
unsigned int m_electrons[2];
/**
* The Molecule holds the atoms (and possibly bonds) read in from the output
* file. Most basis sets have orbitals around these atoms, but this is not
* necessarily the case.
*/
Molecule* m_molecule;
/**
* The name of the basis set, this is usually a string identifier referencing
* a standard basis set when only one is used.
*/
std::string m_name;
/**
* The name of the theory used for the calculation.
*/
std::string m_theoryName;
};
inline void BasisSet::setElectronCount(unsigned int n, ElectronType type)
{
switch (type) {
case Paired:
m_electrons[0] = n;
m_electrons[1] = 0;
break;
case Alpha:
m_electrons[0] = n;
break;
case Beta:
m_electrons[1] = n;
break;
default:
// Shouldn't hit this condition.
;
}
}
inline unsigned int BasisSet::electronCount(ElectronType type) const
{
switch (type) {
case Paired:
case Alpha:
return m_electrons[0];
case Beta:
return m_electrons[1];
default:
// Shouldn't hit this condition.
return 0;
}
}
} // End namesapce Core
} // End namespace Avogadro
#endif
avogadrolibs-1.95.1/avogadro/core/bond.h 0000664 0000000 0000000 00000012676 14112012703 0020113 0 ustar 00root root 0000000 0000000 /******************************************************************************
This source file is part of the Avogadro project.
Copyright 2011-2012 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
#ifndef AVOGADRO_CORE_BOND_H
#define AVOGADRO_CORE_BOND_H
#include "avogadrocore.h"
#include "atom.h"
namespace Avogadro {
namespace Core {
/**
* @class Bond bond.h
* The Bond class represents a bond in a molecule.
* To use the appropriate bond implementation for a specific molecule
* implementation, use the [MoleculeClass]::BondType typedef.
*/
template
class BondTemplate
{
public:
typedef Molecule_T MoleculeType;
typedef typename Molecule_T::AtomType AtomType;
/** Creates a new, invalid bond object. */
BondTemplate();
/**
* Creates a bond object representing a bond at index @p i in molecule @p m.
*/
BondTemplate(MoleculeType* m, Index i);
/**
* @return True if @a this and @a other share the same index and molecule.
*/
bool operator==(const BondTemplate& other) const;
/**
* @return True if @a this and @a other do not share the same index or
* molecule.
*/
bool operator!=(const BondTemplate& other) const;
/**
* Prefix increment operator. Increment this Bond's index by 1 and return a
* self-reference. Check isValid() before calling any other methods.
*/
BondTemplate& operator++();
/**
* Postfix increment operator. Increment this Bond's index by 1 and return a
* copy of the current Atom. Check isValid() before calling any other methods.
*/
BondTemplate operator++(int);
/**
* Prefix decrement operator. Decrement this Bond's index by 1 and return a
* self-reference. Check isValid() before calling any other methods.
*/
BondTemplate& operator--();
/**
* Postfix decrement operator. Decrement this Bond's index by 1 and return a
* copy of the current Atom. Check isValid() before calling any other methods.
*/
BondTemplate operator--(int);
/**
* @return True if the molecule is set and the index is less than the number
* of bonds.
*/
bool isValid() const;
/**
* @return The molecule that contains this Bond.
*/
MoleculeType* molecule() const;
/**
* @return The index of this bond in molecule().
*/
Index index() const;
/**
* An atom in the bond, such that atom1().index() < atom2.index().
* @{
*/
AtomType atom1() const;
AtomType atom2() const;
/** @} */
/**
* The bond's order (single = 1, double = 2, etc.)
* @{
*/
void setOrder(unsigned char o);
unsigned char order() const;
/** @} */
private:
MoleculeType* m_molecule;
Index m_index;
};
template
BondTemplate::BondTemplate()
: m_molecule(nullptr), m_index(MaxIndex)
{
}
template
BondTemplate::BondTemplate(MoleculeType* m, Index i)
: m_molecule(m), m_index(i)
{
}
template
bool BondTemplate::operator==(
const BondTemplate& other) const
{
return m_molecule == other.m_molecule && m_index == other.m_index;
}
template
bool BondTemplate::operator!=(
const BondTemplate& other) const
{
return m_molecule != other.m_molecule || m_index != other.m_index;
}
template
BondTemplate& BondTemplate::operator++()
{
++m_index;
return *this;
}
template
BondTemplate BondTemplate::operator++(int)
{
BondTemplate result(m_molecule, m_index++);
return result;
}
template
BondTemplate& BondTemplate::operator--()
{
--m_index;
return *this;
}
template
BondTemplate BondTemplate::operator--(int)
{
BondTemplate result(m_molecule, m_index--);
return result;
}
template
bool BondTemplate::isValid() const
{
return m_molecule && m_index < m_molecule->bondCount();
}
template
typename BondTemplate::MoleculeType*
BondTemplate::molecule() const
{
return m_molecule;
}
template
Index BondTemplate::index() const
{
return m_index;
}
template
typename BondTemplate::AtomType BondTemplate::atom1()
const
{
return AtomType(m_molecule, m_molecule->bondPairs()[m_index].first);
}
template
typename BondTemplate