Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
e0777e74
Unverified
Commit
e0777e74
authored
Apr 08, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor updates
parent
cf465134
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
8 deletions
+79
-8
include/cif++/Cif++.hpp
+19
-7
include/cif++/Point.hpp
+10
-0
src/Cif++.cpp
+50
-1
src/CifUtils.cpp
+0
-0
No files found.
include/cif++/Cif++.hpp
View file @
e0777e74
...
@@ -686,7 +686,7 @@ class Row
...
@@ -686,7 +686,7 @@ class Row
}
}
template
<
typename
...
Ts
,
size_t
N
>
template
<
typename
...
Ts
,
size_t
N
>
std
::
tuple
<
Ts
...
>
get
(
char
const
*
const
(
&
columns
)[
N
])
std
::
tuple
<
Ts
...
>
get
(
char
const
*
const
(
&
columns
)[
N
])
const
{
{
static_assert
(
sizeof
...(
Ts
)
==
N
,
"Number of columns should be equal to number of types to return"
);
static_assert
(
sizeof
...(
Ts
)
==
N
,
"Number of columns should be equal to number of types to return"
);
...
@@ -1087,7 +1087,7 @@ template<typename T>
...
@@ -1087,7 +1087,7 @@ template<typename T>
Condition
operator
==
(
const
Key
&
key
,
const
T
&
v
)
Condition
operator
==
(
const
Key
&
key
,
const
T
&
v
)
{
{
std
::
ostringstream
s
;
std
::
ostringstream
s
;
s
<<
"== "
<<
v
;
s
<<
"
== "
<<
v
;
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
==
0
;
},
s
.
str
()));
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
==
0
;
},
s
.
str
()));
...
@@ -1123,7 +1123,7 @@ template<typename T>
...
@@ -1123,7 +1123,7 @@ template<typename T>
Condition
operator
>
(
const
Key
&
key
,
const
T
&
v
)
Condition
operator
>
(
const
Key
&
key
,
const
T
&
v
)
{
{
std
::
ostringstream
s
;
std
::
ostringstream
s
;
s
<<
"
>
"
<<
v
;
s
<<
"
>
"
<<
v
;
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
>
0
;
},
s
.
str
()));
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
>
0
;
},
s
.
str
()));
...
@@ -1133,7 +1133,7 @@ template<typename T>
...
@@ -1133,7 +1133,7 @@ template<typename T>
Condition
operator
>=
(
const
Key
&
key
,
const
T
&
v
)
Condition
operator
>=
(
const
Key
&
key
,
const
T
&
v
)
{
{
std
::
ostringstream
s
;
std
::
ostringstream
s
;
s
<<
"
>=
"
<<
v
;
s
<<
"
>=
"
<<
v
;
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
>=
0
;
},
s
.
str
()));
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
>=
0
;
},
s
.
str
()));
...
@@ -1143,7 +1143,7 @@ template<typename T>
...
@@ -1143,7 +1143,7 @@ template<typename T>
Condition
operator
<
(
const
Key
&
key
,
const
T
&
v
)
Condition
operator
<
(
const
Key
&
key
,
const
T
&
v
)
{
{
std
::
ostringstream
s
;
std
::
ostringstream
s
;
s
<<
"
<
"
<<
v
;
s
<<
"
<
"
<<
v
;
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
<
0
;
},
s
.
str
()));
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
<
0
;
},
s
.
str
()));
...
@@ -1153,7 +1153,7 @@ template<typename T>
...
@@ -1153,7 +1153,7 @@ template<typename T>
Condition
operator
<=
(
const
Key
&
key
,
const
T
&
v
)
Condition
operator
<=
(
const
Key
&
key
,
const
T
&
v
)
{
{
std
::
ostringstream
s
;
std
::
ostringstream
s
;
s
<<
"
<=
"
<<
v
;
s
<<
"
<=
"
<<
v
;
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
return
Condition
(
new
detail
::
KeyCompareConditionImpl
(
key
.
mItemTag
,
[
tag
=
key
.
mItemTag
,
v
](
const
Category
&
c
,
const
Row
&
r
,
bool
icase
)
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
<=
0
;
},
s
.
str
()));
{
return
r
[
tag
].
template
compare
<
T
>
(
v
,
icase
)
<=
0
;
},
s
.
str
()));
...
@@ -1824,6 +1824,12 @@ class Category
...
@@ -1824,6 +1824,12 @@ class Category
RowSet
getChildren
(
Row
r
,
Category
&
childCat
);
RowSet
getChildren
(
Row
r
,
Category
&
childCat
);
RowSet
getChildren
(
Row
r
,
const
char
*
childCat
);
RowSet
getChildren
(
Row
r
,
const
char
*
childCat
);
RowSet
getParents
(
Row
r
,
Category
&
parentCat
);
RowSet
getParents
(
Row
r
,
const
char
*
parentCat
);
RowSet
getLinked
(
Row
r
,
Category
&
cat
);
RowSet
getLinked
(
Row
r
,
const
char
*
cat
);
bool
isValid
();
bool
isValid
();
void
validateLinks
()
const
;
void
validateLinks
()
const
;
...
@@ -1904,7 +1910,13 @@ class File
...
@@ -1904,7 +1910,13 @@ class File
bool
isValid
();
bool
isValid
();
void
validateLinks
()
const
;
void
validateLinks
()
const
;
Datablock
&
firstDatablock
()
{
return
*
mHead
;
}
Datablock
&
firstDatablock
()
{
if
(
mHead
==
nullptr
)
throw
std
::
runtime_error
(
"No datablocks in file"
);
return
*
mHead
;
}
void
append
(
Datablock
*
e
);
void
append
(
Datablock
*
e
);
Datablock
*
get
(
const
std
::
string
&
name
)
const
;
Datablock
*
get
(
const
std
::
string
&
name
)
const
;
...
...
include/cif++/Point.hpp
View file @
e0777e74
...
@@ -340,6 +340,16 @@ double CosinusAngle(const PointF<F>& p1, const PointF<F>& p2, const PointF<F>& p
...
@@ -340,6 +340,16 @@ double CosinusAngle(const PointF<F>& p1, const PointF<F>& p2, const PointF<F>& p
return
result
;
return
result
;
}
}
template
<
typename
F
>
auto
DistancePointToLine
(
const
PointF
<
F
>
&
l1
,
const
PointF
<
F
>
&
l2
,
const
PointF
<
F
>
&
p
)
{
auto
line
=
l2
-
l1
;
auto
p_to_l1
=
p
-
l1
;
auto
p_to_l2
=
p
-
l2
;
auto
cross
=
CrossProduct
(
p_to_l1
,
p_to_l2
);
return
cross
.
length
()
/
line
.
length
();
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// For e.g. simulated annealing, returns a new point that is moved in
// For e.g. simulated annealing, returns a new point that is moved in
// a random direction with a distance randomly chosen from a normal
// a random direction with a distance randomly chosen from a normal
...
...
src/Cif++.cpp
View file @
e0777e74
...
@@ -1904,6 +1904,55 @@ RowSet Category::getChildren(Row r, Category& childCat)
...
@@ -1904,6 +1904,55 @@ RowSet Category::getChildren(Row r, Category& childCat)
return
result
;
return
result
;
}
}
RowSet
Category
::
getParents
(
Row
r
,
const
char
*
parentCat
)
{
return
getParents
(
r
,
mDb
[
parentCat
]);
}
RowSet
Category
::
getParents
(
Row
r
,
Category
&
parentCat
)
{
assert
(
mValidator
!=
nullptr
);
assert
(
mCatValidator
!=
nullptr
);
RowSet
result
(
parentCat
);
for
(
auto
&
link
:
mValidator
->
getLinksForChild
(
mName
))
{
if
(
link
->
mParentCategory
!=
parentCat
.
mName
)
continue
;
Condition
cond
;
for
(
size_t
ix
=
0
;
ix
<
link
->
mChildKeys
.
size
();
++
ix
)
{
const
char
*
value
=
r
[
link
->
mChildKeys
[
ix
]].
c_str
();
cond
=
std
::
move
(
cond
)
&&
(
Key
(
link
->
mParentKeys
[
ix
])
==
value
);
}
auto
parents
=
parentCat
.
find
(
std
::
move
(
cond
));
result
.
insert
(
result
.
end
(),
parents
.
begin
(),
parents
.
end
());
}
// remove duplicates
result
.
make_unique
();
return
result
;
}
RowSet
Category
::
getLinked
(
Row
r
,
const
char
*
cat
)
{
return
getLinked
(
r
,
mDb
[
cat
]);
}
RowSet
Category
::
getLinked
(
Row
r
,
Category
&
cat
)
{
RowSet
result
=
getChildren
(
r
,
cat
);
if
(
result
.
empty
())
result
=
getParents
(
r
,
cat
);
return
result
;
}
bool
Category
::
isValid
()
bool
Category
::
isValid
()
{
{
bool
result
=
true
;
bool
result
=
true
;
...
@@ -2582,7 +2631,7 @@ void Row::assign(size_t column, const std::string& value, bool skipUpdateLinked)
...
@@ -2582,7 +2631,7 @@ void Row::assign(size_t column, const std::string& value, bool skipUpdateLinked)
}
}
}
}
if
(
cif
::
VERBOSE
>
=
2
)
if
(
cif
::
VERBOSE
>
2
)
{
{
std
::
cerr
<<
"Parent: "
<<
linked
->
mParentCategory
<<
" Child: "
<<
linked
->
mChildCategory
<<
std
::
endl
std
::
cerr
<<
"Parent: "
<<
linked
->
mParentCategory
<<
" Child: "
<<
linked
->
mChildCategory
<<
std
::
endl
<<
cond
<<
std
::
endl
;
<<
cond
<<
std
::
endl
;
...
...
src/CifUtils.cpp
View file @
e0777e74
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment