- labels: --> Renderer Module
- priority: 5 --> 2
void sample_textile(std::string filename, CTextile* weave,
const unsigned int nx, const unsigned int ny, const unsigned int nz ){
TexGen::XYZ bot, top;
const CDomain* domain = weave->GetDomain();
((CDomainPlanes*)domain)->GetBoxLimits(bot,top);
unsigned int i, j, k;
std::vector<XYZ> points;
unsigned int n_s[] = {nx,ny,nz};
for(i=0;i<n_s[0];++i){
for(j=0;j<n_s[1];++j){
for(k=0;k<n_s[2];++k){
points.push_back(
XYZ(
bot[0]+(top[0]-bot[0])/n_s[0]*i,
bot[1]+(top[1]-bot[1])/n_s[1]*j,
bot[2]+(top[2]-bot[2])/n_s[2]*k
));
}
}
}
std::vector<POINT_INFO> point_info;
weave->GetPointInformation(points, point_info);
vtkFloatArray * coords = vtkFloatArray::New();
vtkFloatArray * orientation = vtkFloatArray::New();
vtkFloatArray * locs_vtk = vtkFloatArray::New();
vtkFloatArray * v_f = vtkFloatArray::New();
vtkIntArray * key = vtkIntArray::New();
vtkPoints* pnts = vtkPoints::New();
vtkPolyData* grid = vtkPolyData::New();
vtkXMLPPolyDataWriter* pwriter = vtkXMLPPolyDataWriter::New();
coords->SetNumberOfComponents(3);
locs_vtk->SetNumberOfComponents(2);
orientation->SetNumberOfComponents(3);
locs_vtk->SetName("loc");
orientation->SetName("orientation");
key->SetName("key");
v_f->SetName("volume_fraction");
for(i=0;i<points.size();++i){
float orient[] = {0,0,0};
float loc[] = {0,0,0};
for(j=0;j<3;++j){
loc[j] = points[i][j];
orient[j] = point_info[i].YarnTangent[j];
}
float inloc[] = {0,0};
inloc[0] = point_info[i].Location[0];
inloc[1] = point_info[i].Location[1];
if (point_info[i].iYarnIndex!=-1){
locs_vtk->InsertNextTupleValue(inloc);
coords->InsertNextTupleValue(loc);
orientation->InsertNextTupleValue(orient);
v_f->InsertNextValue(point_info[i].dVolumeFraction);
key->InsertNextValue(point_info[i].iYarnIndex);
}
}
pnts->SetData(coords);
grid->GetPointData()->AddArray(orientation);
grid->GetPointData()->AddArray(key);
grid->GetPointData()->AddArray(locs_vtk);
grid->GetPointData()->AddArray(v_f);
grid->SetPoints(pnts);
pwriter->SetInput(grid);
pwriter->SetDataModeToBinary();
filename += ".pvtp";
pwriter->SetFileName(filename.c_str());
pwriter->Write();
}