mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Reintroduce --center-model and --center-model-geometry
This commit is contained in:
@@ -449,8 +449,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
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;
|
||||||
const bool model_offset = vmap.count("model-offset") != 0;
|
|
||||||
const bool model_rotation = vmap.count("model-rotation") != 0;
|
|
||||||
|
|
||||||
if (!quiet || vmap.count("version")) {
|
if (!quiet || vmap.count("version")) {
|
||||||
print_version();
|
print_version();
|
||||||
@@ -894,7 +892,7 @@ int main(int argc, char** argv) {
|
|||||||
if (geometry_settings.get<ifcopenshell::geometry::settings::GenerateUvs>().get()) {
|
if (geometry_settings.get<ifcopenshell::geometry::settings::GenerateUvs>().get()) {
|
||||||
Logger::Notice("Generate UVs setting ignored when writing non-tesselated output");
|
Logger::Notice("Generate UVs setting ignored when writing non-tesselated output");
|
||||||
}
|
}
|
||||||
if (center_model || center_model_geometry || model_offset) {
|
if (center_model || center_model_geometry) {
|
||||||
Logger::Notice("Centering/offsetting model setting ignored when writing non-tesselated output");
|
Logger::Notice("Centering/offsetting model setting ignored when writing non-tesselated output");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,71 +921,43 @@ int main(int argc, char** argv) {
|
|||||||
Logger::SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
|
Logger::SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (is_tesselated && (center_model || center_model_geometry)) {
|
||||||
// @todo
|
std::vector<double> offset(3);
|
||||||
if (model_rotation) {
|
|
||||||
std::array<double, 4> &rotation = settings.rotation;
|
|
||||||
if (sscanf(rotation_str.c_str(), "%lf;%lf;%lf;%lf", &rotation[0], &rotation[1], &rotation[2], &rotation[3]) != 4) {
|
|
||||||
cerr_ << "[Error] Invalid use of --model-rotation\n";
|
|
||||||
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename));
|
|
||||||
print_options(serializer_options);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream msg;
|
IfcGeom::Iterator tmp_context_iterator(geometry_kernel, geometry_settings, ifc_file, filter_funcs, num_threads);
|
||||||
msg << "Using model rotation (" << rotation[0] << "," << rotation[1] << "," << rotation[2] << "," << rotation[3] << ")";
|
|
||||||
Logger::Notice(msg.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_tesselated && (center_model || center_model_geometry || model_offset)) {
|
time_t start, end;
|
||||||
std::array<double, 3> &offset = settings.offset;
|
time(&start);
|
||||||
if (center_model || center_model_geometry) {
|
if (!quiet) Logger::Status("Computing bounds...");
|
||||||
if (site_local_placement || building_local_placement) {
|
|
||||||
Logger::Error("Cannot use --center-model or --center-model-geometry together with --{site,building}-local-placement");
|
if (center_model_geometry) {
|
||||||
|
if (!tmp_context_iterator.initialize()) {
|
||||||
|
/// @todo It would be nice to know and print separate error prints for a case where we found no entities
|
||||||
|
/// and for a case we found no entities that satisfy our filtering criteria.
|
||||||
|
Logger::Notice("No geometrical elements found or none successfully converted");
|
||||||
|
serializer.reset();
|
||||||
|
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename));
|
||||||
|
write_log(!quiet);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IfcGeom::Iterator tmp_context_iterator(geometry_kernel, settings, ifc_file, filter_funcs, num_threads);
|
tmp_context_iterator.compute_bounds(center_model_geometry);
|
||||||
|
|
||||||
time_t start, end;
|
time(&end);
|
||||||
time(&start);
|
if (!quiet) Logger::Status("Done ! Bounds computed in " + format_duration(start, end));
|
||||||
if (!quiet) Logger::Status("Computing bounds...");
|
|
||||||
|
|
||||||
if (center_model_geometry) {
|
auto center = (tmp_context_iterator.bounds_min().ccomponents() + tmp_context_iterator.bounds_max().ccomponents()) * 0.5;
|
||||||
if (!tmp_context_iterator.initialize()) {
|
offset[0] = -center(0);
|
||||||
/// @todo It would be nice to know and print separate error prints for a case where we found no entities
|
offset[1] = -center(1);
|
||||||
/// and for a case we found no entities that satisfy our filtering criteria.
|
offset[2] = -center(2);
|
||||||
Logger::Notice("No geometrical elements found or none successfully converted");
|
|
||||||
serializer.reset();
|
|
||||||
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename));
|
|
||||||
write_log(!quiet);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp_context_iterator.compute_bounds(center_model_geometry);
|
|
||||||
|
|
||||||
time(&end);
|
|
||||||
if (!quiet) Logger::Status("Done ! Bounds computed in " + format_duration(start, end));
|
|
||||||
|
|
||||||
auto center = (tmp_context_iterator.bounds_min().ccomponents() + tmp_context_iterator.bounds_max().ccomponents()) * 0.5;
|
|
||||||
offset[0] = -center(0);
|
|
||||||
offset[1] = -center(1);
|
|
||||||
offset[2] = -center(2);
|
|
||||||
} else {
|
|
||||||
if (sscanf(offset_str.c_str(), "%lf;%lf;%lf", &offset[0], &offset[1], &offset[2]) != 3) {
|
|
||||||
cerr_ << "[Error] Invalid use of --model-offset\n";
|
|
||||||
IfcUtil::path::delete_file(IfcUtil::path::to_utf8(output_temp_filename));
|
|
||||||
print_options(serializer_options);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
msg << std::setprecision (std::numeric_limits< double >::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")";
|
msg << std::setprecision (std::numeric_limits< double >::max_digits10) << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")";
|
||||||
Logger::Notice(msg.str());
|
Logger::Notice(msg.str());
|
||||||
|
|
||||||
|
geometry_settings.get<ifcopenshell::geometry::settings::ModelOffset>().value = offset;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// backwards compatibility
|
// backwards compatibility
|
||||||
if (vmap.count("plan") && vmap.count("model")) {
|
if (vmap.count("plan") && vmap.count("model")) {
|
||||||
|
|||||||
+8
-15
@@ -128,13 +128,11 @@ namespace IfcGeom {
|
|||||||
size_t async_elements_returned_ = 0;
|
size_t async_elements_returned_ = 0;
|
||||||
size_t task_result_index_ = 0;
|
size_t task_result_index_ = 0;
|
||||||
|
|
||||||
std::string geometry_library_;
|
|
||||||
|
|
||||||
ifcopenshell::geometry::Settings settings_;
|
ifcopenshell::geometry::Settings settings_;
|
||||||
IfcParse::IfcFile* ifc_file;
|
IfcParse::IfcFile* ifc_file;
|
||||||
std::vector<filter_t> filters_;
|
std::vector<filter_t> filters_;
|
||||||
bool owns_ifc_file;
|
|
||||||
int num_threads_;
|
int num_threads_;
|
||||||
|
std::string geometry_library_;
|
||||||
|
|
||||||
// When single-threaded
|
// When single-threaded
|
||||||
ifcopenshell::geometry::Converter* converter_;
|
ifcopenshell::geometry::Converter* converter_;
|
||||||
@@ -195,7 +193,6 @@ namespace IfcGeom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
time_points[0] = high_resolution_clock::now();
|
time_points[0] = high_resolution_clock::now();
|
||||||
converter_ = new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_);
|
|
||||||
std::vector<ifcopenshell::geometry::geometry_conversion_task> reps;
|
std::vector<ifcopenshell::geometry::geometry_conversion_task> reps;
|
||||||
if (num_threads_ != 1) {
|
if (num_threads_ != 1) {
|
||||||
// @todo this shouldn't be necessary with properly immutable taxonomy items
|
// @todo this shouldn't be necessary with properly immutable taxonomy items
|
||||||
@@ -420,7 +417,7 @@ namespace IfcGeom {
|
|||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
bounds_min_.components()(i) = std::min(bounds_min_.components()(i), transformed(i));
|
bounds_min_.components()(i) = std::min(bounds_min_.components()(i), transformed(i));
|
||||||
bounds_max_.components()(i) = std::max(bounds_min_.components()(i), transformed(i));
|
bounds_max_.components()(i) = std::max(bounds_max_.components()(i), transformed(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (++num_created, next());
|
} while (++num_created, next());
|
||||||
@@ -439,7 +436,7 @@ namespace IfcGeom {
|
|||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
bounds_min_.components()(i) = std::min(bounds_min_.components()(i), vec(i));
|
bounds_min_.components()(i) = std::min(bounds_min_.components()(i), vec(i));
|
||||||
bounds_max_.components()(i) = std::max(bounds_min_.components()(i), vec(i));
|
bounds_max_.components()(i) = std::max(bounds_max_.components()(i), vec(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -838,9 +835,9 @@ namespace IfcGeom {
|
|||||||
: settings_(settings)
|
: settings_(settings)
|
||||||
, ifc_file(file)
|
, ifc_file(file)
|
||||||
, filters_(filters)
|
, filters_(filters)
|
||||||
, owns_ifc_file(false)
|
|
||||||
, num_threads_(num_threads)
|
, num_threads_(num_threads)
|
||||||
, geometry_library_(geometry_library)
|
, geometry_library_(geometry_library)
|
||||||
|
, converter_(new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,36 +845,36 @@ namespace IfcGeom {
|
|||||||
: settings_(settings)
|
: settings_(settings)
|
||||||
, ifc_file(file)
|
, ifc_file(file)
|
||||||
, filters_(filters)
|
, filters_(filters)
|
||||||
, owns_ifc_file(false)
|
|
||||||
, num_threads_(num_threads)
|
, num_threads_(num_threads)
|
||||||
, geometry_library_("opencascade")
|
, geometry_library_("opencascade")
|
||||||
|
, converter_(new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator(const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file)
|
Iterator(const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file)
|
||||||
: settings_(settings)
|
: settings_(settings)
|
||||||
, ifc_file(file)
|
, ifc_file(file)
|
||||||
, owns_ifc_file(false)
|
|
||||||
, num_threads_(1)
|
, num_threads_(1)
|
||||||
, geometry_library_("opencascade")
|
, geometry_library_("opencascade")
|
||||||
|
, converter_(new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator(const std::string& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file)
|
Iterator(const std::string& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file)
|
||||||
: settings_(settings)
|
: settings_(settings)
|
||||||
, ifc_file(file)
|
, ifc_file(file)
|
||||||
, owns_ifc_file(false)
|
|
||||||
, num_threads_(1)
|
, num_threads_(1)
|
||||||
, geometry_library_(geometry_library)
|
, geometry_library_(geometry_library)
|
||||||
|
, converter_(new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator(const std::string& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, int num_threads)
|
Iterator(const std::string& geometry_library, const ifcopenshell::geometry::Settings& settings, IfcParse::IfcFile* file, int num_threads)
|
||||||
: settings_(settings)
|
: settings_(settings)
|
||||||
, ifc_file(file)
|
, ifc_file(file)
|
||||||
, owns_ifc_file(false)
|
|
||||||
, num_threads_(num_threads)
|
, num_threads_(num_threads)
|
||||||
, geometry_library_(geometry_library)
|
, geometry_library_(geometry_library)
|
||||||
|
, converter_(new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -890,10 +887,6 @@ namespace IfcGeom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owns_ifc_file) {
|
|
||||||
delete ifc_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!settings_.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::NATIVE) {
|
if (!settings_.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::NATIVE) {
|
||||||
for (auto& p : all_processed_native_elements_) {
|
for (auto& p : all_processed_native_elements_) {
|
||||||
delete p;
|
delete p;
|
||||||
|
|||||||
@@ -79,7 +79,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) {
|
|||||||
} else {
|
} else {
|
||||||
// The parent placement of the current is a placement for a type that is
|
// The parent placement of the current is a placement for a type that is
|
||||||
// being ignored (Site or Building) or it is the host element of an opening.
|
// being ignored (Site or Building) or it is the host element of an opening.
|
||||||
result = taxonomy::cast<taxonomy::matrix4>(map(transform));
|
|
||||||
|
// Create a new copy around `result` so that it's cached copy is not altered
|
||||||
|
// @todo immutability
|
||||||
|
result = taxonomy::make<taxonomy::matrix4>(
|
||||||
|
taxonomy::cast<taxonomy::matrix4>(map(transform))->ccomponents()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fallback) {
|
if (fallback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user