• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョン06ff6114c3ec58cc025a72ad33802765d03df223 (tree)
日時2022-02-23 13:36:36
作者Toshi Nagata <alchemist.2005@nift...>
コミッターToshi Nagata

ログメッセージ

Handling of IntGroup's in some Molecule methods are improved.

変更サマリ

差分

--- a/MolLib/Ruby_bind/ruby_bind.c
+++ b/MolLib/Ruby_bind/ruby_bind.c
@@ -4931,10 +4931,13 @@ static IntGroup *
49314931 s_Molecule_AtomGroupFromValue(VALUE self, VALUE val)
49324932 {
49334933 IntGroup *ig;
4934+ Molecule *mp1;
4935+ Data_Get_Struct(self, Molecule, mp1);
49344936 val = rb_funcall(self, rb_intern("atom_group"), 1, val);
49354937 if (!rb_obj_is_kind_of(val, rb_cIntGroup))
49364938 rb_raise(rb_eMolbyError, "IntGroup instance is expected");
49374939 Data_Get_Struct(val, IntGroup, ig);
4940+ IntGroupRemove(ig, mp1->natoms, ATOMS_MAX_NUMBER); /* Limit the group member to existing atoms */
49384941 IntGroupRetain(ig);
49394942 return ig;
49404943 }
@@ -6121,12 +6124,14 @@ s_Molecule_Remove(VALUE self, VALUE group)
61216124 Int i;
61226125 IntGroupIterator iter;
61236126
6124- Data_Get_Struct(self, Molecule, mol1);
6127+ ig = s_Molecule_AtomGroupFromValue(self, group);
6128+/* Data_Get_Struct(self, Molecule, mol1);
61256129 group = rb_funcall(self, rb_intern("atom_group"), 1, group);
61266130 if (!rb_obj_is_kind_of(group, rb_cIntGroup))
61276131 rb_raise(rb_eMolbyError, "IntGroup instance is expected");
6128- Data_Get_Struct(group, IntGroup, ig);
6129-
6132+ Data_Get_Struct(group, IntGroup, ig); */
6133+ Data_Get_Struct(self, Molecule, mol1);
6134+
61306135 /* Remove the bonds between the two fragments */
61316136 /* (This is necessary for undo to work correctly) */
61326137 IntGroupIteratorInit(ig, &iter);
@@ -8631,7 +8636,7 @@ s_Molecule_FitCoordinates(int argc, VALUE *argv, VALUE self)
86318636 if (gval == Qnil)
86328637 ig = IntGroupNewWithPoints(0, mol->natoms, -1);
86338638 else
8634- ig = IntGroupFromValue(gval);
8639+ ig = s_Molecule_AtomGroupFromValue(self, gval);
86358640 if (ig == NULL || (nn = IntGroupGetCount(ig)) == 0) {
86368641 IntGroupRelease(ig);
86378642 rb_raise(rb_eMolbyError, "atom group is not given correctly");
@@ -10990,7 +10995,7 @@ s_Molecule_SearchEquivalentAtoms(int argc, VALUE *argv, VALUE self)
1099010995 return Qnil;
1099110996 rb_scan_args(argc, argv, "01", &val);
1099210997 if (val != Qnil)
10993- ig = IntGroupFromValue(val);
10998+ ig = s_Molecule_AtomGroupFromValue(self, val);
1099410999 else ig = NULL;
1099511000 result = MoleculeSearchEquivalentAtoms(mol, ig);
1099611001 if (result == NULL)
@@ -11037,7 +11042,12 @@ s_Molecule_CreatePiAnchor(int argc, VALUE *argv, VALUE self)
1103711042 gval = *argv++;
1103811043 argc -= 2;
1103911044 Data_Get_Struct(self, Molecule, mol);
11040- ig = IntGroupFromValue(gval);
11045+ if (gval == Qnil)
11046+ ig = NULL;
11047+ else
11048+ ig = s_Molecule_AtomGroupFromValue(self, gval);
11049+ if (ig == NULL || IntGroupGetCount(ig) == 0)
11050+ rb_raise(rb_eMolbyError, "atom group is not given correctly");
1104111051 memset(&a, 0, sizeof(a));
1104211052 memset(&an, 0, sizeof(an));
1104311053 strncpy(a.aname, StringValuePtr(nval), 4);
旧リポジトリブラウザで表示