This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
forked from yayahjb/ncdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Follower_main.cpp
executable file
·255 lines (212 loc) · 8.33 KB
/
Follower_main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// D7_Follower.cpp : Defines the entry point for the console application.
//
#include <algorithm>
#include <ctime>
#include <map>
#include <fstream>
#include <iostream>
#include <utility>
#include "LRL_Cell.h"
#include "CreateFileName.h"
#include "D6.h"
#include "G6.h"
#include "D7.h"
#include "B4.h"
#include "FileWriter.h"
#include "Follow.h"
#include "Follower.h"
#include "FollowerConstants.h"
#include "FollowerTools.h"
#include "MapBoundaryStrings2Colors.h"
#include "MaximaTools.h"
#include "ProjectorTools.h"
#include "ReadCellData.h"
#include "ReadGlobalData.h"
#include "Reducer.h"
#include "ReportTools.h"
#include "SuperFastHash.h"
#include "SVG_Writer.h"
#include "G6.h"
#include "MatD7.h"
template<typename TVEC, typename TMAT>
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
bool WalkFromOnePointToAnother( const TVEC& v1, const TVEC& v2, const size_t nSteps, const std::string& s_BaseSVG_FileName, MapBoundaryStrings2Colors& colorMap, const size_t goodCellCount )
/*-------------------------------------------------------------------------------------*/
{
Follow<TVEC,TMAT> follow( v1, v2 );
const std::clock_t start = std::clock();
follow.SetStepCount( nSteps )
.SetWhichComponentsToPlot( FollowerConstants::globalWhichComponentsToPlot.first, FollowerConstants::globalWhichComponentsToPlot.second )
.Procession( );
follow.SetTime2ComputeFrame( std::clock() - start );
// a tiny diagonal means that the probe is essentially reduced before we start
// just dump those
if ( follow.GetCirclePlotDiagonal( ) < 1.0E-3 )
{
std::cout << "rejected because of tiny diagonal " << follow.GetCirclePlotDiagonal( ) << std::endl;
return( false );
}
else
{
//const std::list<double> distances(follow.GetDistances());
const std::list<double> distances(follow.GetDeloneDistances());
std::vector<Glitch<TVEC> > glitches;
glitches = follow.DetermineIfSomeDeltaIsTooLarge( distances ); // return the index for first glitch
if ( FollowerConstants::globalPrintAllDistanceData || ! glitches.empty( ) )
{
FileWriter<TVEC,TMAT>( s_BaseSVG_FileName + ".txt", follow, glitches ).Write();
//#define DisableForHJB
#ifndef DisableForHJB
//Create a file name for each different SVG file
const std::string s_SVG_FileName = ToString( s_BaseSVG_FileName, goodCellCount, ".svg" );
const std::vector<triple<double,double,double> > angles( follow.GetLinesFromAngles( ) );
const std::vector<int> rejectedFrames;
SVG_Writer<TVEC, TMAT>( s_SVG_FileName, follow, 0, colorMap, glitches, rejectedFrames, 0 );
if ( FollowerConstants::globalFollowerMode == FollowerConstants::globalWeb )
exit( 19191 );
#endif
}
}
return( true );
}
template<typename TVEC, typename TMAT>
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
size_t ProbeOneRegion( const CellInputData& probe, const size_t nSteps, const std::string& sBaseFileName )
/*-------------------------------------------------------------------------------------*/
{
G6 vR;
MapBoundaryStrings2Colors colorMap;
Mat66 m;
size_t goodCellCount = 0;
for ( int iloop=0; iloop<FollowerConstants::globalNumberOfTrialsToAttempt; ++iloop )
{
const G6 v1( ReadGlobalData::GeneratePerturbation( G6(probe.GetCell().Cell2V6()) ) );
m.Eye();
//const bool bTestReduce(Delone::Delone(v1, m, vR, 0.0)); lca Delone code
const bool bTestReduce(Reducer::Reduce(v1, m, vR, 0.0));
if ( bTestReduce && ! (m==Mat66().Eye()) )
{
const bool bTestWalk = WalkFromOnePointToAnother<TVEC,TMAT>( TVEC(v1), TVEC(vR), nSteps, sBaseFileName, colorMap, goodCellCount );
if ( bTestWalk ) ++goodCellCount;
} else if( ! bTestReduce ) {
//std::cout << "Delone failed " << v1 << std::endl;
std::cout << "Reduce failed " << v1 << std::endl;
}
}
return( goodCellCount );
}
template<typename TVEC, typename TMAT>
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
int ProbeOneRegion( const G6& probe, const int nSteps, const std::string& sBaseFileName )
/*-------------------------------------------------------------------------------------*/
{
G6 vR;
MapBoundaryStrings2Colors colorMap;
Mat66 m;
long goodCellCount = 0;
for ( int iloop=0; iloop<FollowerConstants::globalNumberOfTrialsToAttempt; ++iloop )
{
const G6 v1( ReadGlobalData::GeneratePerturbation( probe ) );
m.Eye();
//const bool bTestReduce( Delone::Delone( v1, m, vR, 0.0 ) );
const bool bTestReduce(Reducer::Reduce(v1, m, vR, 0.0));
if ( bTestReduce && ! (m==Mat66().Eye()) )
{
const bool bTestWalk = WalkFromOnePointToAnother<TVEC,TMAT>( v1, vR, nSteps, sBaseFileName, colorMap, goodCellCount );
if ( bTestWalk ) ++goodCellCount;
} else if( ! bTestReduce ) {
//std::cout << "Delone failed " << v1 << std::endl;
std::cout << "Reduce failed " << v1 << std::endl;
}
}
return( goodCellCount );
}
//
//void TransformAndTestVector( const D7& testvec, const D7_Subboundary& sb ) {
// const D7 transformedRandom = sb.GetTransform( ) * testvec;
// const std::pair<int, std::string> id = D7_IdentifyNearbyBoundaries( transformedRandom, 10 );
// boundarymap[sb.GetName( )] = std::make_pair( sb.GetName( ) + " transforms to " + id.second, "" );
//}
template<typename T>
void TestToType() {
T a, b;
if (a.size() == 6) {
a = T("10 11 12 90 90 90"); // from string
b = T(G6("10 10 10 10 10 10 ")); // from G6
}
else if (a.size() == 7)
{
a = T("10 11 12 13 14 15 16"); // from string
b = T("10 10 10 60 30 30 30 "); // from G6
}
else if (a.size() == 4)
{
a = T(LRL_Cell("10 11 12 90 90 90"));
b = T(G6("10 10 10 10 10 10 "));
}
else
{
throw;
}
D7 d7(b);
T c(d7); // from D7
T d(c); // from LRL_Cell
D6 ds("5 5 5 -20 -20 -20");
T e(ds); // from DeloneScalars (D6)
B4 dt(G6("10 10 10 10 10 10 "));
T f(dt);
std::cout << a << std::endl;
std::cout << b << std::endl;
std::cout << c << std::endl;
std::cout << d << std::endl;
std::cout << e << std::endl;
std::cout << f << std::endl;
std::cout << std::endl;
std::cout << ToString(a) << std::endl;
std::cout << ToString(b) << std::endl;
std::cout << ToString(c) << std::endl;
std::cout << ToString(d) << std::endl;
std::cout << ToString(e) << std::endl;
std::cout << ToString(f) << std::endl;
}
int main( int argc, char* argv [ ] ) {
//LRL_Cell c;
//c[0];
//std::cout << "FOR CELL " << std::endl;
//TestToType<LRL_Cell>();
//std::cout << std::endl << std::endl;
//std::cout << "FOR G6 " << std::endl;
//TestToType<G6>();
//std::cout << std::endl << std::endl;
//std::cout << "FOR D7 " << std::endl;
//TestToType<D7>();
//std::cout << std::endl << std::endl;
//std::cout << "FOR DeloneScalars " << std::endl;
//TestToType<D6>();
//std::cout << std::endl << std::endl;
//std::cout << "FOR B4 " << std::endl;
//TestToType<B4>();
//D7_BoundaryList bl;
ReadGlobalData();
std::vector<CellInputData> celldata;
std::string lattice( "" );
while ( lattice != "EOF" ) {
ReadCellData rcd;
lattice = rcd.GetLattice( );
if ( lattice != "EOF" && ! lattice.empty() ) {
rcd.SetVarietyRange( std::make_pair( 0, 23 ) );
celldata.push_back( rcd );
}
}
//for ( unsigned int icell=0; icell<celldata.size( ); ++icell ) {
size_t cellcount = 0;
std::vector<CellInputData>::const_iterator it = celldata.begin( );
for ( ; it!=celldata.end( ); ++it ) {
const std::string sBaseFileName =
ToString( CreateFileName::Create( FollowerConstants::globalFileNamePrefix, ToString( cellcount) + "_" ) );
++cellcount;
size_t goodCellCount = ProbeOneRegion<D7,MatD7>( *it, FollowerConstants::globalStepsPerFrame, sBaseFileName );
}
//}
return 0;
}