GDML icon indicating copy to clipboard operation
GDML copied to clipboard

Elliptical Cuts

Open Alex2671 opened this issue 1 year ago • 44 comments

Greetings! When i press the cut button, i have following prompt:

[<SelectionObject>,<SelectionObject>] Boolean Cut

but nothing happened. What could it be? With part workbench it runs fine meanwhile.

FreeCAD 0.20.2 GDML - last Release

Alex2671 avatar Mar 30 '23 13:03 Alex2671

Actually i figure out what is happening: when i cut two objects, one of them are pulled out from cut base property and falling under element tree. Then, when its to be sticked again we just need to recompute object to see it properly.

Alex2671 avatar Mar 30 '23 14:03 Alex2671

Is that the cut button in the GDML workbench or the Part workbench?

The Boolean operations in the GDML workbench assume that there is one GDML object per Part/(Volume) and you select the two Parts for the boolean operation.

From you last comment, I will check if there is a missing recompute following the Cut.

KeithSloan avatar Mar 30 '23 14:03 KeithSloan

Okay checked the code and a GDML boolean operation creates a new Object for which a recompute was performed, but not for the Tool and Base Object that get removed. Have push an update that will now do a Document recompute for GDML booleans. Interested to know if this fixes the issue you are seeing.

KeithSloan avatar Mar 30 '23 14:03 KeithSloan

test.gdml.zip

And there is one more: as you can see at Bool_Cut object, when i do cuts with y axis translations, it is not saving the object in good manner. Even after editing, saving and reopen it states on the brocken place. May be it also couldn't work with x-translation, i didn't test it.

https://github.com/KeithSloan/GDML/issues/108#issuecomment-1490401375 Hm, interesting behavior!

Alex2671 avatar Mar 31 '23 07:03 Alex2671

Okay I am trying to recreate. If I create the two Ellipitical Tubes and Cut I get

AfterCut-worldVOL.gdml.txt BeforeCut.FCStd.txt AfterCut.FCStd.txt

The translation that at issue is and the tube ElTube_007 ?

At what point are you applying the y translation? Is it being applied to the GDML Object ElTube_007 or the Part that contains the ElTube_007 before the Cut?

KeithSloan avatar Mar 31 '23 10:03 KeithSloan

BeforeCutObjPlacement.FCStd.txt BeforeCutPartPlacement.FCStd.txt

If the translation is applied to the Part before the boolean, for me it seems to be okay. If the translation is applied to the GDMLObject before the boolean, the translation is lost.

Is this what you are also seeing.

KeithSloan avatar Mar 31 '23 11:03 KeithSloan

Have pushed a fix for Boolean Cut Placement.Bases

Rotations not yet handled and needs to be applied to booleans other than Cut.

Would appreciate if you could test, so that can at least apply to other booleans.

KeithSloan avatar Mar 31 '23 16:03 KeithSloan

Other booleans Placement Bases fix pushed.

KeithSloan avatar Mar 31 '23 17:03 KeithSloan

Now it works good with thanslations. But still in bool cut operation base property not filled out. I still should do it by myself.

And one more I found wondering: when you point, for example, dz for box or tube, it means full length along z, but for ELTube it says a half width along z axis. Shouldn't it be full length, since its not a radius?

Alex2671 avatar Apr 03 '23 08:04 Alex2671

"Now it works good with thanslations. But still in bool cut operation base property not filled out. I still should do it by myself"

There have been a number of updates to the code, please could you check this is with latest code

This is what I am seeing with test files, one where change of Placement is in Part and the other in GDMLElTube

Base seems to be set to me.

Image 03-04-2023 at 11 59

Image 03-04-2023 at 11 59 BeforeCutObjPlacement.FCStd.txt BeforeCutPartPlacement.FCStd.txt

Manual says

3.4.4 Elliptical Tube The GDML Elliptical Tube is formed using 3 dimensions: dx x semi axis dy y semi axis dz z semi axis

