IfcOpenShell / IfcOpenShell

Open source IFC library and geometry engine
GNU Lesser General Public License v3.0
1.81k stars 715 forks source link

CSG - Boolean Operations #2305

Closed TZwielehner closed 2 years ago

TZwielehner commented 2 years ago

Boolean results for CSG primitives don't fully work for me. The primitives themselves work. If I change the values via "get representation IFC parameters" the boolean operations suddenly work, but blender crashes after a few tries.

aothms commented 2 years ago

I'm not too familiar with the blenderbim internals. First thing to try would be to see how it performs in IfcConvert, and see if the file is valid with python -m ifcopenshell.validate.

TZwielehner commented 2 years ago

A bit more granular: UNION "works" (both shapes are present). INTERSECTION creates an empty, DIFFERENCE leads to the behavior mentioned above (blender crashes)

TZwielehner commented 2 years ago

I'm not too familiar with the blenderbim internals. First thing to try would be to see how it performs in IfcConvert, and see if the file is valid with python -m ifcopenshell.validate.

Validating doesn't throw an error

aothms commented 2 years ago

Can you attach an example?

TZwielehner commented 2 years ago

I modified a file from the "official examples"

ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [DesignTransferView_V1]'),'2;1');
FILE_NAME(
/* name */ '',
/* time_stamp */ '2016-02-04T08:47:55',
/* author */ ('Jon'),
/* organization */ ('Unknown'),
/* preprocessor_version */ 'GeomGymIFC by Geometry Gym Pty Ltd',
/* originating_system */ 'Unknown Application',
/* authorization */ 'None');

FILE_SCHEMA (('IFC4'));
ENDSEC;

