Skip to content

Commit dc44bf5

Browse files
authored
Merge pull request #203 from gcherchi/master
write_MESH test
2 parents 346f6fe + cdf596a commit dc44bf5

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

include/cinolib/io/write_MESH.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ void write_MESH(const char * filename,
6666
uint nv = uint(verts.size());
6767
uint nt = 0;
6868
uint nh = 0;
69+
uint np = 0;
70+
uint nw = 0;
6971
for(auto p : polys)
7072
{
7173
if (p.size() == 4) ++nt; else
74+
if (p.size() == 5) ++np; else
75+
if (p.size() == 6) ++nw; else
7276
if (p.size() == 8) ++nh;
7377
}
7478

@@ -114,6 +118,38 @@ void write_MESH(const char * filename,
114118
}
115119
}
116120

121+
if(np > 0)
122+
{
123+
fprintf(fp, "Pyramids\n" );
124+
fprintf(fp, "%d\n", np );
125+
for(uint pid=0; pid<polys.size(); ++pid)
126+
{
127+
const std::vector<uint> & pyr = polys.at(pid);
128+
if (pyr.size() == 5)
129+
{
130+
fprintf(fp, "%d %d %d %d %d %d\n", pyr.at(0)+1, pyr.at(1)+1, pyr.at(2)+1, pyr.at(3)+1, pyr.at(4)+1,
131+
poly_labels.at(pid));
132+
}
133+
}
134+
}
135+
136+
if (nw > 0)
137+
{
138+
fprintf(fp, "Prisms\n" );
139+
fprintf(fp, "%d\n", nw );
140+
for(uint pid=0; pid<polys.size(); ++pid)
141+
{
142+
const std::vector<uint> & prism = polys.at(pid);
143+
if (prism.size() == 6)
144+
{
145+
fprintf(fp, "%d %d %d %d %d %d %d\n", prism.at(0)+1, prism.at(1)+1, prism.at(2)+1,
146+
prism.at(3)+1, prism.at(4)+1, prism.at(5)+1,
147+
poly_labels.at(pid));
148+
}
149+
}
150+
}
151+
152+
117153
fprintf(fp, "End\n\n");
118154
fclose(fp);
119155
}

include/cinolib/meshes/abstract_polyhedralmesh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,7 @@ uint AbstractPolyhedralMesh<M,V,E,F,P>::poly_add(const std::vector<uint> & vlist
26432643
static_cast<uint>(fid4)},w);
26442644

26452645
// enforce standard vertex ordering (I SHOULDN'T NEED IT FOR PRISMS...)
2646+
26462647
return pid;
26472648
}
26482649
else if(vlist.size()==5) // squared pyramid

0 commit comments

Comments
 (0)