MRArbGrad 4.0.0__tar.gz → 4.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0/MRArbGrad.egg-info}/PKG-INFO +1 -1
- {mrarbgrad-4.0.0/MRArbGrad.egg-info → mrarbgrad-4.1.0}/PKG-INFO +1 -1
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/Function.py +26 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/__init__.py +1 -1
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/main.cpp +43 -7
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/MrTraj.h +1 -1
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/VDSpiral.h +10 -9
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/Yarnball.h +8 -8
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/utility/global.h +5 -2
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/utility/v3.cpp +78 -1
- mrarbgrad-4.1.0/mrarbgrad_src/ext/utility/v3.h +72 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/pyproject.toml +1 -1
- mrarbgrad-4.0.0/mrarbgrad_src/ext/utility/v3.h +0 -156
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/LICENSE +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/MANIFEST.in +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/MRArbGrad.egg-info/SOURCES.txt +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/MRArbGrad.egg-info/dependency_links.txt +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/MRArbGrad.egg-info/requires.txt +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/MRArbGrad.egg-info/top_level.txt +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/README.md +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/example/example_BuiltInTraj.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/example/example_ExternalFunction2D.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/example/example_ExternalSamples2D.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/example/example_ExternalSamples3D.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/Utility.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/mag/Mag.cpp +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/mag/Mag.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/Cones.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/MrTraj_2D.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/Rosette.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/Seiffert.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/Shell3d.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/Spiral.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/traj/TrajFunc.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/utility/Intp.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/utility/LinIntp.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/utility/SplineIntp.h +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/ext/utility/global.cpp +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/trajfunc/__init__.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/mrarbgrad_src/trajfunc/main.py +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/setup.cfg +0 -0
- {mrarbgrad-4.0.0 → mrarbgrad-4.1.0}/setup.py +0 -0
|
@@ -376,3 +376,29 @@ def setMagSFS(x): ext.setMagSFS(x)
|
|
|
376
376
|
def setMagGradRep(x): ext.setMagGradRep(x)
|
|
377
377
|
def setMagTrajRep(x): ext.setMagTrajRep(x)
|
|
378
378
|
def setDbgPrint(x): ext.setDbgPrint(x)
|
|
379
|
+
|
|
380
|
+
def loadF64(hdr:str, bin:str) -> list[NDArray]:
|
|
381
|
+
"""
|
|
382
|
+
load saved vector file (float64)
|
|
383
|
+
|
|
384
|
+
Args:
|
|
385
|
+
hdr (str): header (hdr) file path
|
|
386
|
+
bin (str): bin file path
|
|
387
|
+
|
|
388
|
+
Returns:
|
|
389
|
+
list[NDArray]: list of loaded array
|
|
390
|
+
"""
|
|
391
|
+
return ext.loadF64(str(hdr), str(bin))
|
|
392
|
+
|
|
393
|
+
def loadF32(hdr:str, bin:str) -> list[NDArray]:
|
|
394
|
+
"""
|
|
395
|
+
load saved vector file (float32)
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
hdr (str): header (hdr) file path
|
|
399
|
+
bin (str): bin file path
|
|
400
|
+
|
|
401
|
+
Returns:
|
|
402
|
+
list[NDArray]: list of loaded array
|
|
403
|
+
"""
|
|
404
|
+
return ext.loadF32(str(hdr), str(bin))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from .Function import calGrad4ExFunc, calGrad4ExSamp
|
|
2
2
|
from .Function import getG_Cones, getG_Rosette, getG_Rosette_Trad, getG_Seiffert, getG_Shell3d, getG_Spiral, getG_VDSpiral, getG_VDSpiral_RT, getG_Yarnball, getG_Yarnball_RT
|
|
3
|
-
from .Function import setSolverMtg, setTrajRev, setGoldAng, setShuf, setMaxG0, setMaxG1, setMagOverSamp, setMagSFS, setMagGradRep, setMagTrajRep, setDbgPrint
|
|
3
|
+
from .Function import setSolverMtg, setTrajRev, setGoldAng, setShuf, setMaxG0, setMaxG1, setMagOverSamp, setMagSFS, setMagGradRep, setMagTrajRep, setDbgPrint, loadF64, loadF32
|
|
4
4
|
from .Utility import _calDiaphony, rotate, _calJacElip, _calCompElipInt, _calSphFibPt, cvtGrad2Traj, getGoldang, getGoldrat, rand3d, gradClip
|
|
5
5
|
|
|
6
6
|
from . import trajfunc
|
|
@@ -137,7 +137,7 @@ bool inline checkNarg(i64 nArg, i64 nArgExp)
|
|
|
137
137
|
{
|
|
138
138
|
if (nArg != nArgExp)
|
|
139
139
|
{
|
|
140
|
-
printf("wrong num. of arg, narg=%ld, %ld expected\n", nArg, nArgExp);
|
|
140
|
+
printf("wrong num. of arg, narg=%ld, %ld expected\n", (long)nArg, (long)nArgExp);
|
|
141
141
|
abort();
|
|
142
142
|
return false;
|
|
143
143
|
}
|
|
@@ -389,7 +389,7 @@ bool getG(MrTraj* pmt, vv3* pvv3M0PE, vvv3* pvvv3GRO)
|
|
|
389
389
|
pvvv3GRO->resize(nAcq);
|
|
390
390
|
|
|
391
391
|
bool& enShuf = gMain_enShuffle;
|
|
392
|
-
vi64 vi64ShufSeq; MrTraj::
|
|
392
|
+
vi64 vi64ShufSeq; MrTraj::genPermTab(&vi64ShufSeq, nAcq);
|
|
393
393
|
for (i64 i = 0; i < nAcq; ++i)
|
|
394
394
|
{
|
|
395
395
|
i64 _i = enShuf?vi64ShufSeq[i]:i;
|
|
@@ -707,11 +707,46 @@ PyObject* setDbgPrint(PyObject* self, PyObject* const* args, Py_ssize_t narg)
|
|
|
707
707
|
return Py_None;
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
-
|
|
711
|
-
PyObject* getTestVal(PyObject* self, PyObject* const* args, Py_ssize_t narg)
|
|
710
|
+
PyObject* loadF64(PyObject* self, PyObject* const* args, Py_ssize_t narg)
|
|
712
711
|
{
|
|
713
|
-
checkNarg(narg,
|
|
714
|
-
|
|
712
|
+
checkNarg(narg, 2);
|
|
713
|
+
const char* strHdr = PyUnicode_AsUTF8(args[0]);
|
|
714
|
+
const char* strBin = PyUnicode_AsUTF8(args[1]);
|
|
715
|
+
typedef std::list<vv3> lvv3;
|
|
716
|
+
FILE* fHdr = fopen(strHdr, "r");
|
|
717
|
+
FILE* fBin = fopen(strHdr, "rb");
|
|
718
|
+
|
|
719
|
+
lvv3 lvv3Data;
|
|
720
|
+
bool ret; vv3 vv3Data;
|
|
721
|
+
while (1)
|
|
722
|
+
{
|
|
723
|
+
ret = v3::loadF64(fHdr, fBin, &vv3Data);
|
|
724
|
+
if (vv3Data.empty() || !ret) break;
|
|
725
|
+
lvv3Data.push_back(vv3Data);
|
|
726
|
+
}
|
|
727
|
+
vvv3 vvv3Data(lvv3Data.begin(), lvv3Data.end());
|
|
728
|
+
Py_BuildValue("%O", cvtVvv3toList(vvv3Data));
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
PyObject* loadF32(PyObject* self, PyObject* const* args, Py_ssize_t narg)
|
|
732
|
+
{
|
|
733
|
+
checkNarg(narg, 2);
|
|
734
|
+
const char* strHdr = PyUnicode_AsUTF8(args[0]);
|
|
735
|
+
const char* strBin = PyUnicode_AsUTF8(args[1]);
|
|
736
|
+
typedef std::list<vv3> lvv3;
|
|
737
|
+
FILE* fHdr = fopen(strHdr, "r");
|
|
738
|
+
FILE* fBin = fopen(strHdr, "rb");
|
|
739
|
+
|
|
740
|
+
lvv3 lvv3Data;
|
|
741
|
+
bool ret; vv3 vv3Data;
|
|
742
|
+
while (1)
|
|
743
|
+
{
|
|
744
|
+
ret = v3::loadF32(fHdr, fBin, &vv3Data);
|
|
745
|
+
if (vv3Data.empty() || !ret) break;
|
|
746
|
+
lvv3Data.push_back(vv3Data);
|
|
747
|
+
}
|
|
748
|
+
vvv3 vvv3Data(lvv3Data.begin(), lvv3Data.end());
|
|
749
|
+
Py_BuildValue("%O", cvtVvv3toList(vvv3Data));
|
|
715
750
|
}
|
|
716
751
|
|
|
717
752
|
static PyMethodDef aMeth[] =
|
|
@@ -734,12 +769,13 @@ static PyMethodDef aMeth[] =
|
|
|
734
769
|
{"setShuf", (PyCFunction)setShuf, METH_FASTCALL, ""},
|
|
735
770
|
{"setMaxG0", (PyCFunction)setMaxG0, METH_FASTCALL, ""},
|
|
736
771
|
{"setMaxG1", (PyCFunction)setMaxG1, METH_FASTCALL, ""},
|
|
737
|
-
{"getTestVal", (PyCFunction)getTestVal, METH_FASTCALL, ""},
|
|
738
772
|
{"setMagOverSamp", (PyCFunction)setMagOverSamp, METH_FASTCALL, ""},
|
|
739
773
|
{"setMagSFS", (PyCFunction)setMagSFS, METH_FASTCALL, ""},
|
|
740
774
|
{"setMagGradRep", (PyCFunction)setMagGradRep, METH_FASTCALL, ""},
|
|
741
775
|
{"setMagTrajRep", (PyCFunction)setMagTrajRep, METH_FASTCALL, ""},
|
|
742
776
|
{"setDbgPrint", (PyCFunction)setDbgPrint, METH_FASTCALL, ""},
|
|
777
|
+
{"loadF64", (PyCFunction)loadF64, METH_FASTCALL, ""},
|
|
778
|
+
{"loadF32", (PyCFunction)loadF32, METH_FASTCALL, ""},
|
|
743
779
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
|
744
780
|
};
|
|
745
781
|
|
|
@@ -78,14 +78,13 @@ public:
|
|
|
78
78
|
{
|
|
79
79
|
m_kRhoPhi0 = kRhoPhi0;
|
|
80
80
|
m_kRhoPhi1 = kRhoPhi1;
|
|
81
|
-
|
|
82
|
-
m_dRotAng = 2e0*M_PI/
|
|
83
|
-
|
|
84
|
-
m_nAcq = m_nRot;
|
|
81
|
+
m_nAcq = calNRot(kRhoPhi1, objGeoPara.nPix);
|
|
82
|
+
m_dRotAng = 2e0*M_PI/m_nAcq;
|
|
83
|
+
genPermTab(&m_vi64PermTab, m_nAcq);
|
|
85
84
|
|
|
86
85
|
VDSpiral_TrajFunc tf(m_kRhoPhi0, m_kRhoPhi1, 0);
|
|
87
|
-
vv3 vv3GRO; calGrad(NULL, &vv3GRO, NULL, tf, m_objGradPara,
|
|
88
|
-
m_nSampMax = vv3GRO.size();
|
|
86
|
+
vv3 vv3GRO; calGrad(NULL, &vv3GRO, NULL, tf, m_objGradPara, 4);
|
|
87
|
+
m_nSampMax = vv3GRO.size() + 0;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
virtual ~VDSpiral_RT()
|
|
@@ -95,7 +94,9 @@ public:
|
|
|
95
94
|
{
|
|
96
95
|
bool ret = true;
|
|
97
96
|
ASSERT(iAcq >= 0);
|
|
98
|
-
|
|
97
|
+
i64 iPhi = m_vi64PermTab[iAcq%m_nAcq];
|
|
98
|
+
f64 phi = iPhi*m_dRotAng;
|
|
99
|
+
VDSpiral_TrajFunc tf(m_kRhoPhi0, m_kRhoPhi1, phi);
|
|
99
100
|
ret &= calGrad(pv3M0PE, pvv3GRO, NULL, tf, m_objGradPara, 2);
|
|
100
101
|
return ret;
|
|
101
102
|
}
|
|
@@ -103,6 +104,6 @@ public:
|
|
|
103
104
|
protected:
|
|
104
105
|
f64 m_kRhoPhi0;
|
|
105
106
|
f64 m_kRhoPhi1;
|
|
106
|
-
|
|
107
|
-
vi64
|
|
107
|
+
f64 m_dRotAng;
|
|
108
|
+
vi64 m_vi64PermTab;
|
|
108
109
|
};
|
|
@@ -115,12 +115,12 @@ public:
|
|
|
115
115
|
m_kRhoPhi = kRhoPhi;
|
|
116
116
|
m_nRot = calNRot(kRhoPhi, objGeoPara.nPix);
|
|
117
117
|
m_dRotAng = 2e0*M_PI/m_nRot;
|
|
118
|
-
genRandIdx(&m_vi64Idx, m_nRot);
|
|
119
118
|
m_nAcq = m_nRot*m_nRot;
|
|
119
|
+
genPermTab(&m_vi64PermTab, m_nAcq);
|
|
120
120
|
|
|
121
121
|
Yarnball_TrajFunc tf(m_kRhoPhi, M_PI/2e0, 0);
|
|
122
|
-
vv3 vv3GRO; calGrad(NULL, &vv3GRO, NULL, tf, m_objGradPara,
|
|
123
|
-
m_nSampMax = vv3GRO.size();
|
|
122
|
+
vv3 vv3GRO; calGrad(NULL, &vv3GRO, NULL, tf, m_objGradPara, 4);
|
|
123
|
+
m_nSampMax = vv3GRO.size() + 1; // 1 for redundance
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
virtual ~Yarnball_RT()
|
|
@@ -130,10 +130,10 @@ public:
|
|
|
130
130
|
{
|
|
131
131
|
bool ret = true;
|
|
132
132
|
ASSERT(iAcq >= 0);
|
|
133
|
-
i64 iPhi = iAcq%m_nRot;
|
|
134
|
-
i64 iTht = iAcq/m_nRot
|
|
135
|
-
f64 phi = m_dRotAng*
|
|
136
|
-
f64 tht = m_dRotAng*
|
|
133
|
+
i64 iPhi = m_vi64PermTab[iAcq%m_nAcq]%m_nRot;
|
|
134
|
+
i64 iTht = m_vi64PermTab[iAcq%m_nAcq]/m_nRot;
|
|
135
|
+
f64 phi = m_dRotAng*iPhi;
|
|
136
|
+
f64 tht = m_dRotAng*iTht;
|
|
137
137
|
Yarnball_TrajFunc tf(m_kRhoPhi, tht, phi);
|
|
138
138
|
ret &= calGrad(pv3M0PE, pvv3GRO, NULL, tf, m_objGradPara, 2);
|
|
139
139
|
return ret;
|
|
@@ -142,5 +142,5 @@ public:
|
|
|
142
142
|
protected:
|
|
143
143
|
f64 m_kRhoPhi;
|
|
144
144
|
i64 m_nRot; f64 m_dRotAng;
|
|
145
|
-
vi64
|
|
145
|
+
vi64 m_vi64PermTab;
|
|
146
146
|
};
|
|
@@ -24,6 +24,10 @@ typedef std::vector<i64> vi64;
|
|
|
24
24
|
typedef std::vector<f64> vf64;
|
|
25
25
|
typedef std::list<i64> li64;
|
|
26
26
|
typedef std::list<f64> lf64;
|
|
27
|
+
typedef std::vector<i32> vi32;
|
|
28
|
+
typedef std::vector<f32> vf32;
|
|
29
|
+
typedef std::list<i32> li32;
|
|
30
|
+
typedef std::list<f32> lf32;
|
|
27
31
|
|
|
28
32
|
typedef std::string str;
|
|
29
33
|
|
|
@@ -49,7 +53,7 @@ inline T gcd(T x, T y)
|
|
|
49
53
|
#define GOLDRAT (1.6180339887498949e0) // ((1e0+std::sqrt(5e0))/2e0)
|
|
50
54
|
#define GOLDANG (2.3999632297286531e0) // ((3e0-std::sqrt(5e0))*M_PI)
|
|
51
55
|
|
|
52
|
-
#define PRINT(X) {printf("%s: %ld\n", #X, (
|
|
56
|
+
#define PRINT(X) {printf("%s: %ld\n", #X, (long)(X));}
|
|
53
57
|
#define PRINT_F(X) {printf("%s: %.3lf\n", #X, (f64)(X));}
|
|
54
58
|
#define PRINT_E(X) {printf("%s: %.3e\n", #X, (f64)(X));}
|
|
55
59
|
#define ASSERT(X) {if(!(X)) throw std::runtime_error(#X);}
|
|
@@ -62,4 +66,3 @@ inline T gcd(T x, T y)
|
|
|
62
66
|
if (glob_enDbgPrint) printf("Elapsed time: %.3lf ms\n", 1e3*cTick/CLOCKS_PER_SEC);
|
|
63
67
|
|
|
64
68
|
extern bool glob_enDbgPrint;
|
|
65
|
-
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "v3.h"
|
|
2
2
|
#include <array>
|
|
3
|
+
#include <cinttypes>
|
|
3
4
|
|
|
4
5
|
v3::v3() :x(0e0), y(0e0), z(0e0) {}
|
|
5
6
|
v3::v3(f64 _) :x(_), y(_), z(_) {}
|
|
@@ -362,4 +363,80 @@ v3 v3::axisroll(const v3& v3In, i64 nShift)
|
|
|
362
363
|
break;
|
|
363
364
|
}
|
|
364
365
|
return v3Ot;
|
|
365
|
-
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
bool v3::saveF64(FILE* pfHdr, FILE* pfBin, const vv3& vv3Data)
|
|
369
|
+
{
|
|
370
|
+
bool ret = true;
|
|
371
|
+
i64 lenData = vv3Data.size();
|
|
372
|
+
fprintf(pfHdr, "float64[%ld][3];\n", (long)lenData);
|
|
373
|
+
|
|
374
|
+
f64* bufFile = new f64[lenData*3];
|
|
375
|
+
for(i64 i=0; i<(i64)lenData; ++i)
|
|
376
|
+
{
|
|
377
|
+
for(i64 j=0; j<3; ++j)
|
|
378
|
+
{ bufFile[3*i+j] = (f64)vv3Data[i][j]; }
|
|
379
|
+
}
|
|
380
|
+
ret &= (i64)fwrite(bufFile, sizeof(f64), lenData*3, pfBin)==lenData*3;
|
|
381
|
+
delete[] bufFile;
|
|
382
|
+
return ret;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
bool v3::loadF64(FILE* pfHdr, FILE* pfBin, vv3* pvv3Data)
|
|
386
|
+
{
|
|
387
|
+
bool ret = true;
|
|
388
|
+
i64 lenData = 0;
|
|
389
|
+
pvv3Data->clear();
|
|
390
|
+
int nRead = fscanf(pfHdr, "float64[%" SCNi64 "][3];\n", &lenData);
|
|
391
|
+
if (nRead==EOF) return true; // EOF
|
|
392
|
+
else if (nRead!=1) return false;
|
|
393
|
+
pvv3Data->resize(lenData);
|
|
394
|
+
|
|
395
|
+
f64* bufFile = new f64[lenData*3];
|
|
396
|
+
ret &= (i64)fread(bufFile, sizeof(f64), lenData*3, pfBin)==lenData*3;
|
|
397
|
+
for(i64 i=0; i<(i64)pvv3Data->size(); ++i)
|
|
398
|
+
{
|
|
399
|
+
for(i64 j=0; j<3; ++j)
|
|
400
|
+
{ (*pvv3Data)[i][j] = (f64)bufFile[3*i+j]; }
|
|
401
|
+
}
|
|
402
|
+
delete[] bufFile;
|
|
403
|
+
return ret;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
bool v3::saveF32(FILE* pfHdr, FILE* pfBin, const vv3& vv3Data)
|
|
407
|
+
{
|
|
408
|
+
bool ret = true;
|
|
409
|
+
i64 lenData = vv3Data.size();
|
|
410
|
+
fprintf(pfHdr, "float32[%ld][3];\n", (long)lenData);
|
|
411
|
+
|
|
412
|
+
f32* bufFile = new f32[lenData*3];
|
|
413
|
+
for(i64 i=0; i<(i64)lenData; ++i)
|
|
414
|
+
{
|
|
415
|
+
for(i64 j=0; j<3; ++j)
|
|
416
|
+
{ bufFile[3*i+j] = (f32)vv3Data[i][j]; }
|
|
417
|
+
}
|
|
418
|
+
ret &= (i64)fwrite(bufFile, sizeof(f32), lenData*3, pfBin)==lenData*3;
|
|
419
|
+
delete[] bufFile;
|
|
420
|
+
return ret;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
bool v3::loadF32(FILE* pfHdr, FILE* pfBin, vv3* pvv3Data)
|
|
424
|
+
{
|
|
425
|
+
bool ret = true;
|
|
426
|
+
i64 lenData = 0;
|
|
427
|
+
pvv3Data->clear();
|
|
428
|
+
int nRead = fscanf(pfHdr, "float32[%" SCNi64 "][3];\n", &lenData);
|
|
429
|
+
if (nRead==EOF) return true; // EOF
|
|
430
|
+
else if (nRead!=1) return false;
|
|
431
|
+
pvv3Data->resize(lenData);
|
|
432
|
+
|
|
433
|
+
f32* bufFile = new f32[lenData*3];
|
|
434
|
+
ret &= (i64)fread(bufFile, sizeof(f32), lenData*3, pfBin)==lenData*3;
|
|
435
|
+
for(i64 i=0; i<(i64)pvv3Data->size(); ++i)
|
|
436
|
+
{
|
|
437
|
+
for(i64 j=0; j<3; ++j)
|
|
438
|
+
{ (*pvv3Data)[i][j] = (f64)bufFile[3*i+j]; }
|
|
439
|
+
}
|
|
440
|
+
delete[] bufFile;
|
|
441
|
+
return ret;
|
|
442
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cmath>
|
|
4
|
+
#include <list>
|
|
5
|
+
#include <array>
|
|
6
|
+
#include "global.h"
|
|
7
|
+
|
|
8
|
+
class v3;
|
|
9
|
+
|
|
10
|
+
typedef std::vector<v3> vv3;
|
|
11
|
+
typedef std::vector<vv3> vvv3;
|
|
12
|
+
typedef std::list<v3> lv3;
|
|
13
|
+
|
|
14
|
+
class v3
|
|
15
|
+
{
|
|
16
|
+
public:
|
|
17
|
+
f64 x, y, z;
|
|
18
|
+
|
|
19
|
+
v3();
|
|
20
|
+
v3(f64 _);
|
|
21
|
+
v3(f64 x, f64 y, f64 z);
|
|
22
|
+
~v3();
|
|
23
|
+
v3 operator+(const v3 &rhs) const;
|
|
24
|
+
v3& operator+=(const v3 &rhs);
|
|
25
|
+
v3 operator+(const f64 &rhs) const;
|
|
26
|
+
v3& operator+=(const f64 &rhs);
|
|
27
|
+
v3 operator-(const v3 &rhs) const;
|
|
28
|
+
v3& operator-=(const v3 &rhs);
|
|
29
|
+
v3 operator-(const f64 &rhs) const;
|
|
30
|
+
v3& operator-=(const f64 &rhs);
|
|
31
|
+
v3 operator*(const v3 &rhs) const;
|
|
32
|
+
v3& operator*=(const v3 &rhs);
|
|
33
|
+
v3 operator*(const f64 &rhs) const;
|
|
34
|
+
v3& operator*=(const f64 &rhs);
|
|
35
|
+
v3 operator/(const v3 &rhs) const;
|
|
36
|
+
v3& operator/=(const v3 &rhs);
|
|
37
|
+
v3 operator/(const f64 &rhs) const;
|
|
38
|
+
v3& operator/=(const f64 &rhs);
|
|
39
|
+
bool operator==(const v3 &rhs) const;
|
|
40
|
+
bool operator!=(const v3 &rhs) const;
|
|
41
|
+
f64& operator[](i64 idx);
|
|
42
|
+
f64 operator[](i64 idx) const;
|
|
43
|
+
static f64 norm(const v3& v3In);
|
|
44
|
+
static v3 cross(const v3& v3In0, const v3& v3In1);
|
|
45
|
+
static f64 inner(const v3& v3In0, const v3& v3In1);
|
|
46
|
+
static v3 pow(const v3& v3In, f64 exp);
|
|
47
|
+
static bool rotate
|
|
48
|
+
(
|
|
49
|
+
v3* pv3Dst,
|
|
50
|
+
int iAx, f64 ang,
|
|
51
|
+
const v3& v3Src
|
|
52
|
+
);
|
|
53
|
+
static bool rotate
|
|
54
|
+
(
|
|
55
|
+
vv3* pvv3Dst,
|
|
56
|
+
int iAx, f64 ang,
|
|
57
|
+
const vv3& vv3Src
|
|
58
|
+
);
|
|
59
|
+
static bool rotate
|
|
60
|
+
(
|
|
61
|
+
lv3* plv3Dst,
|
|
62
|
+
int iAx, f64 ang,
|
|
63
|
+
const lv3& lv3Src
|
|
64
|
+
);
|
|
65
|
+
static v3 axisroll(const v3& v3In, i64 lShift);
|
|
66
|
+
static bool saveF64(FILE* pfHdr, FILE* pfBin, const vv3& vv3Data);
|
|
67
|
+
static bool loadF64(FILE* pfHdr, FILE* pfBin, vv3* pvv3Data);
|
|
68
|
+
static bool saveF32(FILE* pfHdr, FILE* pfBin, const vv3& vv3Data);
|
|
69
|
+
static bool loadF32(FILE* pfHdr, FILE* pfBin, vv3* pvv3Data);
|
|
70
|
+
private:
|
|
71
|
+
static bool genRotMat(std::array<v3,3>* pav3RotMat, int iAx, f64 ang);
|
|
72
|
+
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <cmath>
|
|
4
|
-
#include <list>
|
|
5
|
-
#include <array>
|
|
6
|
-
#include "global.h"
|
|
7
|
-
|
|
8
|
-
class v3;
|
|
9
|
-
|
|
10
|
-
typedef std::vector<v3> vv3;
|
|
11
|
-
typedef std::vector<vv3> vvv3;
|
|
12
|
-
typedef std::list<v3> lv3;
|
|
13
|
-
|
|
14
|
-
class v3
|
|
15
|
-
{
|
|
16
|
-
public:
|
|
17
|
-
f64 x, y, z;
|
|
18
|
-
|
|
19
|
-
v3();
|
|
20
|
-
v3(f64 _);
|
|
21
|
-
v3(f64 x, f64 y, f64 z);
|
|
22
|
-
~v3();
|
|
23
|
-
v3 operator+(const v3 &rhs) const;
|
|
24
|
-
v3& operator+=(const v3 &rhs);
|
|
25
|
-
v3 operator+(const f64 &rhs) const;
|
|
26
|
-
v3& operator+=(const f64 &rhs);
|
|
27
|
-
v3 operator-(const v3 &rhs) const;
|
|
28
|
-
v3& operator-=(const v3 &rhs);
|
|
29
|
-
v3 operator-(const f64 &rhs) const;
|
|
30
|
-
v3& operator-=(const f64 &rhs);
|
|
31
|
-
v3 operator*(const v3 &rhs) const;
|
|
32
|
-
v3& operator*=(const v3 &rhs);
|
|
33
|
-
v3 operator*(const f64 &rhs) const;
|
|
34
|
-
v3& operator*=(const f64 &rhs);
|
|
35
|
-
v3 operator/(const v3 &rhs) const;
|
|
36
|
-
v3& operator/=(const v3 &rhs);
|
|
37
|
-
v3 operator/(const f64 &rhs) const;
|
|
38
|
-
v3& operator/=(const f64 &rhs);
|
|
39
|
-
bool operator==(const v3 &rhs) const;
|
|
40
|
-
bool operator!=(const v3 &rhs) const;
|
|
41
|
-
f64& operator[](i64 idx);
|
|
42
|
-
f64 operator[](i64 idx) const;
|
|
43
|
-
static f64 norm(const v3& v3In);
|
|
44
|
-
static v3 cross(const v3& v3In0, const v3& v3In1);
|
|
45
|
-
static f64 inner(const v3& v3In0, const v3& v3In1);
|
|
46
|
-
static v3 pow(const v3& v3In, f64 exp);
|
|
47
|
-
static bool rotate
|
|
48
|
-
(
|
|
49
|
-
v3* pv3Dst,
|
|
50
|
-
int iAx, f64 ang,
|
|
51
|
-
const v3& v3Src
|
|
52
|
-
);
|
|
53
|
-
static bool rotate
|
|
54
|
-
(
|
|
55
|
-
vv3* pvv3Dst,
|
|
56
|
-
int iAx, f64 ang,
|
|
57
|
-
const vv3& vv3Src
|
|
58
|
-
);
|
|
59
|
-
static bool rotate
|
|
60
|
-
(
|
|
61
|
-
lv3* plv3Dst,
|
|
62
|
-
int iAx, f64 ang,
|
|
63
|
-
const lv3& lv3Src
|
|
64
|
-
);
|
|
65
|
-
static v3 axisroll(const v3& v3In, i64 lShift);
|
|
66
|
-
template<typename cv3>
|
|
67
|
-
static bool saveF64(FILE* pfBHdr, FILE* pfBin, const cv3& cv3Data);
|
|
68
|
-
template<typename cv3>
|
|
69
|
-
static bool loadF64(FILE* pfBHdr, FILE* pfBin, cv3* pcv3Data);
|
|
70
|
-
template<typename cv3>
|
|
71
|
-
static bool saveF32(FILE* pfBHdr, FILE* pfBin, const cv3& cv3Data);
|
|
72
|
-
template<typename cv3>
|
|
73
|
-
static bool loadF32(FILE* pfBHdr, FILE* pfBin, cv3* pcv3Data);
|
|
74
|
-
private:
|
|
75
|
-
static bool genRotMat(std::array<v3,3>* pav3RotMat, int iAx, f64 ang);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
template<typename cv3>
|
|
79
|
-
bool v3::saveF64(FILE* pfBHdr, FILE* pfBin, const cv3& cv3Data)
|
|
80
|
-
{
|
|
81
|
-
bool ret = true;
|
|
82
|
-
fprintf(pfBHdr, "float64[%ld][3];\n", (i64)cv3Data.size());
|
|
83
|
-
typename cv3::const_iterator icv3Data = cv3Data.begin();
|
|
84
|
-
while (icv3Data!=cv3Data.end())
|
|
85
|
-
{
|
|
86
|
-
ret &= (fwrite(&icv3Data->x, sizeof(f64), 1, pfBin) == 1);
|
|
87
|
-
ret &= (fwrite(&icv3Data->y, sizeof(f64), 1, pfBin) == 1);
|
|
88
|
-
ret &= (fwrite(&icv3Data->z, sizeof(f64), 1, pfBin) == 1);
|
|
89
|
-
++icv3Data;
|
|
90
|
-
}
|
|
91
|
-
return ret;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
template<typename cv3>
|
|
95
|
-
bool v3::loadF64(FILE* pfBHdr, FILE* pfBin, cv3* pcv3Data)
|
|
96
|
-
{
|
|
97
|
-
bool ret = true;
|
|
98
|
-
i64 lenData = 0;
|
|
99
|
-
int nByte = fscanf(pfBHdr, "float64[%ld][3];\n", &lenData);
|
|
100
|
-
if (nByte!=1) ret = false;
|
|
101
|
-
pcv3Data->resize(lenData);
|
|
102
|
-
typename cv3::iterator icv3Data = pcv3Data->begin();
|
|
103
|
-
while (icv3Data!=pcv3Data->end())
|
|
104
|
-
{
|
|
105
|
-
ret &= (fread(&icv3Data->x, sizeof(f64), 1, pfBin) == 1);
|
|
106
|
-
ret &= (fread(&icv3Data->y, sizeof(f64), 1, pfBin) == 1);
|
|
107
|
-
ret &= (fread(&icv3Data->z, sizeof(f64), 1, pfBin) == 1);
|
|
108
|
-
++icv3Data;
|
|
109
|
-
}
|
|
110
|
-
return ret;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
template<typename cv3>
|
|
114
|
-
bool v3::saveF32(FILE* pfBHdr, FILE* pfBin, const cv3& cv3Data)
|
|
115
|
-
{
|
|
116
|
-
bool ret = true;
|
|
117
|
-
fprintf(pfBHdr, "float32[%ld][3];\n", (i64)cv3Data.size());
|
|
118
|
-
typename cv3::const_iterator icv3Data = cv3Data.begin();
|
|
119
|
-
float f32X, f32Y, f32Z;
|
|
120
|
-
while (icv3Data!=cv3Data.end())
|
|
121
|
-
{
|
|
122
|
-
f32X = (float)icv3Data->x;
|
|
123
|
-
f32Y = (float)icv3Data->y;
|
|
124
|
-
f32Z = (float)icv3Data->z;
|
|
125
|
-
ret &= (fwrite(&f32X, sizeof(float), 1, pfBin) == 1);
|
|
126
|
-
ret &= (fwrite(&f32Y, sizeof(float), 1, pfBin) == 1);
|
|
127
|
-
ret &= (fwrite(&f32Z, sizeof(float), 1, pfBin) == 1);
|
|
128
|
-
++icv3Data;
|
|
129
|
-
}
|
|
130
|
-
return ret;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
template<typename cv3>
|
|
134
|
-
bool v3::loadF32(FILE* pfBHdr, FILE* pfBin, cv3* pcv3Data)
|
|
135
|
-
{
|
|
136
|
-
bool ret = true;
|
|
137
|
-
i64 lenData = 0;
|
|
138
|
-
int nByte = fscanf(pfBHdr, "float32[%ld][3];\n", &lenData);
|
|
139
|
-
if (nByte!=1) ret = false;
|
|
140
|
-
pcv3Data->resize(lenData);
|
|
141
|
-
typename cv3::iterator icv3Data = pcv3Data->begin();
|
|
142
|
-
float f32X, f32Y, f32Z;
|
|
143
|
-
while (icv3Data!=pcv3Data->end())
|
|
144
|
-
{
|
|
145
|
-
ret &= (fread(&f32X, sizeof(float), 1, pfBin) == 1);
|
|
146
|
-
ret &= (fread(&f32Y, sizeof(float), 1, pfBin) == 1);
|
|
147
|
-
ret &= (fread(&f32Z, sizeof(float), 1, pfBin) == 1);
|
|
148
|
-
|
|
149
|
-
icv3Data->x = (f64)f32X;
|
|
150
|
-
icv3Data->y = (f64)f32Y;
|
|
151
|
-
icv3Data->z = (f64)f32Z;
|
|
152
|
-
|
|
153
|
-
++icv3Data;
|
|
154
|
-
}
|
|
155
|
-
return ret;
|
|
156
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|