Skip to content

Commit 0a5ddec

Browse files
committed
Use positive vertex indices for Wavefront OBJ files: https://sourceforge.net/projects/ifcopenshell/forums/forum/1782717/topic/5341422
1 parent 2137ad2 commit 0a5ddec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ifcobj/IfcObj.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ int main ( int argc, char** argv ) {
7272
// The functions IfcGeomObjects::Get() and IfcGeomObjects::Next() wrap an iterator of all geometrical entities in the Ifc file.
7373
// IfcGeomObjects::Get() returns an IfcGeomObjects::IfcGeomObject (see IfcObjects.h for definition)
7474
// IfcGeomObjects::Next() is used to poll whether more geometrical entities are available
75+
int vcount_total = 1;
7576
do {
7677
const IfcGeomObjects::IfcGeomObject* o = IfcGeomObjects::Get();
7778
if ( o->type == "IfcSpace" || o->type == "IfcOpeningElement" ) continue;
@@ -94,11 +95,12 @@ int main ( int argc, char** argv ) {
9495
fObj << "vn " << x << " " << y << " " << z << std::endl;
9596
}
9697
for ( IfcGeomObjects::IntIt it = o->mesh->faces.begin(); it != o->mesh->faces.end(); ) {
97-
const int v1 = *(it++)-vcount;
98-
const int v2 = *(it++)-vcount;
99-
const int v3 = *(it++)-vcount;
98+
const int v1 = *(it++)+vcount_total;
99+
const int v2 = *(it++)+vcount_total;
100+
const int v3 = *(it++)+vcount_total;
100101
fObj << "f " << v1 << "//" << v1 << " " << v2 << "//" << v2 << " " << v3 << "//" << v3 << std::endl;
101102
}
103+
vcount_total += vcount;
102104

103105
const int progress = IfcGeomObjects::Progress() / 2;
104106
if ( old_progress!= progress ) std::cout << "\r[" << std::string(progress,'#') << std::string(50 - progress,' ') << "]" << std::flush;

0 commit comments

Comments
 (0)