[FIXED] FC#3006: PartDesign Mirrored bugs
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- kkremitzki
- Veteran
- Posts: 2515
- Joined: Thu Mar 03, 2016 9:52 pm
- Location: Illinois
[FIXED] FC#3006: PartDesign Mirrored bugs
Hi, so I'm working on this issue and just wanted to create a thread to get some feedback.
First question:
what's up with this inversion? https://github.com/FreeCAD/FreeCAD/blob ... pp#L74-L77
I'm assuming it must be a mistake.
Anyway, I believe one of the core issues here may be an OCC bug, or at least a misuse of OCC, here and here.
Reference:
void gp_Trsf::SetMirror ( const gp_Ax2 & A2)
My test case is simple: I'm using a 1mm x 1mm square sketch, cornered at the origin and padded up 1mm, so a unit cube in the +X,+Y,+Z octant. So my gp_Pnt axbase is always (0, 0, 0).
If I reverse the inversion in my first link, I get the following results:
Mirror about vertical sketch axis (Y): axdir is (0, 1, 0). So, the mirror matrix should be [[-1, 0, 0], [0, 1, 0], [0, 0, 1]]. However the Z-direction ends up being negative.
Mirror about horizontal sketch axis (X): axdir is (1, 0, 0), ok. But the mirror matrix is [[1, 0, 0], [0, -1, 0], [0, 0,-1]] as above. The Z direction is negative when it shouldn't be.
Repeat this with sketches attached to the YZ and XZ planes, and always the corresponding normal is reversed. (So what should be X is -X, and what should be Y is -Y, respectively.)
So, this is obviously a problem. It got me thinking, though. Is this a problem with handedness/chirality of coordinate systems, and the fact that we're trying to mirror? In OCC, gp_Ax2 is a right-handed coordinate system only. There is a separate class, gp_Ax3, that can be left-handed, but then there is no gp_Trsf::SetMirror( const gp_Ax3& A3 )...
First question:
what's up with this inversion? https://github.com/FreeCAD/FreeCAD/blob ... pp#L74-L77
I'm assuming it must be a mistake.
Anyway, I believe one of the core issues here may be an OCC bug, or at least a misuse of OCC, here and here.
Reference:
void gp_Trsf::SetMirror ( const gp_Ax2 & A2)
My test case is simple: I'm using a 1mm x 1mm square sketch, cornered at the origin and padded up 1mm, so a unit cube in the +X,+Y,+Z octant. So my gp_Pnt axbase is always (0, 0, 0).
If I reverse the inversion in my first link, I get the following results:
Mirror about vertical sketch axis (Y): axdir is (0, 1, 0). So, the mirror matrix should be [[-1, 0, 0], [0, 1, 0], [0, 0, 1]]. However the Z-direction ends up being negative.
Mirror about horizontal sketch axis (X): axdir is (1, 0, 0), ok. But the mirror matrix is [[1, 0, 0], [0, -1, 0], [0, 0,-1]] as above. The Z direction is negative when it shouldn't be.
Repeat this with sketches attached to the YZ and XZ planes, and always the corresponding normal is reversed. (So what should be X is -X, and what should be Y is -Y, respectively.)
So, this is obviously a problem. It got me thinking, though. Is this a problem with handedness/chirality of coordinate systems, and the fact that we're trying to mirror? In OCC, gp_Ax2 is a right-handed coordinate system only. There is a separate class, gp_Ax3, that can be left-handed, but then there is no gp_Trsf::SetMirror( const gp_Ax3& A3 )...
Last edited by Kunda1 on Wed Apr 27, 2022 9:17 pm, edited 1 time in total.
Reason: Added [Fixed] to thread title
Reason: Added [Fixed] to thread title
Re: FC#3006: PartDesign Mirrored bugs
Not a reply to your questions. Just a mutex/sync.kkremitzki wrote:Hi, so I'm working on this issue and just wanted to create a thread to get some feedback.
As part of "mirrored feature does not intersect support" error when touching, I am working on: Part::checkIntersection last section non-manyfold detection:
Code: Select all
//non manifold condition. 1 has to be a face
for (int index = 1; index < extrema.NbSolution() + 1; ++index)
{
if (extrema.SupportTypeShape1(index) == BRepExtrema_IsInFace || extrema.SupportTypeShape2(index) == BRepExtrema_IsInFace)
return true;
}
return false;
}
else
return false;
Re: FC#3006: PartDesign Mirrored bugs
Definitely a mistake. It explains why I always have to select the axis I do not want to get what I wantkkremitzki wrote:what's up with this inversion? https://github.com/FreeCAD/FreeCAD/blob ... pp#L74-L77
I'm assuming it must be a mistake.
Re: FC#3006: PartDesign Mirrored bugs
It seems to be just a visualization problem in the mesh (the red thing the screenshoots).kkremitzki wrote: ↑Thu Jun 01, 2017 5:34 am So, this is obviously a problem. It got me thinking, though. Is this a problem with handedness/chirality of coordinate systems, and the fact that we're trying to mirror? In OCC, gp_Ax2 is a right-handed coordinate system only. There is a separate class, gp_Ax3, that can be left-handed, but then there is no gp_Trsf::SetMirror( const gp_Ax3& A3 )...
When the transformation succeeds, there is no inversion (but then you do not see the red mesh, because that is only when it fails). When it fails (for other reasons, like misdetection by Part::CheckIntersection), this inverted red thing appears, making you think the inversion is causing the transformation to fail. However, in my tests the transformation fails for other reasons (at least in some of my examples).
If you want to test this, you can do this:
Code: Select all
bool Part::checkIntersection(const TopoDS_Shape& first, const TopoDS_Shape& second,
const bool quick, const bool touch_is_intersection) {
return true;
}
Re: FC#3006: PartDesign Mirrored bugs
I want to document this problem:
A point on object constraint in the sketcher, in a first solve, reaches a precision of 2E-7, whereas precision::confusion is 1e-7. The mirroring feature fails. See case:
I just open the sketcher and try to drag the point (the one with the Point on object constraint) to the -x axis (so as to try to make it closer from the mirroring feature that would be done). Close sketch and the mirroring feature success.
Problem: The Sketcher should increase its precision (we know it is not straight-forward, but still).
A point on object constraint in the sketcher, in a first solve, reaches a precision of 2E-7, whereas precision::confusion is 1e-7. The mirroring feature fails. See case:
I just open the sketcher and try to drag the point (the one with the Point on object constraint) to the -x axis (so as to try to make it closer from the mirroring feature that would be done). Close sketch and the mirroring feature success.
Problem: The Sketcher should increase its precision (we know it is not straight-forward, but still).
Re: FC#3006: PartDesign Mirrored bugs
Definitely, the culprit of Mirroring not working properly is Part::checkIntersection. The red mesh is wrongly represented in the ViewProvider ("inverted" and if the mistake Kurt identified is corrected, then also it makes the horizontal mirror when asking for the vertical mirror and vice versa).
Re: FC#3006: PartDesign Mirrored bugs
checkIntersection is also the only reason why a multitransform can not be used to make a full part from a quarter:
bypassing it:
Note: The in the first image the "non-manifold" test was already by passed. For the second, the whole checkIntersection was bypassed (it was giving a minimum distance of "7" mm?, probably was not measuring the right "shapes" as there are two original and two results).
bypassing it:
Note: The in the first image the "non-manifold" test was already by passed. For the second, the whole checkIntersection was bypassed (it was giving a minimum distance of "7" mm?, probably was not measuring the right "shapes" as there are two original and two results).
- kkremitzki
- Veteran
- Posts: 2515
- Joined: Thu Mar 03, 2016 9:52 pm
- Location: Illinois
Re: FC#3006: PartDesign Mirrored bugs
Here's my test case btw:
- Attachments
-
- pdtest1.fcstd
- (7.59 KiB) Downloaded 86 times
- kkremitzki
- Veteran
- Posts: 2515
- Joined: Thu Mar 03, 2016 9:52 pm
- Location: Illinois
Re: FC#3006: PartDesign Mirrored bugs
The unit test I added BTW should be failing when checkIntersection is set to return true, but it isn't.
This needs to be changed to be >= 1.0
https://github.com/FreeCAD/FreeCAD/blob ... pp.py#L164
This needs to be changed to be >= 1.0
https://github.com/FreeCAD/FreeCAD/blob ... pp.py#L164
Re: FC#3006: PartDesign Mirrored bugs
Your test case Kurt: