11 #ifndef SNAKSTRUCT_H_INCLUDED
12 #define SNAKSTRUCT_H_INCLUDED
19 #define TEST_SNAKSTRUCT
35 #include <unordered_map>
59 int isOrderedOnEdge = 0;
64 friend void SpawnArrivedSnaxelsDir(
snake &fullsnake,
snake &partSnake,
const std::vector<int> &isImpact,
int dir);
68 void CalculateTimeStepOnEdge(std::vector<double> &dt, std::vector<bool> &isSnaxDone,
int edgeInd);
69 void DetectImpactOnEdge(std::vector<int> &isImpact, std::vector<bool> &isSnaxDone,
int edgeInd);
72 void ForceArrayReady();
75 snax &operator[](
const int a)
88 mesh *privatesnakemesh = NULL;
89 bool snaxDistanceLimit_conserveShape =
true;
90 bool isSetStepLimit =
false;
92 bool isFlipped =
false;
95 void OrientSurfaceVolume();
96 void OrientEdgeSurface();
106 mesh *snakemesh()
const
108 return this->privatesnakemesh;
111 std::vector<bool> isMeshVertIn;
112 std::vector<double> edgeStepLimit;
115 void displight()
const;
116 bool isready()
const;
120 this->snaxedges.clear();
121 this->snaxsurfs.clear();
122 this->snakeconn.clear();
123 this->isMeshVertIn.clear();
124 this->edgeStepLimit.clear();
125 this->isSetStepLimit =
false;
126 this->isFlipped =
false;
128 void PrepareForUse(
bool needOrder =
true);
129 void Init(
mesh *snakemeshin,
int nSnax,
int nEdge,
int nSurf,
int nVolu);
130 void SetSnakeMesh(
mesh *snakemeshin);
131 void reserve(
int nSnax,
int nEdge,
int nSurf,
int nVolu);
132 inline void GetMaxIndex(
int *nVert,
int *nEdge,
int *nSurf,
int *nVolu)
const;
137 void SetMaxIndexNM();
138 void Concatenate(
const snake &other,
int isInternal = 0);
144 void MakeCompatible_inplace(
snake &other)
const;
146 void ChangeIndices(
int nVert,
int nEdge,
int nSurf,
int nVolu);
147 void ChangeIndicesSnakeMesh(
int nVert,
int nEdge,
int nSurf,
int nVolu);
148 void ForceCloseContainers();
150 void UpdateDistance(
double dt,
double maxDstep = 1.0,
bool scaledStep =
false);
151 void UpdateDistance(
const std::vector<double> &dt,
double maxDstep = 1.0,
bool scaledStep =
false);
152 void CalculateTimeStep(std::vector<double> &dt,
double dtDefault,
double distDefault = 1.0);
153 double SnaxStepLimit(
int snaxSub)
const;
155 void SnaxImpactDetection(std::vector<int> &isImpact);
156 void SnaxAlmostImpactDetection(std::vector<int> &isImpact,
double dDlim);
158 void UpdateCoord(
const std::vector<int> &snaxInds);
160 grid::limits Scale(
const grid::limits &newSize);
167 int FindBlockSnakeMeshVerts(std::vector<int> &vertBlock)
const;
168 void AssignInternalVerts();
169 void CheckConnectivity()
const;
170 void TakeSpawnStep(
int minIndex,
double stepLength);
171 void TakeSmoothSpawnStep(
int minIndex,
double stepLength, std::string smoothStep =
"none");
172 void VertIsIn(
int vertInd,
bool isIn =
true);
173 void VertIsIn(std::vector<int> vertInd,
bool isIn =
true);
174 bool ReturnFlip()
const
179 void read(FILE *fid);
180 void write(FILE *fid)
const;
181 int read(
const char *str);
182 int write(
const char *str)
const;
183 std::vector<double> MoveDirections()
const;
185 void SetSnaxDistanceLimit_conserveShape(
bool in)
187 this->snaxDistanceLimit_conserveShape = in;
204 void disptree(
const mesh &meshin,
int n)
const;
205 void disptree(
const snake &snakein,
int n)
const;
206 double value(
const mesh &meshin)
const
208 return meshin.verts.isearch(this->index)->value(meshin);
214 int KeyParent()
const
218 void ChangeIndices(
int nVert,
int nEdge,
int nSurf,
int nVolu);
219 void ChangeIndicesSnakeMesh(
int nVert,
int nEdge,
int nSurf,
int nVolu);
220 void PrepareForUse(){};
221 #pragma GCC diagnostic push
222 #pragma GCC diagnostic ignored "-Wunused-parameter"
223 bool isready(
bool isInMesh)
const
227 #pragma GCC diagnostic pop
228 void read(FILE *fid);
229 void write(FILE *fid)
const;
230 inline void set(
int index,
double d,
double v,
int fromvert,
int tovert,
int edgeind,
int isfreeze,
int orderedge);
231 void SwitchIndex(
int typeInd,
int oldInd,
int newInd);
232 void TightenConnectivity()
235 void TakeSpawnStep(
snake &snakein,
double stepLength);
236 int CloseToVertex(
bool far =
false)
const
238 return ((d < 0.5) ^ far) ? fromvert : tovert;
240 void ValidateDistance(
snake &snakein);
250 void PrepareForUse();
252 void disptree(
const mesh &meshin,
int n)
const;
253 void disptree(
const snake &snakein,
int n)
const;
254 double value(
const mesh &meshin)
const
256 return meshin.edges.isearch(this->index)->value(meshin);
262 int KeyParent()
const
266 void ChangeIndices(
int nVert,
int nEdge,
int nSurf,
int nVolu);
267 void ChangeIndicesSnakeMesh(
int nVert,
int nEdge,
int nSurf,
int nVolu);
268 #pragma GCC diagnostic push
269 #pragma GCC diagnostic ignored "-Wunused-parameter"
270 bool isready(
bool isInMesh)
const
272 return (normvector.isready());
274 #pragma GCC diagnostic pop
275 void read(FILE *fid);
276 void write(FILE *fid)
const;
277 void SwitchIndex(
int typeInd,
int oldInd,
int newInd);
278 void TightenConnectivity()
288 void PrepareForUse();
290 void disptree(
const mesh &meshin,
int n)
const;
291 void disptree(
const snake &snakein,
int n)
const;
292 double value(
const mesh &meshin)
const
294 return meshin.surfs.isearch(this->index)->value(meshin);
300 int KeyParent()
const
304 void ChangeIndices(
int nVert,
int nEdge,
int nSurf,
int nVolu);
305 void ChangeIndicesSnakeMesh(
int nVert,
int nEdge,
int nSurf,
int nVolu);
306 #pragma GCC diagnostic push
307 #pragma GCC diagnostic ignored "-Wunused-parameter"
308 bool isready(
bool isInMesh)
const
310 return (normvector.isready());
312 #pragma GCC diagnostic pop
313 void read(FILE *fid);
314 void write(FILE *fid)
const;
315 void SwitchIndex(
int typeInd,
int oldInd,
int newInd);
316 void TightenConnectivity()
322 double SnaxImpactDt(
const snax &snax1,
const snax &snax2);
323 int CompareSnakeInternalStatus(
const std::vector<bool> &thisVec,
bool thisFlipped,
const std::vector<bool> &otherVec,
326 int Test_SnakeStructures();
331 int Test_snakeinit_random();
332 int Test_snakeinit_unit();
333 int Test_snakeinit_unitnoreflect();
334 int Test_snakeinit_random_short();
335 int Test_snakeinit_unit_short();
336 int Test_snakeinit_unitnoreflect_short();
337 int Test_snakeinit_MC();
338 int Test_snakeOrderEdges();
339 int Test_snakeinitflat();
340 void Test_stepalgo(
snake &testSnake, std::vector<int> &isImpact);
341 void Test_stepalgo_mergeclean(
snake &testSnake, std::vector<int> &isImpact);
346 inline void snax::set(
int indexin,
double din,
double vin,
int fromvertin,
int tovertin,
int edgeindin,
int isfreezein,
352 fromvert = fromvertin;
355 isfreeze = isfreezein;
356 orderedge = orderedgein;
Provide std::vector container with hashed index mapping.
Handles the use and norm of a vector for which the norm and the unit value might be needed.
/Abstract class to ensure mesh interfaces are correct.
void SetEdgeStepLimits()
Sets the relative edge step limits.
Provides all the mesh tools used for the generation of 3D grids and geometries.