15 #include "vtkPolyData.h"
16 #include <vtkCellArray.h>
17 #include "vtkIdList.h"
41 return std::vector<DataPtr>();
61 QFile exportFile(filename);
62 exportFile.open(QIODevice::WriteOnly);
63 QDataStream out(&exportFile);
64 this->writeToStream(data, out);
70 QDataStream out(&retval, QIODevice::WriteOnly);
71 this->writeToStream(data, out);
76 void CgeoReaderWriter::writeToStream(
DataPtr data, QDataStream &out)
78 MeshPtr mesh = boost::dynamic_pointer_cast<Mesh>(data);
84 vtkPolyDataPtr polyData = mesh->getTransformedPolyDataCopy(mesh->get_rMd());
87 out.setByteOrder(QDataStream::LittleEndian);
88 out.setFloatingPointPrecision(QDataStream::SinglePrecision);
90 out << (qint32) 12072001;
96 if(mesh->getColor().rgba())
98 int intRed = mesh->getColor().red();
99 int intGreen = mesh->getColor().green();
100 int intBlue = mesh->getColor().blue();
101 int intAlpha = mesh->getColor().alpha();
102 int intColor = intRed<<24 | intGreen<<16 | intBlue<<8 | intAlpha;
103 out << (qint32) intColor;
106 out << (qint32) 0xFFFFFFFF;
108 out << (qint32) polyData->GetNumberOfPoints();
111 out << (qint32) polys->GetNumberOfCells();
114 for (
int i=0; i<polyData->GetNumberOfPoints(); i++)
117 polyData->GetPoint(i,p);
124 vtkSmartPointer<vtkIdList> idlist = vtkSmartPointer<vtkIdList>::New();
125 polys->InitTraversal();
127 while(polys->GetNextCell(idlist))
129 n_ids = idlist->GetNumberOfIds();
132 out << (qint32) idlist->GetId(0);
133 out << (qint32) idlist->GetId(1);
134 out << (qint32) idlist->GetId(2);
137 std::cout <<
"Warning in .cgeo export: Skipped polygon not containing exactly 3 points." << std::endl;