-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes#1714 => Functionality for setting size of ghost atom #1911
base: master
Are you sure you want to change the base?
Conversation
Thanks for opening this pull request! Please check out our contributing guidelines and check for the automated tests. |
This looks fine from a Before I merge, it would be great to have a test or two in https://github.com/OpenChemistry/avogadrolibs/blob/master/tests/core/elementtest.cpp |
Oh, before I forget .. I don't remember if it's mentioned in #1714 but some "ghost" atoms are element 0. That probably needs a special case in your code. |
I am working on this but I just wanted to clarify a small doubt, does element 0 mean neutronium? Like the edge case should be for neutronium? |
Most chemistry packages have a element 0 "Xx" or "Du" - it's a placeholder. In Avogadro, it's used to indicate a centroid point, for example. |
I have committed some changes into this including edge case for element 0. Please review. |
This pull request has been mentioned on Avogadro Discussion. There might be relevant details there: |
Signed-off-by: Vaishnavi Bhandari <[email protected]>
@@ -111,9 +113,33 @@ | |||
} | |||
} | |||
} CustomElementTableInitializer; | |||
void setCustomElementCovalentRadius(unsigned char atomicNumber, double radius) |
Check notice
Code scanning / CodeQL
Unused static function Note
|
||
void setCustomElementVDWRadius(unsigned char atomicNumber, double radius) |
Check notice
Code scanning / CodeQL
Unused static function Note
switch (error_handler) | ||
{ | ||
case error_handler_t::strict: | ||
{ | ||
JSON_THROW(type_error::create(316, concat("invalid UTF-8 byte at index ", std::to_string(i), ": 0x", hex_bytes(byte | 0)), nullptr)); | ||
} | ||
|
||
case error_handler_t::ignore: | ||
case error_handler_t::replace: | ||
{ | ||
// in case we saw this character the first time, we | ||
// would like to read it again, because the byte | ||
// may be OK for itself, but just not OK for the | ||
// previous sequence | ||
if (undumped_chars > 0) | ||
{ | ||
--i; | ||
} | ||
|
||
// reset length buffer to the last accepted index; | ||
// thus removing/ignoring the invalid characters | ||
bytes = bytes_after_last_accept; | ||
|
||
if (error_handler == error_handler_t::replace) | ||
{ | ||
// add a replacement character | ||
if (ensure_ascii) | ||
{ | ||
string_buffer[bytes++] = '\\'; | ||
string_buffer[bytes++] = 'u'; | ||
string_buffer[bytes++] = 'f'; | ||
string_buffer[bytes++] = 'f'; | ||
string_buffer[bytes++] = 'f'; | ||
string_buffer[bytes++] = 'd'; | ||
} | ||
else | ||
{ | ||
string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xEF'); | ||
string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBF'); | ||
string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBD'); | ||
} | ||
|
||
// write buffer and reset index; there must be 13 bytes | ||
// left, as this is the maximal number of bytes to be | ||
// written ("\uxxxx\uxxxx\0") for one code point | ||
if (string_buffer.size() - bytes < 13) | ||
{ | ||
o->write_characters(string_buffer.data(), bytes); | ||
bytes = 0; | ||
} | ||
|
||
bytes_after_last_accept = bytes; | ||
} | ||
|
||
undumped_chars = 0; | ||
|
||
// continue processing the string | ||
state = UTF8_ACCEPT; | ||
break; | ||
} | ||
|
||
default: // LCOV_EXCL_LINE | ||
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE | ||
} |
Check notice
Code scanning / CodeQL
Long switch case Note library
replace (52 lines)
// previous sequence | ||
if (undumped_chars > 0) | ||
{ | ||
--i; |
Check notice
Code scanning / CodeQL
For loop variable changed in body Note library
loop
inline std::size_t concat_length(const StringType& str, const Args& ... rest); | ||
|
||
template<typename... Args> | ||
inline std::size_t concat_length(const char /*c*/, const Args& ... rest) |
Check notice
Code scanning / CodeQL
Unused local variable Note library
inline std::size_t concat_length(const StringType& str, const Args& ... rest); | ||
|
||
template<typename... Args> | ||
inline std::size_t concat_length(const char /*c*/, const Args& ... rest) |
Check notice
Code scanning / CodeQL
Unused static variable Note library
} | ||
|
||
template<typename... Args> | ||
inline std::size_t concat_length(const char* cstr, const Args& ... rest) |
Check notice
Code scanning / CodeQL
Unused local variable Note library
} | ||
|
||
template<typename... Args> | ||
inline std::size_t concat_length(const char* cstr, const Args& ... rest) |
Check notice
Code scanning / CodeQL
Unused static variable Note library
} | ||
|
||
template<typename StringType, typename... Args> | ||
inline std::size_t concat_length(const StringType& str, const Args& ... rest) |
Check notice
Code scanning / CodeQL
Unused local variable Note library
This pull request has been mentioned on Avogadro Discussion. There might be relevant details there: |
Modified elements.cpp to allow for individual radii for each custom element.
Added methods to set the radii for custom elements.
Updated the methods that return the radii to use the vectors instead of the single values.