"Solid" clipping plane
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
"Solid" clipping plane
Hi,
I really like and often use the clipping plane but I don't like how it cuts the solids, I mean, if it's a solid the cut is supposed to continue solid and, therefore show a "solid cutted part"... something like: Would it be easy to code? and, is it interesting also for you?
Thanks
I really like and often use the clipping plane but I don't like how it cuts the solids, I mean, if it's a solid the cut is supposed to continue solid and, therefore show a "solid cutted part"... something like: Would it be easy to code? and, is it interesting also for you?
Thanks
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Re: "Solid" clipping plane
This would be nice to have (especially for sketching on an object). But I don't think coin already provides some methods for this. Maybe it's possible to write an extension for coin. I think the right way to do it is described here: https://www.opengl.org/archives/resourc ... ode10.html
there was already a topic about this: viewtopic.php?f=3&t=4371
there was already a topic about this: viewtopic.php?f=3&t=4371
Re: "Solid" clipping plane
Wow, thanks for pointing me out this old thread, I have no tried seeing if there was a previous one about the subject... sorry about that.looo wrote:This would be nice to have (especially for sketching on an object). But I don't think coin already provides some methods for this. Maybe it's possible to write an extension for coin. I think the right way to do it is described here: https://www.opengl.org/archives/resourc ... ode10.html
there was already a topic about this: viewtopic.php?f=3&t=4371
I have also read the OpenGL method you linked and seems a nice and probably easy way to accomplish it but I'm not programmer so I have no idea, any of you?
Thanks
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Re: "Solid" clipping plane
It is a bit more complicated. The thing is that the shown stencil technique works with the opengl objects, hence this happens for every object that gets clipped. In FreeCAD however this makes only sense for solids. Not for Meshes or Shells, which are by definition void. Hence one would need to create a object dependend clipping system. Otherwise the current situation would just be inverted, from "Why are Solids shown void?" to "Why are empty objects shown filled?".
Re: "Solid" clipping plane
There is a work around. In preferences 3D view deactivate the backlight color. In the view properties of the cliped object change Lighning from Two side to one side. The inner part of the object will be black thus it looks like the cut plan is black.
Re: "Solid" clipping plane
I understand but maybe an simple checkbox in the Clipping plane tool to turn it off and on could do the trick. Then it would turn not into if the concept is wrong or not, but how the user wants to view this specific cut...ickby wrote:It is a bit more complicated. The thing is that the shown stencil technique works with the opengl objects, hence this happens for every object that gets clipped. In FreeCAD however this makes only sense for solids. Not for Meshes or Shells, which are by definition void. Hence one would need to create a object dependend clipping system. Otherwise the current situation would just be inverted, from "Why are Solids shown void?" to "Why are empty objects shown filled?".
Yes, I saw it on the link @loo shared with me, a really clever trick but it only works with one clipping, if you turn, for instance, two of them then you can "see" the trick:bernd wrote:There is a work around. In preferences 3D view deactivate the backlight color. In the view properties of the cliped object change Lighning from Two side to one side. The inner part of the object will be black thus it looks like the cut plan is black.
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
Re: "Solid" clipping plane
Are you sure this is true? With pivy it's possible to add a SoClipPlane as a node somewhere in the scenegraph. Only nodes after the clip-plane are shown clipped.ickby wrote:It is a bit more complicated. The thing is that the shown stencil technique works with the opengl objects, hence this happens for every object that gets clipped.
And the stencil-technique is applied to one plane if I understand it. So if we can figure out the opengl plane corresponding to the SoClipPlane it should be possible to "close" only the clipped solid.
Code: Select all
from pivy import coin
import FreeCAD as App
import FreeCADGui as Gui
doc = App.newDocument()
sg = Gui.ActiveDocument.ActiveView.getSceneGraph()
root = coin.SoSeparator()
sphere = coin.SoSphere()
cube = coin.SoCube()
normal = coin.SbVec3f(0,0, 1)
point = coin.SbVec3f(0, 0, 0)
plane = coin.SbPlane(normal, point)
clip = coin.SoClipPlane()
clip.plane = plane
trans = coin.SoTransform()
trans.translation.setValue(coin.SbVec3f(2, 0, 0))
sg.addChild(cube)
sg.addChild(clip)
sg.addChild(trans)
sg.addChild(sphere)
Code: Select all
EarthSurface->Draw();
Re: "Solid" clipping plane
Maybe this is what I need: SoNode::GLRenderBelowPath
But also this doesn't work with python:
But also this doesn't work with python:
Code: Select all
Traceback (most recent call last):
File "SoClipPlane.py", line 49, in myCallbackRoutine
cap.stencilBuffer(action)
File "SoClipPlane.py", line 28, in stencilBuffer
self.node.GLRenderBelowPath(action)
File "~/conda/envs/freecad/lib/python3.5/site-packages/pivy/coin.py", line 4804, in GLRenderBelowPath
return _coin.SoNode_GLRenderBelowPath(self, action)
TypeError: in method 'SoNode_GLRenderBelowPath', argument 2 of type 'SoGLRenderAction *'
Re: "Solid" clipping plane
I'm not really sure, I'm not very familiar with OpenGL. But i always thought that the opengl clipping works on the whole scene. Don't know how coin does handle it with it's clipping. But would be nice if you find a way to make this work 

Re: "Solid" clipping plane
Ok, a basic example works now:ickby wrote:Don't know how coin does handle it with it's clipping. But would be nice if you find a way to make this work
https://github.com/looooo/pivy/blob/mas ... ipPlane.py With OpenGL it works this way:
1. draw front faces and decrease stencil-buffer where the front_face is drawn
2. disable drawing to Color-buffer and draw the back-face to the stencil-buffer (increase)
3. render a plane where the stencil-buffer is not 0 (for a solid this is every location where only the back-face is visible)
The trick to not clip the whole scene is to enable a clip plane somewhere in the render-transversal and disable after a certain node/group is drawn.
How to implement this in coin is another question but I think by looking at the implementation of the SoClipPlane this shouldn't be a too big problem. Another thing I was reading about is the use of SoOffScreenRenderer with the stencil-buffer.... https://github.com/looooo/coin3d/blob/m ... p#L219L237