Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Conograph/trunk/src/utility_data_structure/NodeB.hh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (show annotations) (download) (as text)
Wed Sep 7 04:38:51 2016 UTC (7 years, 6 months ago) by rtomiyasu
File MIME type: text/x-c++hdr
File size: 4049 byte(s)
The output format for base-centered monoclinic cells was corrected.
1 /*
2 * The MIT License
3
4 Conograph (powder auto-indexing program)
5
6 Copyright (c) <2012> <Ryoko Oishi-Tomiyasu, KEK>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 *
26 */
27 #ifndef _NodeB_hh_
28 #define _NodeB_hh_
29 // Node3.hh
30
31 #include <set>
32 #include "Bud.hh"
33 #include "VCData.hh"
34 #include "VecDat3.hh"
35 #include "../RietveldAnalysisTypes.hh"
36 #include "../utility_func/zstring.hh"
37
38
39 class NodeB
40 {
41 private:
42 Int4 m_left; // K1
43 Int4 m_right; // K2
44 NodeB* m_left_branch; // K1, K4
45 NodeB* m_right_branch; // K2, K4
46
47 public:
48 NodeB();
49 NodeB(const Int4& i, const Int4& j);
50 NodeB(const NodeB& i, const NodeB& j);
51 NodeB(const NodeB& rhs);
52 ~NodeB();
53
54 NodeB& operator=(const NodeB& rhs);
55 void set(NodeB& rhs);
56
57 inline const Int4& Left() const;
58 inline const Int4& Right() const;
59 inline bool IsBud() const;
60 inline Int4 Upper() const;
61
62 void count(std::set<Int4>& index) const;
63
64 inline const NodeB& LeftBranch() const;
65 inline const NodeB& RightBranch() const;
66
67 void setBranch(const Int4&);
68 void cutBranch();
69
70 void putRootBud(const Int4& K3, std::set<Bud>& tray) const;
71 void putBud(const Int4& K3, std::set<Bud>& tray) const;
72 // void putQuadraticForm(const VecDat3<Int4>& hkl_left,
73 // const VecDat3<Int4>& hkl_right,
74 // multimap<Int4, VecDat3<Int4> >& qindex_hkl) const;
75
76 inline Int4 count_bud() const;
77
78 inline string chToString() const;
79 inline void swapBranch();
80 void print(ostream&, const Int4& num, const Int4& K3, const Double& maxQ) const;
81 };
82
83
84 inline Int4 NodeB::count_bud() const
85 {
86 if( IsBud() ) return 0;
87
88 if( m_left == m_right ) return m_left_branch->count_bud() + 1;
89 else return m_left_branch->count_bud() + m_right_branch->count_bud() + 1;
90 }
91
92
93 inline const Int4& NodeB::Left() const
94 {
95 return m_left;
96 }
97
98
99 inline const Int4& NodeB::Right() const
100 {
101 return m_right;
102 }
103
104
105 inline bool NodeB::IsBud() const
106 {
107 return m_left_branch == NULL && m_right_branch == NULL;
108 }
109
110
111 inline Int4 NodeB::Upper() const
112 {
113 if( this->IsBud() )
114 {
115 throw ZErrorMessage(ZErrorNullPointer, __FILE__, __LINE__, __FUNCTION__);
116 }
117 return m_left_branch->Right();
118 }
119
120
121 inline const NodeB& NodeB::LeftBranch() const
122 {
123 if(m_left_branch==NULL)
124 {
125 throw ZErrorMessage(ZErrorNullPointer, __FILE__, __LINE__, __FUNCTION__);
126 }
127 return *m_left_branch;
128 }
129
130
131 inline const NodeB& NodeB::RightBranch() const
132 {
133 if(m_right_branch==NULL)
134 {
135 throw ZErrorMessage(ZErrorNullPointer, __FILE__, __LINE__, __FUNCTION__);
136 }
137 return *m_right_branch;
138 }
139
140
141 inline string NodeB::chToString() const
142 {
143 if( m_left < 0 ) return "(-1, " + num2str<Int4>(m_right+1) + ")";
144 if( m_right < 0 ) return "(" + num2str<Int4>(m_left+1) + ", -1)";
145 return "(" + num2str<Int4>(m_left+1) + ", " + num2str<Int4>(m_right+1) + ")";
146 }
147
148 inline void NodeB::swapBranch()
149 {
150 if( m_left == m_right ) return;
151 swap(m_left, m_right);
152 swap(m_left_branch, m_right_branch);
153 }
154
155
156 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26