Skip to content

Commit

Permalink
Minor tweaks to make parts of fillUnitCell optional
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Oct 17, 2023
1 parent 1225015 commit 5b0a8b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 7 additions & 3 deletions avogadro/core/spacegroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Array<Vector3> SpaceGroups::getTransforms(unsigned short hallNumber,
}

void SpaceGroups::fillUnitCell(Molecule& mol, unsigned short hallNumber,
double cartTol)
double cartTol, bool wrapToCell, bool allCopies)
{
if (!mol.unitCell())
return;
Expand Down Expand Up @@ -303,13 +303,17 @@ void SpaceGroups::fillUnitCell(Molecule& mol, unsigned short hallNumber,
newAtom.setPosition3d(newCandidate);
}
}
// @todo make this optional
CrystalTools::wrapAtomsToUnitCell(mol);

if (wrapToCell)
CrystalTools::wrapAtomsToUnitCell(mol);

// Now we need to generate any copies on the unit boundary
// We need to loop through all the atoms again
// if a fractional coordinate contains 0.0, we need to generate a copy
// of the atom at 1.0
if (!allCopies)
return;

atomicNumbers = mol.atomicNumbers();
positions = mol.atomPositions3d();
numAtoms = mol.atomCount();
Expand Down
14 changes: 8 additions & 6 deletions avogadro/core/spacegroups.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class AVOGADROCORE_EXPORT SpaceGroups
~SpaceGroups();

/**
* @return The hall number of the matching space group string or 0 if not found
* @return The hall number of the matching space group string or 0 if not
* found
*/
static unsigned short hallNumber(const std::string& spaceGroup);

Expand All @@ -65,8 +66,8 @@ class AVOGADROCORE_EXPORT SpaceGroups
static const char* schoenflies(unsigned short hallNumber);

/**
* @return the Hall symbol for a given hall number. '=' is used instead of '"'.
* If an invalid hall number is given, an empty string will be returned.
* @return the Hall symbol for a given hall number. '=' is used instead of
* '"'. If an invalid hall number is given, an empty string will be returned.
*/
static const char* hallSymbol(unsigned short hallNumber);

Expand Down Expand Up @@ -118,7 +119,8 @@ class AVOGADROCORE_EXPORT SpaceGroups
* distance, the new atom will not be placed there.
*/
static void fillUnitCell(Molecule& mol, unsigned short hallNumber,
double cartTol = 1e-5);
double cartTol = 1e-5, bool wrapToCell = true,
bool allCopies = true);

/**
* Reduce a cell to its asymmetric unit.
Expand All @@ -137,7 +139,7 @@ class AVOGADROCORE_EXPORT SpaceGroups
static const char* transformsString(unsigned short hallNumber);
};

} // end Core namespace
} // end Avogadro namespace
} // namespace Core
} // namespace Avogadro

#endif // AVOGADRO_CORE_SPACE_GROUPS_H

0 comments on commit 5b0a8b7

Please sign in to comment.