pyOCCT icon indicating copy to clipboard operation
pyOCCT copied to clipboard

Setting referenced based class attributes

Open capfish opened this issue 3 years ago • 3 comments

Expected Behavior

I am unable to set the ShapeFix_Wireframe mode to remove small edges via its attribute ModeDropSmallEdges Relatedly, I am also unable to change any of the modes (i.e. FixSolidMode, FixFreeFaceMode, etc) in ShapeFix_Shape

>>> from OCCT.Exchange.Basic import ExchangeBasic
>>> from OCCT.ShapeFix import ShapeFix_Wireframe
>>> my_part = ExchangeBasic.read_step('path/to/my/step.step')
>>> wireframe_fixer = ShapeFix_Wireframe(my_part)
>>> wireframe_fixer.ModeDropSmallEdges = True
>>> wireframe_fixer.ModeDropSmallEdges()
True

Current Behavior

>>> from OCCT.Exchange.Basic import ExchangeBasic
>>> from OCCT.ShapeFix import ShapeFix_Wireframe
>>> my_part = ExchangeBasic.read_step('path/to/my/step.step')
>>> wireframe_fixer = ShapeFix_Wireframe(my_part)
>>> wireframe_fixer.ModeDropSmallEdges = True
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'OCCT.ShapeFix.ShapeFix_Wireframe' object attribute 'ModeDropSmallEdges' is read-only
>>> wireframe_fixer.ModeDropSmallEdges()
False

Possible Solution

This seems to be because those attributes are passed by reference in the C++ libraries, I'm not strong in pybind-fu so I'm not sure what would have to be changed, but I'm willing to try if you point me in the right direction!

Context

I have been having issues with the capping plane feature and I was pointed to these shape healing tools on the OpenCascade forums They work alright, but it is clear that I have some small disconnected edges that need removed and I'm unable to set the attribute.

Your Environment

  • Version used: 7.5.2
  • Operating System and version (desktop or mobile): Windows 10, Debian Stretch

capfish avatar Nov 01 '21 07:11 capfish

I guess you intend to use method MergeSmallEdges, note that it has argument theModeDrop which you can set true as a workaround.

russelmann avatar Feb 08 '22 19:02 russelmann

Oh interesting I completely missed that. I was intending to run FixSmallEdges, do you know if running MergeSmallEdges with theModeDrop=True followed by FixSmallEdges with ModeDropSmallEdges set to False is equivalent to just running FixSmallEdges with ModeDropSmallEdges set to False?

capfish avatar Feb 09 '22 01:02 capfish

Seems that the workaround won't help using method FixSmallEdges. In case you don't need to call it on a compound, you should be fine calling CheckSmallEdges and MergeSmallEdges instead. You can check the implementation of FixSmallEdges here , line 408. Lines 421-462 show an involved specific behavior for compounds with a recursive call which is problematic. However if you use any other topology is should suffice to only reimplement lines 463-466 in Python.

russelmann avatar Feb 09 '22 09:02 russelmann