You are correct, what is implemented, z is treated as full length.

Need to check which is correct.

KeithSloan avatar Apr 03 '23 11:04 KeithSloan

ElTube looks correct in Geant4, so assume there is an error in the manaul and I need to change the description in the GDML ElTube property description.

Image 03-04-2023 at 12 29

KeithSloan avatar Apr 03 '23 11:04 KeithSloan

I do a bit different cut, when one object included in another: 1 and i get 2 But your method works perfectly.

Alex2671 avatar Apr 03 '23 11:04 Alex2671

I do a bit different cut, when one object included in another: 1 and i get 2 But your method works perfectly.

Okay - Now able to reproduce the problem you are seeing, will see what we can do.

KeithSloan avatar Apr 03 '23 12:04 KeithSloan

Booleans should be between objects that have a SHAPE. App::Parts really should not be used as the base and tool of boolean operations, even if they some times seem to work. So the items in the last figure that should be selected for cutting are the GMLElTube and GDMLElTube001 and not the Parts they are in.

mhindi2 avatar Apr 04 '23 15:04 mhindi2

Booleans should be between objects that have a SHAPE. App::Parts really should not be used as the base and tool of boolean operations, even if they some times seem to work. So the items in the last figure that should be selected for cutting are the GMLElTube and GDMLElTube001 and not the Parts they are in.

Note: That is not how it is currently coded. The selection is checking for a part.

If I switch to using selecting of GDMLobjects, what should happen about the Placement of the Part of the second Object? Ignore? or find parent?

KeithSloan avatar Apr 04 '23 15:04 KeithSloan

I would check for shape, not GDMLObject (hasattr(obj, 'Shape')). I believe the current code (that I fixed!) takes into account BOTH placements, but I will double check.

mhindi2 avatar Apr 04 '23 15:04 mhindi2

But it could have a Shape and not be a GDML Object.

"The code you fixed" Is that in your repro?

KeithSloan avatar Apr 04 '23 15:04 KeithSloan

Yes, that's the hole point. The user should be able to do booleans with any solid, not just GDML objects. One should think of GDMLobjects as new specialized solids, but boolean operations should operate on any solid, not just the specialized solid.

The last branch I pushed and that you already merged into Main already has the code to to take into account the placement of both tool abd base Parts. Check the code in BooleanCutFeature.

mhindi2 avatar Apr 04 '23 15:04 mhindi2

"Yes, that's the hole point. The user should be able to do booleans with any solid, not just GDML objects. One should think of GDMLobjects as new specialized solids, but boolean operations should operate on any solid, not just the specialized solid."

But when the Non GDML object with a Shape gets exported, how is that handled? surely better to have a GDMLBoolean that will only allow booleans of GDMLObjects.

Things can have Shapes, that have no GDML equivalent,

KeithSloan avatar Apr 04 '23 16:04 KeithSloan

Under the Part workbench if you try a cut with a Part that has sub parts:

Screenshot_20230404_090126

You get the error

09:02:12 Traceback (most recent call last): File "", line 1, in <class 'ValueError'>: 'Group' is not part of the enumeration in Unnamed1#Cut.ViewObject.DisplayMode

and the following is produced

Screenshot_20230404_085150

Now our current code only selects the first of the to objects and would work. Should discuss this offline before deciding on best approach.

mhindi2 avatar Apr 04 '23 16:04 mhindi2

"Should discuss this offline before deciding on best approach."

AGREED

KeithSloan avatar Apr 04 '23 16:04 KeithSloan

@KeithSloan

We do export non GDML objects and booleans thereof and have been for a very long time. Extrusions, Revolutions, ... etc.

mhindi2 avatar Apr 04 '23 16:04 mhindi2

"We do export non GDML objects and booleans thereof and have been for a very long time. Extrusions, Revolutions, ... etc."

