MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / writePDC

Function writePDC

extern/partio/src/lib/io/PDC.cpp:130–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130bool writePDC(const char* filename,const ParticlesData& p,const bool compressed,std::ostream* errorStream){
131 unique_ptr<ostream> output(
132 compressed ?
133 Gzip_Out(filename,ios::out|ios::binary)
134 :new std::ofstream(filename,ios::out|ios::binary));
135
136 if(!*output){
137 if(errorStream) *errorStream << "Partio Unable to open file " << filename << endl;
138 return false;
139 }
140
141 // write .pdc header
142 write<LITEND>(*output, PDC_MAGIC);
143 write<BIGEND>(*output, (int)1); // version
144 write<BIGEND>(*output, (int)1); // bitorder
145 write<BIGEND>(*output, (int)0); // tmp1
146 write<BIGEND>(*output, (int)0); // tmp2
147 write<BIGEND>(*output, (int)p.numParticles());
148 write<BIGEND>(*output, (int)p.numAttributes());
149
150 for(int attrIndex = 0; attrIndex < p.numAttributes(); attrIndex++){
151 ParticleAttribute attr;
152 p.attributeInfo(attrIndex,attr);
153
154 // write attribute name
155 write<BIGEND>(*output, (int)attr.name.length());
156 output->write(attr.name.c_str(), (int)attr.name.length());
157
158 // write type
159 int count = 1; // FLOAT
160 if(attr.type == VECTOR){
161 count = 3;
162 }
163 write<BIGEND>(*output, (int)(count+2));
164
165 // write data
166 for(int partIndex = 0; partIndex < p.numParticles(); partIndex++){
167 const float* data = p.data<float>(attr, partIndex);
168 for(int dim = 0; dim < count; dim++){
169 write<BIGEND>(*output, (double)data[dim]);
170 }
171 }
172 }
173 return true;
174}
175
176}// end of namespace Partio

Callers

nothing calls this directly

Calls 5

Gzip_OutFunction · 0.85
numParticlesMethod · 0.80
lengthMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected