Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit f369678

Browse files
committed
#1097
fix:IFC file conversion obj file, some cases will be rotated 90 °
1 parent 14193fb commit f369678

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/ifcconvert/IfcConvert.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ int main(int argc, char** argv) {
394394
("site-local-placement",
395395
"Place elements locally in the IfcSite coordinate system, instead of placing "
396396
"them in the IFC global coords. Applicable for OBJ and DAE output.")
397+
("use-z-up", "Z UP. default Y UP,Applicable for OBJ output.")
397398
("building-local-placement",
398399
"Similar to --site-local-placement, but placing elements in locally in the parent IfcBuilding coord system")
399400
("precision", po::value<short>(&precision)->default_value(SerializerSettings::DEFAULT_PRECISION),
@@ -459,6 +460,7 @@ int main(int argc, char** argv) {
459460
const bool use_material_names = vmap.count("use-material-names") != 0;
460461
const bool use_element_types = vmap.count("use-element-types") != 0;
461462
const bool use_element_hierarchy = vmap.count("use-element-hierarchy") != 0;
463+
const bool use_z_up = vmap.count("use-z-up") != 0;
462464
const bool no_normals = vmap.count("no-normals") != 0;
463465
const bool center_model = vmap.count("center-model") != 0;
464466
const bool center_model_geometry = vmap.count("center-model-geometry") != 0;
@@ -732,6 +734,7 @@ int main(int argc, char** argv) {
732734

733735
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
734736
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
737+
settings.set(SerializerSettings::USE_Z_UP, use_z_up);
735738
settings.set(SerializerSettings::USE_ELEMENT_STEPIDS, use_element_stepids);
736739
settings.set(SerializerSettings::USE_MATERIAL_NAMES, use_material_names);
737740
settings.set(SerializerSettings::USE_ELEMENT_TYPES, use_element_types);

src/serializers/GeometrySerializer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ class SerializerSettings : public IfcGeom::IteratorSettings
5353
/// Use step ids for naming elements.
5454
/// Applicable for OBJ, DAE, and SVG output.
5555
USE_ELEMENT_STEPIDS = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 6),
56+
/// Use step Z UP .
57+
/// Applicable for OBJ output.
58+
USE_Z_UP = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 7),
5659
/// Number of different setting flags.
57-
NUM_SETTINGS = 6
60+
NUM_SETTINGS = 7
5861
};
5962

6063
SerializerSettings()

src/serializers/WavefrontObjSerializer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,24 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement<real_t>*
8888
{
8989
obj_stream << "g " << object_id(o) << "\n";
9090
obj_stream << "s 1" << "\n";
91-
91+
bool isyup = true;
92+
if (settings().get(SerializerSettings::USE_Z_UP) ){ //settings().get(SerializerSettings::USE_Z_UP)
93+
isyup = false;
94+
}
95+
9296
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
9397

9498
const int vcount = (int)mesh.verts().size() / 3;
9599
for ( std::vector<real_t>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end(); ) {
96100
const real_t x = *(it++);
97101
const real_t y = *(it++);
98102
const real_t z = *(it++);
99-
obj_stream << "v " << x << " " << y << " " << z << "\n";
103+
104+
if(isyup){
105+
obj_stream << "v " << x << " " << y << " " << z << "\n";
106+
}else{
107+
obj_stream << "v " << -x << " " << z << " " << y << "\n";
108+
}
100109
}
101110

102111
for ( std::vector<real_t>::const_iterator it = mesh.normals().begin(); it != mesh.normals().end(); ) {

0 commit comments

Comments
 (0)