So the export code will handle a boolean of a GDML object and Extrusion or Revolution?

But there is nothing to stop the user creating a non supported Shape will the export code just ignore, report the issue?

KeithSloan avatar Apr 04 '23 16:04 KeithSloan

Yes, the export code does handle booleans of GDML and non GDML objects, as long as there is an exporter for that particular solid. At present if there is no exporter, the solid will be skipped. We should add a message to that effect. Check your email.

mhindi2 avatar Apr 04 '23 16:04 mhindi2

Yes, we currently do support export of booleans of GDML and (supported) non-GDML solids: Screenshot_20230404_093329

In case it is hard to see, above is a cut between a GDMLBox and a sphere (Part sphere, not GDMLSphere). Export works fine.

mhindi2 avatar Apr 04 '23 16:04 mhindi2

I do a bit different cut, when one object included in another: 1 and i get 2 But your method works perfectly.

Doing a boolean operation between a volume and one of its descendants is really a little strange. If you do the operation under the Part workbench, you will get a result, but even there, the Part workbench complains:

15:54:13 Traceback (most recent call last): File "", line 1, in <class 'ValueError'>: 'Group' is not part of the enumeration in AlexTest#Cut.ViewObject.DisplayMode 15:54:13 Part::Cut: Link(s) to object(s) 'LV_EllipticalTube LV_EllipticalTube001' go out of the allowed scope 'Cut'. Instead, the linked object(s) reside within 'worldVOL worldVOL'.

Best have the operands of the boolean operation on the same level, not one contained within the other

mhindi2 avatar Apr 04 '23 22:04 mhindi2

Actually, export to gdml far from ideal. Some details should be tuned after saving to gdml, but i fine with it. More crucial, there is objects that permanently lose their position, etc. For example GEARS.gdml.zip For now ELTube110 and Box098 has y position translation on -70 mm and -140 mm accordingly. Whereas initially Box099 had +70 mm translation through the y axis. After editing of placement, there is no changes occurs.

Alex2671 avatar Apr 17 '23 07:04 Alex2671

Actually, export to gdml far from ideal. Some details should be tuned after saving to gdml, but i fine with it. More crucial, there is objects that permanently lose their position, etc. For example GEARS.gdml.zip For now ELTube110 and Box098 has y position translation on -70 mm and -140 mm accordingly. Whereas initially Box099 had +70 mm translation through the y axis. After editing of placement, there is no changes occurs.

Please could you supply the FreeCAD file for GEARS that you are exporting - Thanks

KeithSloan avatar Apr 17 '23 07:04 KeithSloan

Actually, export to gdml far from ideal. Some details should be tuned after saving to gdml, but i fine with it. More crucial, there is objects that permanently lose their position, etc. For example GEARS.gdml.zip For now ELTube110 and Box098 has y position translation on -70 mm and -140 mm accordingly. Whereas initially Box099 had +70 mm translation through the y axis. After editing of placement, there is no changes occurs.

Please could you supply the FreeCAD file for GEARS that you are exporting - Thanks

ger.FCStd.txt As you can verify, there are two types of fails: N250 is possible to be tuned, and N10, N614 as unchangeable objects.

Alex2671 avatar Apr 17 '23 08:04 Alex2671

@Alex2671

ger1.FCStd.txt

Could you please check if the attached file works. There seems to be a problem (on our side) of exporting two different solids but with the same name. I have changed the name of the base solid in N1 from GDMLElTube_GDMLElTube to GDMLElTube_GDMLElTube000.

With my version of geant (geant4.10.07) I get display artifact when the cutting solid has a matching surface with the solid being cut, so I increased the z-dimension of the cutting solid to avoid that distracting artifact. That should have no effect on the simulation.

We will work on fixing the naming roblem.

I don't know what you mean "N10, N614 as unchangeable objects".

mhindi2 avatar Apr 17 '23 15:04 mhindi2