DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0032716

Modeling Algorithms - BRepBuilderAPI_Transform discards triangulation

Open CASCADEOCCT:Modeling Algorithmsclosed49 public notes

Search issues

Description

BRepBuilderAPI_ModifyShape has severe issue in handling faces - existing triangulation is always removed.
This leads to two issues:
- User has to re-triangulate shape, which might be much more expensive than transforming triangulation nodes.
- Triangulation-only shapes are corrupted or lead to NULL-dereference in algorithm.

Steps to reproduce

pload MODELING
psphere s 1
incmesh s 1
trinfo s
tscale s 0 0 0 0.5
trinfo s
# KO - triangulation is empty

incmesh s 1
tclean -geom s
tscale s 0 0 0 0.5
# KO - crash in the algorithm
trinfo s

Public activity

49 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Andrei LATYSHEV
Date: Fri Apr 1 16:45:02 2022 +0300

    0032716: Modeling Algorithms - BRepBuilderAPI_Transform discards triangulation
    
    The methods for BRepTools_TrsfModification are defined and modified to keep the triangulation during 'tscale' operation.
02Author
+    //Applying the transformation to each node of triangulation
+    aP = theTriangulation->Node(i).Transformed(myTrsf);
+    theTriangulation->SetNode(i, aP);

It might be better adding the method `Poly_Triangulation::Transform (const gp_Trsf& theT)` / `Poly_Polygon3D::Transform()`.
It is not enough transforming triangulation nodes, normals should be transformed as well.

+Standard_EXPORT Standard_Boolean BRepTools_TrsfModification::NewPolygon

`Standard_EXPORT` should not appear in .cxx files.

+    TColgp_Array1OfPnt aNodesArray = aPolygon->Nodes();

Would be nice adding `Poly_Polygon3D::Copy()` for consistency with other classes.
03Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: Andrei LATYSHEV
Date: Mon Apr 4 11:28:10 2022 +0300

    0031479: Modeling Algorithms - exception on geometry transformation of triangulation-only shapes (without geometry surface)
    
    Added test for user's problem case
04Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
05Author
+    aV = gp_Vec(myNormals(i).x(), myNormals(i).y(), myNormals(i).z()).Transformed(theT);
+    Standard_Real aCoef = aV.Magnitude();
+    aV = aV / aCoef;

Normal vectors couldn't be transformed like that - see gp_Dir::Transform() implementation.

+  // Apply the transformation to the triangulation
+  Standard_EXPORT void Transform(const gp_Trsf& theT);

`//!`

+  for (Standard_Integer i = 1; i < myNodes.Length(); ++i)
+  {

Indexation of `myNodes` doesn't start from `1`.

+//function : RemoveNormals
+//purpose  :
+//=======================================================================
+void Poly_Triangulation::Transform(const gp_Trsf& theT)

Inconsistent header.
06Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
07Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Wed Apr 20 17:14:07 2022 +0300

    0032716: Modeling Algorithms - BRepBuilderAPI_Transform discards triangulation
    
    Added the test to reproduce this problem.
    The methods for BRepTools_TrsfModification are defined and modified to keep the triangulation during 'tscale' operation.
08Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
09Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
10Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
11Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
12Author
It is desired to create screenshots within the test to be able to verify visually that transformed mesh has correct vertex normals.
+++ b/tests/bugs/mesh/bug32716
13Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
14Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
15Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
16Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
17Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
18Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
19Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
20Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
21Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
22Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
23Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
24Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
25Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
26Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
27Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
28Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
29Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Fri Jul 1 16:46:55 2022 +0300

    0031479: Modeling Algorithms - exception on geometry transformation of triangulation-only shapes (without geometry surface)
    
    * Avoid crash in BRepBuilderAPI_GTransform algorithm. The crash in BRepBuilder_Transform has been solved by 0032716.
    * Move copying modifier to BRepTools package.
    * Implement transformation of a triangulation in BRepTools_GTrsfModification.

Author: Commenter 1
Date: Wed Apr 20 17:14:07 2022 +0300

    0032716: Modeling Algorithms - BRepBuilderAPI_Transform discards triangulation
    
    * Implement methods for copying tessellation to BRepTools_TrsfModification to keep the triangulation during transformation.
    * Add tests to reproduce the problem.

Author: azv
Date: Fri Jul 1 15:59:40 2022 +0300

    0033049: Command 'tclean -geom' does not remove all geometric objects from the shape
    
    Remove unused P-curves when cleaning the geometry
30Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
31Commenter 31
Please, review OCCT branch CR32716_2.
Test results: http://jenkins-test-occt/view/CR32716_2-master-AZV/view/COMPARE/
32Commenter 32
It is needed to invalidate myCachedMinMax of the copy.
  theTriangulation = theTriangulation->Copy();


Use const&
      Poly_Triangle aTria = theTriangulation->Triangle(anInd);


In the method BRepTools_TrsfModification::NewPolygon it is needed to transform parameters if the edge has 3D curve.

Please update description, as there is no more "Copy" argument, but there are two new ones:
  //! of T is equal to 1., and if Copy equals false (the
...
                                const Standard_Boolean theCopyGeom = Standard_False, 
                                const Standard_Boolean theCopyMesh = Standard_False);
33Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Wed Jul 6 17:25:10 2022 +0300

    # remarks
34Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: azv
Date: Fri Jul 1 16:46:55 2022 +0300

    0031479: Modeling Algorithms - exception on geometry transformation of triangulation-only shapes (without geometry surface)
    
    * Avoid crash in BRepBuilderAPI_GTransform algorithm. The crash in BRepBuilder_Transform has been solved by 0032716.
    * Move copying modifier to BRepTools package.
    * Implement copying of triangulation in BRepTools_NurbsConvertModification.
    * Implement transformation of a triangulation in BRepTools_GTrsfModification.
    * Update test case bugs/mesh/bug22778 to clean the triangulation after conversion to NURBS (reproduce the same behavior as before).

Author: Commenter 1
Date: Wed Apr 20 17:14:07 2022 +0300

    0032716: Modeling Algorithms - BRepBuilderAPI_Transform discards triangulation
    
    * Implement methods for copying tessellation to BRepTools_TrsfModification to keep the triangulation during transformation.
    * Add tests to reproduce the problem.
35Commenter 35
>>> Use const&
>>>
>>> Poly_Triangle aTria = theTriangulation->Triangle(anInd);

It is not possible here, because aTria is updated below.
36Commenter 36
The option -copymesh takes effect only with -copy. Please reflect this in the help.
37Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
38Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
39Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
40Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
41Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
42Commenter 42
Mikhail, please review OCCT branch CR32716_2.
Branch CR32716_3 contains the same changes, but squashed to a single commit.
Test results: http://jenkins-test-occt/view/CR32716_3-master-AZV/view/COMPARE/
43Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
44Commenter 44
For integration:
occt - CR32716_3
products - none
45Commenter 45
Combination -
OCCT branch : [archived branch]
master SHA - changes and them, and you can discard any commits you make in this
[revision removed]
changes and them, and you can discard any commits you make in this
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18685.930000000586 / 18908.870000000694 [-1.18%]
Products
Total CPU difference: 11796.890000000125 / 11832.130000000114 [-0.30%]
Windows-64-VC14:
OCCT
Total CPU difference: 20784.828125 / 20752.59375 [+0.16%]
Products
Total CPU difference: 13361.3125 / 13368.90625 [-0.06%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
46Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
47Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
48Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
49Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records