mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
Merge remote-tracking branch 'ifcopenshell/v0.8.0' into bonsai/parametric-framework-features-pt2
This commit is contained in:
@@ -258,10 +258,14 @@ if(WITH_ROCKSDB)
|
||||
set(ROCKSDB_LIBRARIES "IFCOPENSHELL_RocksDB")
|
||||
target_compile_definitions(IFCOPENSHELL_RocksDB INTERFACE IFOPSH_WITH_ROCKSDB)
|
||||
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB)
|
||||
# Shared binaries for `rocksdb` only support limited API (only `c.h`), but we use `db.h` API.
|
||||
# So rocksdb supported only as a static library.
|
||||
# See https://github.com/facebook/rocksdb/issues/981.
|
||||
target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE RocksDB::rocksdb)
|
||||
if(TARGET RocksDB::rocksdb)
|
||||
target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE RocksDB::rocksdb)
|
||||
elseif(TARGET RocksDB::rocksdb-shared)
|
||||
target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE RocksDB::rocksdb-shared)
|
||||
else()
|
||||
message(FATAL_ERROR "RocksDB found but neither RocksDB::rocksdb nor RocksDB::rocksdb-shared target exists")
|
||||
endif()
|
||||
|
||||
if(WITH_ZSTD)
|
||||
# @todo do we actually need the zstd include dir or rather just pass
|
||||
|
||||
@@ -88,7 +88,15 @@ if(NOT HDF5_INCLUDE_DIR OR NOT HDF5_LIBRARY_DIR)
|
||||
mark_as_advanced(HDF5_DIR)
|
||||
if(HDF5_DIR)
|
||||
message(STATUS "HDF5: found config at '${HDF5_DIR}'.")
|
||||
set(HDF5_LIBRARIES hdf5_cpp-static)
|
||||
if(TARGET hdf5_cpp-static)
|
||||
set(HDF5_LIBRARIES hdf5_cpp-static)
|
||||
elseif(TARGET hdf5_cpp-shared)
|
||||
set(HDF5_LIBRARIES hdf5_cpp-shared)
|
||||
elseif(TARGET hdf5::hdf5_cpp-shared)
|
||||
set(HDF5_LIBRARIES hdf5::hdf5_cpp-shared)
|
||||
else()
|
||||
find_package(HDF5 REQUIRED COMPONENTS CXX)
|
||||
endif()
|
||||
else()
|
||||
# If it failed, still try to find as a module.
|
||||
# E.g. on Ubuntu `libhdf5-dev` doesn't provie hdf5-config.cmake.
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
ISO-10303-21;
|
||||
HEADER;
|
||||
FILE_DESCRIPTION(('ViewDefinition[DesignTransferView]'),'2;1');
|
||||
FILE_NAME('snap-target.ifc','2026-06-05T17:45:10-03:00',(''),(''),'IfcOpenShell 0.0.0','Bonsai 0.8.6-alpha260605-24a241a','Nobody');
|
||||
FILE_SCHEMA(('IFC4'));
|
||||
ENDSEC;
|
||||
DATA;
|
||||
#1=IFCPROJECT('2pZygwkcb1Au$5kgwmW6ZC',$,'My Project',$,$,$,$,(#10,#22),#5);
|
||||
#2=IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
|
||||
#3=IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.);
|
||||
#4=IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.);
|
||||
#5=IFCUNITASSIGNMENT((#4,#2,#3));
|
||||
#6=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#7=IFCDIRECTION((0.,0.,1.));
|
||||
#8=IFCDIRECTION((1.,0.,0.));
|
||||
#9=IFCAXIS2PLACEMENT3D(#6,#7,#8);
|
||||
#10=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#9,$);
|
||||
#11=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Model',*,*,*,*,#10,$,.MODEL_VIEW.,$);
|
||||
#12=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Axis','Model',*,*,*,*,#10,$,.GRAPH_VIEW.,$);
|
||||
#13=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Box','Model',*,*,*,*,#10,$,.MODEL_VIEW.,$);
|
||||
#14=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Model',*,*,*,*,#10,$,.SECTION_VIEW.,$);
|
||||
#15=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Model',*,*,*,*,#10,$,.ELEVATION_VIEW.,$);
|
||||
#16=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Model',*,*,*,*,#10,$,.MODEL_VIEW.,$);
|
||||
#17=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Model',*,*,*,*,#10,$,.PLAN_VIEW.,$);
|
||||
#18=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Profile','Model',*,*,*,*,#10,$,.ELEVATION_VIEW.,$);
|
||||
#19=IFCCARTESIANPOINT((0.,0.));
|
||||
#20=IFCDIRECTION((1.,0.));
|
||||
#21=IFCAXIS2PLACEMENT2D(#19,#20);
|
||||
#22=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Plan',2,1.E-05,#21,$);
|
||||
#23=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Axis','Plan',*,*,*,*,#22,$,.GRAPH_VIEW.,$);
|
||||
#24=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Plan',*,*,*,*,#22,$,.PLAN_VIEW.,$);
|
||||
#25=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Plan',*,*,*,*,#22,$,.PLAN_VIEW.,$);
|
||||
#26=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Annotation','Plan',*,*,*,*,#22,$,.REFLECTED_PLAN_VIEW.,$);
|
||||
#27=IFCSITE('1Lvnr1aSn2OP70jevISY_C',$,'My Site',$,$,#50,$,$,$,$,$,$,$,$);
|
||||
#33=IFCBUILDING('1NaNtC8Wf6YPU7CZRG8Z8Q',$,'My Building',$,$,#56,$,$,$,$,$,$);
|
||||
#39=IFCBUILDINGSTOREY('1k9kfaMOr2cvyNvxvoll27',$,'My Storey',$,$,#62,$,$,$,$);
|
||||
#45=IFCRELAGGREGATES('1plJGwDIHDzwuc7i7gcQQD',$,$,$,#1,(#27));
|
||||
#46=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#47=IFCDIRECTION((0.,0.,1.));
|
||||
#48=IFCDIRECTION((1.,0.,0.));
|
||||
#49=IFCAXIS2PLACEMENT3D(#46,#47,#48);
|
||||
#50=IFCLOCALPLACEMENT($,#49);
|
||||
#51=IFCRELAGGREGATES('13KnzD8ZT8bAvAyOQAWiUj',$,$,$,#27,(#33));
|
||||
#52=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#53=IFCDIRECTION((0.,0.,1.));
|
||||
#54=IFCDIRECTION((1.,0.,0.));
|
||||
#55=IFCAXIS2PLACEMENT3D(#52,#53,#54);
|
||||
#56=IFCLOCALPLACEMENT(#50,#55);
|
||||
#57=IFCRELAGGREGATES('2Hf4WQLJvE4O43wq$0AZeu',$,$,$,#33,(#39));
|
||||
#58=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#59=IFCDIRECTION((0.,0.,1.));
|
||||
#60=IFCDIRECTION((1.,0.,0.));
|
||||
#61=IFCAXIS2PLACEMENT3D(#58,#59,#60);
|
||||
#62=IFCLOCALPLACEMENT(#56,#61);
|
||||
#63=IFCPROPERTYSINGLEVALUE('Symbol',$,IFCLABEL('setout-point'),$);
|
||||
#64=IFCPROPERTYSET('27lmSbeAXC08EWkEq8XdUG',$,'EPset_Annotation',$,(#63));
|
||||
#65=IFCTYPEPRODUCT('0UrP0fLdD5OwzwD41aRKao',$,'SETOUT-POINT',$,'IfcAnnotation/SYMBOL',(#64),$,$);
|
||||
#66=IFCCARTESIANPOINTLIST3D(((-8999.9990234375,-8999.9990234375,0.),(8999.9990234375,-8999.9990234375,0.),(-8999.9990234375,8999.9990234375,0.),(8999.9990234375,8999.9990234375,0.)));
|
||||
#67=IFCINDEXEDPOLYGONALFACE((1,2,4,3));
|
||||
#68=IFCPOLYGONALFACESET(#66,$,(#67),$);
|
||||
#69=IFCSHAPEREPRESENTATION(#11,'Body','Tessellation',(#68));
|
||||
#70=IFCBUILDINGELEMENTPROXY('3Avrn7zrPBiA7RUh91ENg9',$,'Plane',$,$,#142,#72,$,.COMPLEX.);
|
||||
#71=IFCRELCONTAINEDINSPATIALSTRUCTURE('0ftVF1Vf1Dmg$p62mtpWVF',$,$,$,(#123,#70,#108),#39);
|
||||
#72=IFCPRODUCTDEFINITIONSHAPE($,$,(#69));
|
||||
#108=IFCBUILDINGELEMENTPROXY('1lwURx5YX5WAXD5ExqQt31',$,'Plane',$,$,#122,#117,$,.COMPLEX.);
|
||||
#114=IFCCARTESIANPOINTLIST3D(((-5999.99951171875,-2999.99975585938,0.),(5999.99951171875,-2999.99975585938,0.)));
|
||||
#115=IFCINDEXEDPOLYCURVE(#114,(IFCLINEINDEX((1,2))),$);
|
||||
#116=IFCSHAPEREPRESENTATION(#11,'Body','Curve3D',(#115));
|
||||
#117=IFCPRODUCTDEFINITIONSHAPE($,$,(#116));
|
||||
#118=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#119=IFCDIRECTION((0.,0.,1.));
|
||||
#120=IFCDIRECTION((1.,0.,0.));
|
||||
#121=IFCAXIS2PLACEMENT3D(#118,#119,#120);
|
||||
#122=IFCLOCALPLACEMENT(#62,#121);
|
||||
#123=IFCBUILDINGELEMENTPROXY('2X4YMFxHjANvnkl1Hzqjlq',$,'Plane',$,$,#137,#132,$,.COMPLEX.);
|
||||
#129=IFCCARTESIANPOINTLIST3D(((3000.,-5999.99951171875,0.),(2999.99951171875,5999.99951171875,0.)));
|
||||
#130=IFCINDEXEDPOLYCURVE(#129,(IFCLINEINDEX((1,2))),$);
|
||||
#131=IFCSHAPEREPRESENTATION(#11,'Body','Curve3D',(#130));
|
||||
#132=IFCPRODUCTDEFINITIONSHAPE($,$,(#131));
|
||||
#133=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#134=IFCDIRECTION((0.,0.,1.));
|
||||
#135=IFCDIRECTION((1.,0.,0.));
|
||||
#136=IFCAXIS2PLACEMENT3D(#133,#134,#135);
|
||||
#137=IFCLOCALPLACEMENT(#62,#136);
|
||||
#138=IFCCARTESIANPOINT((0.,0.,0.));
|
||||
#139=IFCDIRECTION((0.,0.,1.));
|
||||
#140=IFCDIRECTION((1.,0.,0.));
|
||||
#141=IFCAXIS2PLACEMENT3D(#138,#139,#140);
|
||||
#142=IFCLOCALPLACEMENT(#62,#141);
|
||||
ENDSEC;
|
||||
END-ISO-10303-21;
|
||||
@@ -296,6 +296,63 @@ def test_snap_far_from_origin(window):
|
||||
yield from preset_event_simulate(window, "RET", "TAP", x, y)
|
||||
yield "FINISHED"
|
||||
|
||||
def test_snap_targets(window):
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", 0, 0)
|
||||
area, region = get_area_and_region(window)
|
||||
x = round(area.width * 0.44 + area.x)
|
||||
y = round(area.height * 0.73 + area.y)
|
||||
|
||||
yield from preset_event_simulate(window, "ESC", "TAP", x, y)
|
||||
|
||||
options = []
|
||||
props = tool.Snap.get_snap_props()
|
||||
try:
|
||||
annotations = props.__annotations__
|
||||
except AttributeError:
|
||||
annotations = type(props).__annotations__
|
||||
for prop in annotations.keys():
|
||||
if getattr(props, prop):
|
||||
options.append((prop, props.rna_type.properties[prop].name))
|
||||
|
||||
for prop, name in options:
|
||||
any(setattr(props, prop2, prop2 == prop) for prop2, _ in options) # set prop to true and others to false
|
||||
measure_settings = tool.Project.get_measure_tool_settings()
|
||||
measure_settings.measurement_type = "POLYLINE"
|
||||
for obj in tool.Blender.get_selected_objects():
|
||||
obj.select_set(False)
|
||||
with bpy.context.temp_override(area=area, region=region, space_data=area.spaces[0]):
|
||||
bpy.ops.bim.measure_tool("INVOKE_DEFAULT", measure_type="POLYLINE")
|
||||
snap_types = []
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", x, y)
|
||||
yield from preset_event_simulate(window, "LEFTMOUSE", "TAP", x, y)
|
||||
snap_type = tool.Model.get_polyline_props().snap_mouse_point[0].snap_type
|
||||
snap_types.append(snap_type)
|
||||
|
||||
new_x = x + 200
|
||||
new_y = y - 55
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "LEFTMOUSE", "TAP", x, y)
|
||||
snap_type = tool.Model.get_polyline_props().snap_mouse_point[0].snap_type
|
||||
snap_types.append(snap_type)
|
||||
|
||||
new_x = x + 130
|
||||
new_y = y - 358
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "MOUSEMOVE", "NOTHING", new_x, new_y)
|
||||
yield from preset_event_simulate(window, "LEFTMOUSE", "TAP", x, y)
|
||||
snap_type = tool.Model.get_polyline_props().snap_mouse_point[0].snap_type
|
||||
snap_types.append(snap_type)
|
||||
|
||||
yield from preset_event_simulate(window, "ESC", "TAP", x, y)
|
||||
assert_msg = f"{name} should be in snap_types: {snap_types}"
|
||||
assert name in snap_types
|
||||
_assert_pass(assert_msg)
|
||||
|
||||
def test_draw_polyline_wall(window, x, y):
|
||||
yield from preset_event_simulate(window, "ESC", "TAP", x, y)
|
||||
area, region = get_area_and_region(window)
|
||||
@@ -358,6 +415,13 @@ def run_tests():
|
||||
lambda w=window: test_snap_in_xray_mode(w),
|
||||
lambda w=window: test_snap_far_from_origin(w),
|
||||
]
|
||||
elif module_name == "snap-target":
|
||||
filepath = f"./test/files/snap-target.ifc"
|
||||
bpy.ops.bim.load_project(filepath=filepath)
|
||||
window = _get_valid_window()
|
||||
test_queue = [
|
||||
lambda w=window: test_snap_targets(w),
|
||||
]
|
||||
else:
|
||||
cleanup()
|
||||
|
||||
|
||||
@@ -149,8 +149,12 @@ namespace {
|
||||
|
||||
template <>
|
||||
struct dispatch_conversion<ifcopenshell::geometry::taxonomy::type_by_kind::max> {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, ifcopenshell::geometry::taxonomy::kinds, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) {
|
||||
Logger::Error("No conversion for " + std::to_string(item->kind()));
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, ifcopenshell::geometry::taxonomy::kinds, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) {
|
||||
std::string created_from;
|
||||
if (item->instance) {
|
||||
created_from = " (created from " + item->instance->declaration().name() + ")";
|
||||
}
|
||||
Logger::Error("No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -169,8 +173,12 @@ namespace {
|
||||
|
||||
template <>
|
||||
struct dispatch_with_upgrade<ifcopenshell::geometry::taxonomy::upgrades::max> {
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) {
|
||||
Logger::Error("No conversion with upgrade for " + std::to_string(item->kind()));
|
||||
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr& item, IfcGeom::ConversionResults&) {
|
||||
std::string created_from;
|
||||
if (item->instance) {
|
||||
created_from = " (created from " + item->instance->declaration().name() + ")";
|
||||
}
|
||||
Logger::Error("No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,13 +35,25 @@ namespace IfcGeom {
|
||||
class Transformation {
|
||||
private:
|
||||
ifcopenshell::geometry::Settings settings_;
|
||||
ifcopenshell::geometry::taxonomy::matrix4::ptr matrix_;
|
||||
ifcopenshell::geometry::taxonomy::matrix4::ptr matrix_, matrix_orig_units_;
|
||||
public:
|
||||
Transformation(const ifcopenshell::geometry::Settings& settings, const ifcopenshell::geometry::taxonomy::matrix4::ptr& matrix)
|
||||
: settings_(settings)
|
||||
, matrix_(matrix)
|
||||
{}
|
||||
Transformation(const ifcopenshell::geometry::Settings& settings, const ifcopenshell::geometry::taxonomy::matrix4::ptr& matrix)
|
||||
: settings_(settings), matrix_(matrix)
|
||||
{
|
||||
const bool convert = settings.get<ifcopenshell::geometry::settings::ConvertBackUnits>().get();
|
||||
auto unit_magnitude = settings.get<ifcopenshell::geometry::settings::LengthUnit>().get();
|
||||
if (matrix_ && convert && unit_magnitude != 1.0) {
|
||||
matrix_orig_units_ = ifcopenshell::geometry::taxonomy::make<ifcopenshell::geometry::taxonomy::matrix4>(*matrix);
|
||||
// only multiple the translation components of the matrix with the unit magnitude, not the rotation/scaling components
|
||||
matrix_orig_units_->components().col(3).head<3>() /= unit_magnitude;
|
||||
} else {
|
||||
matrix_orig_units_ = nullptr;
|
||||
}
|
||||
}
|
||||
const ifcopenshell::geometry::taxonomy::matrix4::ptr& data() const {
|
||||
if (matrix_orig_units_) {
|
||||
return matrix_orig_units_;
|
||||
}
|
||||
if (matrix_) {
|
||||
return matrix_;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,16 @@ template <typename Kernel>
|
||||
using plane_map = std::map<typename Kernel::Plane_3, typename Kernel::Plane_3, PlaneLess<Kernel>>;
|
||||
// using plane_map = std::unordered_map<typename Kernel::Plane_3, typename Kernel::Plane_3, PlaneHash<Kernel>>;
|
||||
|
||||
// Lexicographic comparator for CGAL Point_d (operator< is deleted in CGAL 6.x)
|
||||
struct Point_d_4d_Less {
|
||||
using Point_d = CGAL::Epick_d<CGAL::Dimension_tag<4>>::Point_d;
|
||||
bool operator()(const Point_d& a, const Point_d& b) const {
|
||||
return std::lexicographical_compare(
|
||||
a.cartesian_begin(), a.cartesian_end(),
|
||||
b.cartesian_begin(), b.cartesian_end());
|
||||
}
|
||||
};
|
||||
|
||||
// Snap halfspace planes
|
||||
// search_radius: max cartesian distance in plane equation parameters as 4d points in space
|
||||
template <typename Kernel>
|
||||
@@ -131,8 +141,8 @@ plane_map<Kernel> snap_halfspaces(const std::list<CGAL::Plane_3<Kernel>>& planes
|
||||
|
||||
plane_map<Kernel> result;
|
||||
|
||||
std::map<Point_d, std::set<Point_d>> neighbours;
|
||||
std::map<Point_d, std::list<CGAL::Plane_3<Kernel>>> originals;
|
||||
std::map<Point_d, std::set<Point_d, Point_d_4d_Less>, Point_d_4d_Less> neighbours;
|
||||
std::map<Point_d, std::list<CGAL::Plane_3<Kernel>>, Point_d_4d_Less> originals;
|
||||
std::vector<Point_d> planes_as_point;
|
||||
|
||||
for (auto& p : planes) {
|
||||
@@ -205,7 +215,7 @@ plane_map<Kernel> snap_halfspaces_2(const std::list<CGAL::Plane_3<Kernel>>& plan
|
||||
plane_map<Kernel> result;
|
||||
|
||||
std::vector<Point_d> planes_as_point;
|
||||
std::map<Point_d, CGAL::Plane_3<Kernel>> normalized_to_original;
|
||||
std::map<Point_d, CGAL::Plane_3<Kernel>, Point_d_4d_Less> normalized_to_original;
|
||||
|
||||
for (auto& p : planes_fixed) {
|
||||
// @todo can we skip normalization (simply divide by largest component perhaps)
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <stack>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <cstdint>
|
||||
#include <BRepExtrema_TriangleSet.hxx>
|
||||
#include <BRepLProp_SLProps.hxx>
|
||||
#include <BVH_BinaryTree.hxx>
|
||||
|
||||
@@ -136,17 +136,39 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity*
|
||||
for (auto entity_part : parts) {
|
||||
bool is_manifold = util::is_manifold(entity_part);
|
||||
|
||||
if (!is_manifold) {
|
||||
// force sewing, edge identity might have been mudied by FixAdvFace.FixOrientation.MSG5 to fix interior loop winding order
|
||||
TopTools_ListOfShape list;
|
||||
IfcGeom::util::shape_to_face_list(entity_part, list);
|
||||
IfcGeom::util::create_solid_from_faces(list, entity_part, settings_.get<settings::Precision>().get(), true);
|
||||
is_manifold = util::is_manifold(entity_part);
|
||||
if (is_manifold) {
|
||||
Logger::Warning("Successfully sewed non-manifold first operand");
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_manifold) {
|
||||
if (settings_.get<settings::MakeVolume>().get()) {
|
||||
BOPAlgo_MakerVolume mv;
|
||||
mv.AddArgument(entity_part);
|
||||
mv.SetAvoidInternalShapes(true);
|
||||
// mv.SetFuzzyValue(settings_.get<settings::Precision>().get());
|
||||
std::optional<std::string> failure;
|
||||
try {
|
||||
mv.Perform();
|
||||
entity_part = mv.Shape();
|
||||
Logger::Warning("Sucessfully detected exterior volume to non-manifold first operand");
|
||||
auto entity_part_2 = mv.Shape();
|
||||
if (IfcGeom::util::count(entity_part_2, TopAbs_FACE) == 0) {
|
||||
failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE));
|
||||
} else {
|
||||
is_manifold = util::is_manifold(entity_part_2);
|
||||
Logger::Warning(std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")));
|
||||
entity_part = entity_part_2;
|
||||
}
|
||||
} catch (const Standard_Failure& e) {
|
||||
Logger::Warning("MakeVolume failed: " + std::string(e.GetMessageString()), entity);
|
||||
failure.emplace(e.GetMessageString());
|
||||
}
|
||||
if (failure) {
|
||||
Logger::Warning("MakeVolume failed: " + *failure, entity);
|
||||
}
|
||||
} else {
|
||||
Logger::Warning("Non-manifold first operand, use --make-volume to try and make manifold");
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "clash_utils.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cfloat>
|
||||
|
||||
#define GU_CULLING_EPSILON_RAY_TRIANGLE FLT_EPSILON*FLT_EPSILON
|
||||
#define PX_MAX_F32 3.4028234663852885981170418348452e+38F
|
||||
|
||||
@@ -154,7 +154,13 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
|
||||
|
||||
typedef std::array<int, 2> edge_t;
|
||||
typedef std::set<edge_t> edge_set_t;
|
||||
std::set<edge_set_t> edge_sets;
|
||||
// When a single face fills an interior loop, their edge_sets (canonicalized edges) will be identical.
|
||||
// We can differentiate in this scenario in two ways:
|
||||
// - std::map<edge_t, bool> retain the edge order from the bool passed to the loop_() lambda
|
||||
// - std::pair<bool, edge_set_t> with pair::first populated from external (FaceBound / OuterBound)
|
||||
// The second has been found more reliable for typical models, because inner bound winding can be wrong.
|
||||
// The can be made more resilient by first checking correct population of external and falling back to approach 1.
|
||||
std::set<std::pair<bool, edge_set_t>> edge_sets;
|
||||
|
||||
for (auto& loop : loops) {
|
||||
std::vector<std::pair<int, int> > segments;
|
||||
@@ -165,12 +171,12 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
|
||||
segments.push_back(std::make_pair(C, D));
|
||||
});
|
||||
|
||||
if (edge_sets.find(segment_set) != edge_sets.end()) {
|
||||
if (edge_sets.find({loop->external.get_value_or(false), segment_set}) != edge_sets.end()) {
|
||||
duplicate_faces++;
|
||||
duplicates_.insert(loop->identity());
|
||||
continue;
|
||||
}
|
||||
edge_sets.insert(segment_set);
|
||||
edge_sets.insert({loop->external.get_value_or(false), segment_set});
|
||||
|
||||
if (segments.size() >= 3) {
|
||||
for (auto& p : segments) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../../ifcparse/IfcLogger.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <cstdint>
|
||||
|
||||
#define INCLUDE_SCHEMA(x) STRINGIFY(../../ifcparse/x.h)
|
||||
#include INCLUDE_SCHEMA(IfcSchema)
|
||||
|
||||
+14
-7
@@ -17,6 +17,13 @@
|
||||
#include <tuple>
|
||||
#include <exception>
|
||||
#include <numeric>
|
||||
#include <cstdint>
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifndef TAXONOMY_USE_UNIQUE_PTR
|
||||
#ifndef TAXONOMY_USE_NAKED_PTR
|
||||
@@ -1625,19 +1632,19 @@ typedef item const* ptr;
|
||||
// @todo Sad... now that we have templated collection members,
|
||||
// we can't generally use collection_base anymore as a cast target.
|
||||
if (auto s = std::dynamic_pointer_cast<taxonomy::collection>(i)) {
|
||||
visit<taxonomy::collection>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::collection>(s, fn);
|
||||
} else if (auto s = std::dynamic_pointer_cast<taxonomy::loop>(i)) {
|
||||
visit<taxonomy::loop>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::loop>(s, fn);
|
||||
} else if (auto s = std::dynamic_pointer_cast<taxonomy::face>(i)) {
|
||||
visit<taxonomy::face>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::face>(s, fn);
|
||||
} else if (auto s = std::dynamic_pointer_cast<taxonomy::shell>(i)) {
|
||||
visit<taxonomy::shell>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::shell>(s, fn);
|
||||
} else if (auto s = std::dynamic_pointer_cast<taxonomy::solid>(i)) {
|
||||
visit<taxonomy::solid>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::solid>(s, fn);
|
||||
} else if (auto s = std::dynamic_pointer_cast<taxonomy::loft>(i)) {
|
||||
visit<taxonomy::loft>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::loft>(s, fn);
|
||||
} else if (auto s = std::dynamic_pointer_cast<taxonomy::boolean_result>(i)) {
|
||||
visit<taxonomy::boolean_result>(s, fn);
|
||||
ifcopenshell::geometry::visit<taxonomy::boolean_result>(s, fn);
|
||||
}
|
||||
else {
|
||||
fn(i);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class aggregate_of_instance;
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace {
|
||||
if (character >= 0x20 && character <= 0x7e) {
|
||||
stream.put((char)character);
|
||||
} else {
|
||||
stream << "\\u" << character;
|
||||
stream << "\\u" << static_cast<uint32_t>(character);
|
||||
}
|
||||
});
|
||||
return stream.str();
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/logic/tribool.hpp>
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
#include <rocksdb/table.h>
|
||||
#include <rocksdb/convenience.h>
|
||||
#include <rocksdb/version.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -410,10 +413,8 @@ IfcUtil::IfcBaseClass* IfcParse::impl::rocks_db_file_storage::assert_existance(s
|
||||
}
|
||||
|
||||
namespace {
|
||||
rocksdb::DB* init_db(const std::string& filepath, bool readonly) {
|
||||
rocksdb::DB* db = nullptr;
|
||||
std::unique_ptr<rocksdb::DB> init_db(const std::string& filepath, bool readonly) {
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
|
||||
rocksdb::Options options;
|
||||
// options.disable_auto_compactions = true;
|
||||
options.create_if_missing = true;
|
||||
@@ -445,16 +446,31 @@ namespace {
|
||||
options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tbo));
|
||||
|
||||
rocksdb::Status status;
|
||||
std::unique_ptr<rocksdb::DB> db;
|
||||
if (readonly) {
|
||||
#if ROCKSDB_MAJOR > 9 || (ROCKSDB_MAJOR == 9 && ROCKSDB_MINOR >= 11)
|
||||
status = rocksdb::DB::OpenForReadOnly(options, filepath, &db);
|
||||
#else
|
||||
rocksdb::DB* raw = nullptr;
|
||||
status = rocksdb::DB::OpenForReadOnly(options, filepath, &raw);
|
||||
db.reset(raw);
|
||||
#endif
|
||||
} else {
|
||||
#if ROCKSDB_MAJOR > 9 || (ROCKSDB_MAJOR == 9 && ROCKSDB_MINOR >= 11)
|
||||
status = rocksdb::DB::Open(options, filepath, &db);
|
||||
#else
|
||||
rocksdb::DB* raw = nullptr;
|
||||
status = rocksdb::DB::Open(options, filepath, &raw);
|
||||
db.reset(raw);
|
||||
#endif
|
||||
}
|
||||
if (!status.ok()) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif // IFOPSH_WITH_ROCKSDB#
|
||||
return db;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,12 +479,12 @@ IfcParse::impl::rocks_db_file_storage::rocks_db_file_storage(const std::string&
|
||||
: file(ffile)
|
||||
, db(init_db(filepath, readonly))
|
||||
// @todo streaming serializer does not populate the byguid map
|
||||
, byguid_internal_(db, "g|")
|
||||
, byguid_internal_(db.get(), "g|")
|
||||
, byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](IfcUtil::IfcBaseClass* v) { return v->identity(); })
|
||||
, instance_ids_(db, "i|")
|
||||
, instance_ids_(db.get(), "i|")
|
||||
, instance_by_name_(&instance_ids_, [this](size_t v) { return assert_existance(v, entityinstance_ref); })
|
||||
, bytype_(db, "t|")
|
||||
, byref_excl_(db, "v|")
|
||||
, bytype_(db.get(), "t|")
|
||||
, byref_excl_(db.get(), "v|")
|
||||
// @todo by_identity is probably not correct here, this mapping is Name -> Identity, so Fn should have access to full pair?
|
||||
// , byidentity_(&byid_, [this](size_t v) { return assert_existance(v, by_identity); }, [](IfcUtil::IfcBaseClass* v) { return v->identity(); })
|
||||
{
|
||||
@@ -491,7 +507,6 @@ IfcParse::impl::rocks_db_file_storage::~rocks_db_file_storage()
|
||||
assert(s.ok());
|
||||
|
||||
db->Close();
|
||||
delete db;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
#include <rocksdb/merge_operator.h>
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#include <algorithm>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace IfcParse {
|
||||
class declaration;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
struct is_std_tuple : std::false_type {};
|
||||
|
||||
@@ -25,10 +25,13 @@ namespace rocksdb {
|
||||
|
||||
#include <variant>
|
||||
#include <iterator>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#ifndef SWIG
|
||||
|
||||
@@ -306,7 +309,7 @@ namespace IfcParse {
|
||||
|
||||
class IFC_PARSE_API rocks_db_file_storage {
|
||||
public:
|
||||
rocksdb::DB* db;
|
||||
std::unique_ptr<rocksdb::DB> db;
|
||||
rocksdb::WriteOptions wopts;
|
||||
rocksdb::ReadOptions ropts;
|
||||
IfcParse::IfcFile* file;
|
||||
|
||||
@@ -33,6 +33,10 @@ variant - which is the maximum size of its constituents - is reduced.
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
|
||||
#include "IfcException.h"
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "../ifcparse/utils.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef WITH_PROJ
|
||||
#include <proj.h>
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef USE_BINARY
|
||||
#define write_shape write_binary
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include <rocksdb/options.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include "../ifcparse/IfcLogger.h"
|
||||
|
||||
RocksDbSerializer::RocksDbSerializer(IfcParse::IfcFile* file, const std::string& rocksdb_filename)
|
||||
|
||||
Reference in New Issue
Block a user