mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
#1097
fix:IFC file conversion obj file, some cases will be rotated 90 °
This commit is contained in:
@@ -394,6 +394,7 @@ int main(int argc, char** argv) {
|
|||||||
("site-local-placement",
|
("site-local-placement",
|
||||||
"Place elements locally in the IfcSite coordinate system, instead of placing "
|
"Place elements locally in the IfcSite coordinate system, instead of placing "
|
||||||
"them in the IFC global coords. Applicable for OBJ and DAE output.")
|
"them in the IFC global coords. Applicable for OBJ and DAE output.")
|
||||||
|
("use-z-up", "Z UP. default Y UP,Applicable for OBJ output.")
|
||||||
("building-local-placement",
|
("building-local-placement",
|
||||||
"Similar to --site-local-placement, but placing elements in locally in the parent IfcBuilding coord system")
|
"Similar to --site-local-placement, but placing elements in locally in the parent IfcBuilding coord system")
|
||||||
("precision", po::value<short>(&precision)->default_value(SerializerSettings::DEFAULT_PRECISION),
|
("precision", po::value<short>(&precision)->default_value(SerializerSettings::DEFAULT_PRECISION),
|
||||||
@@ -459,6 +460,7 @@ int main(int argc, char** argv) {
|
|||||||
const bool use_material_names = vmap.count("use-material-names") != 0;
|
const bool use_material_names = vmap.count("use-material-names") != 0;
|
||||||
const bool use_element_types = vmap.count("use-element-types") != 0;
|
const bool use_element_types = vmap.count("use-element-types") != 0;
|
||||||
const bool use_element_hierarchy = vmap.count("use-element-hierarchy") != 0;
|
const bool use_element_hierarchy = vmap.count("use-element-hierarchy") != 0;
|
||||||
|
const bool use_z_up = vmap.count("use-z-up") != 0;
|
||||||
const bool no_normals = vmap.count("no-normals") != 0;
|
const bool no_normals = vmap.count("no-normals") != 0;
|
||||||
const bool center_model = vmap.count("center-model") != 0;
|
const bool center_model = vmap.count("center-model") != 0;
|
||||||
const bool center_model_geometry = vmap.count("center-model-geometry") != 0;
|
const bool center_model_geometry = vmap.count("center-model-geometry") != 0;
|
||||||
@@ -732,6 +734,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
|
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
|
||||||
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
|
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
|
||||||
|
settings.set(SerializerSettings::USE_Z_UP, use_z_up);
|
||||||
settings.set(SerializerSettings::USE_ELEMENT_STEPIDS, use_element_stepids);
|
settings.set(SerializerSettings::USE_ELEMENT_STEPIDS, use_element_stepids);
|
||||||
settings.set(SerializerSettings::USE_MATERIAL_NAMES, use_material_names);
|
settings.set(SerializerSettings::USE_MATERIAL_NAMES, use_material_names);
|
||||||
settings.set(SerializerSettings::USE_ELEMENT_TYPES, use_element_types);
|
settings.set(SerializerSettings::USE_ELEMENT_TYPES, use_element_types);
|
||||||
|
|||||||
@@ -53,8 +53,11 @@ public:
|
|||||||
/// Use step ids for naming elements.
|
/// Use step ids for naming elements.
|
||||||
/// Applicable for OBJ, DAE, and SVG output.
|
/// Applicable for OBJ, DAE, and SVG output.
|
||||||
USE_ELEMENT_STEPIDS = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 6),
|
USE_ELEMENT_STEPIDS = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 6),
|
||||||
|
/// Use step Z UP .
|
||||||
|
/// Applicable for OBJ output.
|
||||||
|
USE_Z_UP = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 7),
|
||||||
/// Number of different setting flags.
|
/// Number of different setting flags.
|
||||||
NUM_SETTINGS = 6
|
NUM_SETTINGS = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
SerializerSettings()
|
SerializerSettings()
|
||||||
|
|||||||
@@ -88,7 +88,11 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement<real_t>*
|
|||||||
{
|
{
|
||||||
obj_stream << "g " << object_id(o) << "\n";
|
obj_stream << "g " << object_id(o) << "\n";
|
||||||
obj_stream << "s 1" << "\n";
|
obj_stream << "s 1" << "\n";
|
||||||
|
bool isyup = true;
|
||||||
|
if (settings().get(SerializerSettings::USE_Z_UP) ){ //settings().get(SerializerSettings::USE_Z_UP)
|
||||||
|
isyup = false;
|
||||||
|
}
|
||||||
|
|
||||||
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
||||||
|
|
||||||
const int vcount = (int)mesh.verts().size() / 3;
|
const int vcount = (int)mesh.verts().size() / 3;
|
||||||
@@ -96,7 +100,12 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement<real_t>*
|
|||||||
const real_t x = *(it++);
|
const real_t x = *(it++);
|
||||||
const real_t y = *(it++);
|
const real_t y = *(it++);
|
||||||
const real_t z = *(it++);
|
const real_t z = *(it++);
|
||||||
obj_stream << "v " << x << " " << y << " " << z << "\n";
|
|
||||||
|
if(isyup){
|
||||||
|
obj_stream << "v " << x << " " << y << " " << z << "\n";
|
||||||
|
}else{
|
||||||
|
obj_stream << "v " << -x << " " << z << " " << y << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( std::vector<real_t>::const_iterator it = mesh.normals().begin(); it != mesh.normals().end(); ) {
|
for ( std::vector<real_t>::const_iterator it = mesh.normals().begin(); it != mesh.normals().end(); ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user