Site local placement (#240)

* ifcgeom: Add placement_rel_to for convert()

Change geometry conversion in `convert()` for `ObjectPlacement` such
that we can stop the `PlacementRelTo()` recursion when we hit an
`ObjectPlacement` that places a certain type, e.g. a `IfcSite'.

Introduce a new IteratorSetting `SITE_LOCAL_PLACEMENT` which will be
exposed in `IfcConvert`.

* IfcConvert: Add --site-local-placement

Some IFC authoring tools may put the global origo at a large distance
away from the actual building geometry. Also, the global X- and Y-axes
may be at arbitrary angles with natural building axes. Using
--center-model or --model-offset may place the converted geometry closer
to origo, but will still use the global IFC definition of axis
directions. Also, in a scenario with multiple IFC files for one
construction site, using --center-model on each of them would not
generate consistent geometry across OBJ or DAE files.

Solve this by introducing --site-local-placement which will disregard
the ObjectPlacement at the IfcSite level.
This commit is contained in:
Anders Granskogen Bjørnstad
2017-08-19 17:21:10 +02:00
committed by Thomas Krijnen
parent 7bea054c1e
commit 475b8554a8
5 changed files with 39 additions and 5 deletions
+10
View File
@@ -293,6 +293,9 @@ int main(int argc, char** argv)
"all placements as an offset. Applicable for OBJ and DAE output.")
("model-offset", po::value<std::string>(&offset_str),
"Applies an arbitrary offset of form 'x;y;z' to all placements. Applicable for OBJ and DAE output.")
("site-local-placement",
"Place elements locally in the IfcSite coordinate system, instead of placing "
"them in the IFC global coords. Applicable for OBJ and DAE output.")
("precision", po::value<short>(&precision)->default_value(SerializerSettings::DEFAULT_PRECISION),
"Sets the precision to be used to format floating-point values, 15 by default. "
"Use a negative value to use the system's default precision (should be 6 typically). "
@@ -364,6 +367,7 @@ int main(int argc, char** argv)
const bool no_normals = vmap.count("no-normals") != 0 ;
const bool center_model = vmap.count("center-model") != 0 ;
const bool model_offset = vmap.count("model-offset") != 0 ;
const bool site_local_placement = vmap.count("site-local-placement") != 0 ;
const bool generate_uvs = vmap.count("generate-uvs") != 0 ;
#ifdef HAVE_ICU
@@ -496,6 +500,7 @@ int main(int argc, char** argv)
settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals);
settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs);
settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy);
settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement);
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
@@ -602,6 +607,11 @@ int main(int argc, char** argv)
if (center_model || model_offset) {
double* offset = serializer->settings().offset;
if (center_model) {
if (site_local_placement) {
Logger::Error("Cannot use --center-model together with --site-local-placement");
delete serializer;
return EXIT_FAILURE;
}
gp_XYZ center = (context_iterator.bounds_min() + context_iterator.bounds_max()) * 0.5;
offset[0] = -center.X();
offset[1] = -center.Y();