|
@@ -46,6 +46,7 @@ namespace Lemma {
|
46
|
46
|
// Description: DeSerializing constructor (protected)
|
47
|
47
|
//--------------------------------------------------------------------------------------
|
48
|
48
|
DEMGrain::DEMGrain (const YAML::Node& node) : DEMParticle(node) {
|
|
49
|
+ Points = node["Points"].as<Vector3Xr>( );
|
49
|
50
|
|
50
|
51
|
} // ----- end of method DEMGrain::DEMGrain (constructor) -----
|
51
|
52
|
|
|
@@ -76,6 +77,7 @@ namespace Lemma {
|
76
|
77
|
YAML::Node node = DEMParticle::Serialize();
|
77
|
78
|
node.SetTag( GetName() );
|
78
|
79
|
// FILL IN CLASS SPECIFICS HERE
|
|
80
|
+ node["Points"] = Points;
|
79
|
81
|
return node;
|
80
|
82
|
} // ----- end of method DEMGrain::Serialize -----
|
81
|
83
|
|
|
@@ -91,6 +93,46 @@ namespace Lemma {
|
91
|
93
|
return Object ;
|
92
|
94
|
} // ----- end of method DEMGrain::DeSerialize -----
|
93
|
95
|
|
|
96
|
+
|
|
97
|
+ //--------------------------------------------------------------------------------------
|
|
98
|
+ // Class: DEMGrain
|
|
99
|
+ // Method: RandomPointBuild
|
|
100
|
+ //--------------------------------------------------------------------------------------
|
|
101
|
+ void DEMGrain::RandomPointCloud ( const int& npoints, const Real& sigma ) {
|
|
102
|
+
|
|
103
|
+ Points.resize( Eigen::NoChange, npoints );
|
|
104
|
+ std::mt19937 eng(time(NULL));
|
|
105
|
+ std::normal_distribution<Real> normalx(GetCentreMass(0), sigma);
|
|
106
|
+ std::normal_distribution<Real> normaly(GetCentreMass(1), sigma);
|
|
107
|
+ std::normal_distribution<Real> normalz(GetCentreMass(2), sigma);
|
|
108
|
+ std::cout.precision(12);
|
|
109
|
+ for(int i=0; i < npoints; ++i) {
|
|
110
|
+ Points(0, i) = normalx(eng);
|
|
111
|
+ Points(1, i) = normaly(eng);
|
|
112
|
+ Points(2, i) = normalz(eng);
|
|
113
|
+ }
|
|
114
|
+ ConvexHull();
|
|
115
|
+ return ;
|
|
116
|
+ } // ----- end of method DEMGrain::RandomPoints -----
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+ //--------------------------------------------------------------------------------------
|
|
121
|
+ // Class: DEMGrain
|
|
122
|
+ // Method: ConvexHull
|
|
123
|
+ //--------------------------------------------------------------------------------------
|
|
124
|
+ void DEMGrain::ConvexHull ( ) {
|
|
125
|
+
|
|
126
|
+ //for ( auto point : Points.rowwise() ) {
|
|
127
|
+ // Brute force algorithm (O(n^3))
|
|
128
|
+ for (int icol=0; icol<Points.cols(); ++icol) {
|
|
129
|
+ std::cout << Points.col(icol) << std::endl;
|
|
130
|
+ }
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+ return ;
|
|
134
|
+ } // ----- end of method DEMGrain::ConvexHull -----
|
|
135
|
+
|
94
|
136
|
} // ---- end of namespace Lemma ----
|
95
|
137
|
|
96
|
138
|
/* vim: set tabstop=4 expandtab: */
|