DATA;
/* general entities required for all IFC data sets, defining the context for the exchange */
#1= IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,0.0001,#3,$);
#2= IFCCARTESIANPOINT((0.0,0.0,0.0));
#3= IFCAXIS2PLACEMENT3D(#2,$,$);
#4= IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Axis','Model',*,*,*,*,#1,$,.MODEL_VIEW.,$);
#5= IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Model',*,*,*,*,#1,$,.MODEL_VIEW.,$);
/* defines the default building (as required as the minimum spatial element)  */
#50= IFCBUILDING('39t4Pu3nTC4ekXYRIHJB9W',#56,'IfcBuilding',$,$,$,$,$,$,$,$,$);
#51= IFCPERSONANDORGANIZATION(#52,#53,$);
#52= IFCPERSON('Jon','Jon',$,$,$,$,$,$);
#53= IFCORGANIZATION($,'Geometry Gym Pty Ltd',$,$,$);
#54= IFCAPPLICATION(#55,'0.0.1.0','ggRhinoIFC - Geometry Gym Plug-in for Rhino3d','ggRhinoIFC');
#55= IFCORGANIZATION($,'Geometry Gym Pty Ltd',$,$,$);
#56= IFCOWNERHISTORY(#51,#54,$,.ADDED.,1454575675,$,$,1454575675);
#57= IFCRELCONTAINEDINSPATIALSTRUCTURE('3Sa3dTJGn0H8TQIGiuGQd5',#56,'Building','Building Container for Elements',(#225),#50);
#58= IFCAXIS2PLACEMENT3D(#2,$,$);
#100= IFCPROJECT('0$WU4A9R19$vKWO$AdOnKA',#56,'IfcProject',$,$,$,$,(#1),#101);
#101= IFCUNITASSIGNMENT((#102,#103,#104));
#102= IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
#103= IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
#104= IFCSIUNIT(*,.TIMEUNIT.,$,.SECOND.);
#105= IFCRELAGGREGATES('091a6ewbvCMQ2Vyiqspa7a',#56,'Project Container','Project Container for Buildings',#100,(#50));
#200= IFCSPHERE(#201,2000.0);
#201= IFCAXIS2PLACEMENT3D(#2,$,$);
#202= IFCROUNDEDRECTANGLEPROFILEDEF(.AREA.,'VoidProfile',$,1800.0,600.0,200.0);
#203= IFCAXIS2PLACEMENT3D(#204,$,$);
#204= IFCCARTESIANPOINT((1000.0,400.0,100.0));
#205= IFCDIRECTION((0.0,0.0,1.0));
#206= IFCEXTRUDEDAREASOLID(#202,#203,#205,700.0);
#207= IFCBOOLEANRESULT(.DIFFERENCE.,#200,#206);
#208= IFCCSGSOLID(#230);
#209= IFCREPRESENTATIONMAP(#210,#211);
#210= IFCAXIS2PLACEMENT3D(#2,$,$);
#211= IFCSHAPEREPRESENTATION(#5,'Body','SolidModel',(#232));
#212= IFCMATERIAL('Ceramic',$,$);
#213= IFCRELASSOCIATESMATERIAL('0Pkhszwjv1qRMYyCFg9fjB',#56,'MatAssoc','Material Associates',(#214),#212);
#214= IFCSANITARYTERMINALTYPE('1HarmwaPv3OeJSXpaoPKpg',#56,'Bath',$,$,$,(#209),$,$,.BATH.);
#215= IFCRELDEFINESBYTYPE('1lO$X3e3j9lfVMhNy4MzKB',#56,$,$,(#225),#214);
#216= IFCRELDECLARES('1acQrDhur9399Xqs2jQs4t',#56,$,$,#100,(#214));
#217= IFCDIRECTION((1.0,0.0,0.0));
#218= IFCDIRECTION((0.0,1.0,0.0));
#219= IFCCARTESIANPOINT((0.0,0.0,0.0));
#220= IFCCARTESIANTRANSFORMATIONOPERATOR3D(#217,#218,#219,1.0,#221);
#221= IFCDIRECTION((0.0,0.0,1.0));
#222= IFCMAPPEDITEM(#209,#220);
#223= IFCSHAPEREPRESENTATION(#5,'Body','MappedRepresentation',(#222));
#224= IFCPRODUCTDEFINITIONSHAPE($,$,(#223));
#225= IFCSANITARYTERMINAL('3$$o7C03j0KQeLnoj018fc',#56,$,$,$,#227,#224,$,$);
#226= IFCAXIS2PLACEMENT3D(#2,$,$);
#227= IFCLOCALPLACEMENT($,#226);
#228= IFCBLOCK(#201,2000.0,2000.0,2000.);
#229= IFCRECTANGULARPYRAMID(#201,2000.0,2000.0,2000.);
#230= IFCRIGHTCIRCULARCONE(#201,2000.0,2000.0);
#231= IFCRIGHTCIRCULARCYLINDER(#201,2000.0,2000.0);
#232= IFCCSGSOLID(#234);
#233= IFCCSGSOLID(#229);
#234= IFCBOOLEANRESULT(.DIFFERENCE.,#228,#206);
#235= IFCCSGSOLID(#234);
#236= IFCCSGSOLID(#200);
ENDSEC;

END-ISO-10303-21;
aothms commented 2 years ago

IfcConvert seems to process this just fine so could be something BlenderBIM specific, maybe @Moult can comment

afbeelding

TZwielehner commented 2 years ago

Blocks work fine on the beginning, after changing the dimensions a few times it breaks.

Moult commented 2 years ago

I played around with a few dimensions and it didn't break for me. Which parameters / numbers did you change exactly?

2022-07-22-133044_980x401_scrot

TZwielehner commented 2 years ago

Please try again with this line replaced #234= IFCBOOLEANRESULT(.DIFFERENCE.,#228,#230); First I don't see the substraction. When I change the height of the box it appears. If I change the height of the cone before that blender crashes.

Moult commented 2 years ago

@aothms I think what @TZwielehner means is that if you change 234 to to boolean 230 (a cone) instead of 206 (the extrusion) I don't seem to be able to get a result. It just hangs for me. I'm not quite sure exactly what change he's making though. Can you replicate this?

Moult commented 2 years ago

Still unsure exactly what changes @TZwielehner is making, which we need to replicate the issues... @TZwielehner can you elaborate?

Moult commented 2 years ago

Proposing to close bug in a week if we don't get material to replicate.

aothms commented 2 years ago

The cone case I could get to work.

afbeelding

It's a bit of a hypothetical example, we don't see these kind of cases in real world building models, but it wasn't overly hard to work around some of the assumptions in the code base to enable this.