12 template <
typename TDataType>
class TriangleSet;
14 template<
typename TDataType>
17 this->inVec3f()->tagOptional(
true);
18 this->inMatrix1()->tagOptional(
true);
19 this->inMatrix2()->tagOptional(
true);
25 template<
typename TDataType>
28 if (this->stateFrameNumber()->getData() % this->varFrameStep()->getData() != 0)
33 trilist.
copyFrom(this->inTriangleSet()->getData());
37 c_triangle.
assign(d_triangle);
53 if (!this->inVec3f()->isEmpty())
55 d_color = this->inVec3f()->getData();
58 if (!this->inMatrix1()->isEmpty())
60 d_strain = this->inMatrix1()->getData();
63 if (!this->inMatrix2()->isEmpty())
65 d_stress = this->inMatrix2()->getData();
69 int n_point = this->inTriangleSet()->getData().getVertex2Triangles().size();
70 int n_triangle = this->inTriangleSet()->getData().getTriangles().size();
75 if (this->varReCount()->getData())
77 out_number = this->stateFrameNumber()->getData() / this->varFrameStep()->getData();
81 out_number = this->stateFrameNumber()->getData();
84 std::stringstream ss; ss << out_number;
85 std::string filename = this->varOutputPath()->getData() + ss.str() + this->file_postfix;
86 std::ofstream out4(filename.c_str(), std::ios::out);
88 out4 <<
"ply" << std::endl;
89 out4 <<
"format ascii 1.0" << std::endl;
90 out4 <<
"comment created by Peridyno" << std::endl;
91 out4 <<
"element vertex " << n_point << std::endl;
93 out4 <<
"property float x" << std::endl;
94 out4 <<
"property float y" << std::endl;
95 out4 <<
"property float z" << std::endl;
97 if (!this->inVec3f()->isEmpty())
99 out4 <<
"property uchar vec3f01" << std::endl;
100 out4 <<
"property uchar vec3f02" << std::endl;
101 out4 <<
"property uchar vec3f03" << std::endl;
104 if (!this->inMatrix1()->isEmpty())
106 out4 <<
"property float MatrixOne00" << std::endl;
107 out4 <<
"property float MatrixOne01" << std::endl;
108 out4 <<
"property float MatrixOne02" << std::endl;
109 out4 <<
"property float MatrixOne10" << std::endl;
110 out4 <<
"property float MatrixOne11" << std::endl;
111 out4 <<
"property float MatrixOne12" << std::endl;
112 out4 <<
"property float MatrixOne20" << std::endl;
113 out4 <<
"property float MatrixOne21" << std::endl;
114 out4 <<
"property float MatrixOne22" << std::endl;
117 if (!this->inMatrix2()->isEmpty())
119 out4 <<
"property float MatrixTwo00" << std::endl;
120 out4 <<
"property float MatrixTwo01" << std::endl;
121 out4 <<
"property float MatrixTwo02" << std::endl;
122 out4 <<
"property float MatrixTwo10" << std::endl;
123 out4 <<
"property float MatrixTwo11" << std::endl;
124 out4 <<
"property float MatrixTwo12" << std::endl;
125 out4 <<
"property float MatrixTwo20" << std::endl;
126 out4 <<
"property float MatrixTwo21" << std::endl;
127 out4 <<
"property float MatrixTwo22" << std::endl;
130 out4 <<
"element face " << n_triangle << std::endl;
131 out4 <<
"property list uchar int vertex_indices" << std::endl;
132 out4 <<
"end_header" << std::endl;
136 for (
int i = 0; i < n_point; i++)
139 out4 << std::fixed << std::setw(stw) << std::setprecision(num) << c_point[i][0] <<
" "
140 << std::fixed << std::setw(stw) << std::setprecision(num) << c_point[i][1] <<
" "
141 << std::fixed << std::setw(stw) << std::setprecision(num) << c_point[i][2] <<
" ";
144 if (!this->inVec3f()->isEmpty()) {
145 out4 << std::fixed << std::setw(stw) << std::setprecision(num) << c_color[i][0] <<
" "
146 << std::fixed << std::setw(stw) << std::setprecision(num) << c_color[i][1] <<
" "
147 << std::fixed << std::setw(stw) << std::setprecision(num) << c_color[i][2] <<
" ";
152 if (!this->inMatrix1()->isEmpty())
154 for (
int j = 0; j < 3; j++)
156 for (
int k = 0; k < 3; k++)
158 out4 << std::fixed << std::setw(stw) << std::setprecision(num) << c_strain[i](j, k) <<
" ";
163 if (!this->inMatrix2()->isEmpty())
165 for (
int j = 0; j < 3; j++)
167 for (
int k = 0; k < 3; k++)
169 out4 << std::fixed << std::setw(stw) << std::setprecision(num) << c_stress[i](j, k) <<
" ";
176 for (
int i = 0; i < n_triangle; i++)
178 out4 <<
"3 " << std::fixed << std::setw(stw) << std::setprecision(num) << c_triangle[i][2] <<
" ";
179 out4 << std::fixed << std::setw(stw) << std::setprecision(num) << c_triangle[i][1] <<
" ";
180 out4 << std::fixed << std::setw(stw) << std::setprecision(num) << c_triangle[i][0]
189 template<
typename TDataType>
void assign(const T &val)
DArrayList< int > & getVer2Edge()
void resetStates() override
void updateStates() override
DArray< Coord > & getPoints()
DArrayList< int > & getVertex2Triangles()
void copyFrom(TriangleSet< TDataType > &triangleSet)
DArray< Triangle > & getTriangles()
return all triangle indices
This is an implementation of AdditiveCCD based on peridyno.
IMPLEMENT_TCLASS(FloatingNumber, TDataType)
DEFINE_CLASS(CircularEmitter)