Regression from 7.3.0 to 7.4.0

Forums: 

I noticed this very annoying regression in visualization. The object seems topologically correct, but something in the translation to OpenGL must happen? See the attached picture for the end result of the code below (C#, snippet appended to the sample project importExportWPF):

        TopoDS_Compound comp = new TopoDS_Compound();
        TopoDS_Shape compShape = comp;
        BRep_Builder builder = new BRep_Builder();
        builder.MakeCompound(ref comp);

        gp_Pnt startPoint = new gp_Pnt();
        Geom_Circle borderCircle = new Geom_Circle(new gp_Ax2(startPoint, new gp_Dir(0, 0, 1)), 40);
        BRepBuilderAPI_MakeEdge edgeMk = new BRepBuilderAPI_MakeEdge(borderCircle.Circ());
        BRepBuilderAPI_MakeWire wMaker = new BRepBuilderAPI_MakeWire(edgeMk.Edge());
        TopoDS_Wire spine = wMaker.Wire();
        BRepBuilderAPI_MakeEdge eMaker = new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 40, 0), new gp_Pnt(0, 50, 0));
        BRepOffsetAPI_MakePipe pipeMk = new BRepOffsetAPI_MakePipe(spine, eMaker.Edge());
        builder.Add(ref compShape, pipeMk.Shape());

        BRepBuilderAPI_MakeWire mkWire = new BRepBuilderAPI_MakeWire();
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 40, 0), new gp_Pnt(-40, 0, 0)).Edge());
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(-40, 0, 0), new gp_Pnt(-15, 0, 0)).Edge());
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(-15, 0, 0), new gp_Pnt(-15, -37, 0)).Edge());
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(-15, -37, 0), new gp_Pnt(15, -37, 0)).Edge());
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(15, -37, 0), new gp_Pnt(15, 0, 0)).Edge());
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(15, 0, 0), new gp_Pnt(40, 0, 0)).Edge());
        mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(40, 0, 0), new gp_Pnt(0, 40, 0)).Edge());
        TopoDS_Face faceArrow = new BRepBuilderAPI_MakeFace(mkWire.Wire(), true).Face();
        builder.Add(ref compShape, faceArrow);

        double scalefactor = 0.25;
        gp_Trsf trsfScale = new gp_Trsf();
        trsfScale.SetScale(startPoint, scalefactor);
        TopLoc_Location locScale = new TopLoc_Location(trsfScale);
        comp.Move(locScale);

        //var aisShape = new AIS_Shape(faceArrow); // va
        var aisShape = new AIS_Shape(compShape); // NON va
        aisShape.SetDisplayMode((int)AIS_DisplayMode.AIS_Shaded);
        myOcctView.Context.Display(aisShape, 1, 0, true);
Attachments: 
Marco Cecchi's picture

The problem is revealed by skipping the Tessellate() in StdPrs_ShadedShape.cxx.

The arrow triangulation is wrong.

Attachments: 
gkv311 n's picture

AIS_Shape just displays triangulation computed by BRepMesh_IncrementalMesh or some another algorithm.

So either - you observe some bug in meshing algorithm, or your shape is defined incorrectly (from meshing algorithm point of view).

Reporting an issue for obsolete OCCT release is not much helpful - it is desired to check issue on more recent releases to see if it is still happen or already fixed.

Marco Cecchi's picture

Ok, I checked the code. The problem is in the creation of the Delanauy triangulation. The code in BRepMesh_Delaun.cxx is the same in 7.8.0.

void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
{
  // Insertion of edges of super triangles in the list of free edges:
  Handle(NCollection_IncAllocator) aAllocator = new NCollection_IncAllocator(
    IMeshData::MEMORY_BLOCK_SIZE_HUGE);

  IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator);
  const Standard_Integer(&e)[3] = mySupTrian.myEdges;

  aLoopEdges.Bind( e[0], Standard_True );
  aLoopEdges.Bind( e[1], Standard_True );
  aLoopEdges.Bind( e[2], Standard_True );

  if ( theVertexIndexes.Length() > 0 )
  {
    // Creation of 3 trianglers with the first node and the edges of the super triangle:
    Standard_Integer anVertexIdx = theVertexIndexes.Lower();
    createTriangles( theVertexIndexes( anVertexIdx ), aLoopEdges );

    // Add other nodes to the mesh
------->    createTrianglesOnNewVertices( theVertexIndexes );
  }

Why do you need to add extra nodes not belonging to the mesh for visualisation? Skipping that line seems to work.

Marco Cecchi's picture

I just dowloaded OCCT 7.8.0, but the ImportExport samples have been removed?

Can you please check the aforementioned snippet with the DRAWEXE?

Dmitrii Pasukhin's picture

Hello, Samples are not removed.

We apologies for late publishing. The samples will be public a little later. If you can share the file, it helps us to reproduce the issue.

Best regards, Dmitrii.

Dmitrii Pasukhin's picture

My apologies,  your code sample generate a model. I will try to reproduce on latest version. But it can be faster to check with already prepared".brep" file.

Best regards, Dmitrii.

Marco Cecchi's picture

Hi Dmitri,

ok thanks. Take into account that the problem is verified by embedding the arrow face into a compound. The face alone works. The BREP file is included. This is a minimal example:

    TopoDS_Compound comp = new TopoDS_Compound();
    TopoDS_Shape compShape = comp;
    BRep_Builder builder = new BRep_Builder();
    builder.MakeCompound(ref comp);

    gp_Pnt startPoint = new gp_Pnt();
    BRepBuilderAPI_MakeWire mkWire = new BRepBuilderAPI_MakeWire();
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(0, 40, 0), new gp_Pnt(-40, 0, 0)).Edge());
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(-40, 0, 0), new gp_Pnt(-15, 0, 0)).Edge());
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(-15, 0, 0), new gp_Pnt(-15, -37, 0)).Edge());
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(-15, -37, 0), new gp_Pnt(15, -37, 0)).Edge());
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(15, -37, 0), new gp_Pnt(15, 0, 0)).Edge());
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(15, 0, 0), new gp_Pnt(40, 0, 0)).Edge());
    mkWire.Add(new BRepBuilderAPI_MakeEdge(new gp_Pnt(40, 0, 0), new gp_Pnt(0, 40, 0)).Edge());
    TopoDS_Face faceArrow = new BRepBuilderAPI_MakeFace(mkWire.Wire(), true).Face();
    builder.Add(ref compShape, faceArrow);

    //double scalefactor = 1.0; // va anche col compound
    double scalefactor = 0.25; // NON va
    gp_Trsf trsfScale = new gp_Trsf();
    trsfScale.SetScale(startPoint, scalefactor);
    TopLoc_Location locScale = new TopLoc_Location(trsfScale);
    comp.Move(locScale);
    //var aisShape = new AIS_Shape(faceArrow); // va
    AIS_Shape aisShape = new AIS_Shape(compShape); // NON va
    BRepTools.Write(compShape, "c:\\windows\\temp\\arrow.brep");
    aisShape.SetDisplayMode((int)AIS_DisplayMode.AIS_Shaded);
    myOcctView.Context.Display(aisShape, 1, 0, true);
Attachments: 
Marco Cecchi's picture

Hello Dmitri,

trying with 7.8.0, I have found what causes the problem. With 7.8.0:

gp_Trsf trsfScale = new gp_Trsf();
trsfScale.SetScale(startPoint, scalefactor);
TopLoc_Location locScale = new TopLoc_Location(trsfScale);
comp.Move(locScale);

gives an error, because you cannot Move to a TopLoc_Location without defining the translation first. Actually TopoDS_Shape does not have a Transform() method, to perform a scaled rototranslation.

So probably a default has changed from 7.3 to 7.4, but adding this line fixes the issue:

trsfScale.SetTranslation(new gp_Vec());

You can close this ticket.

Dmitrii Pasukhin's picture

Thank you for your investigation. We will try to analize the reason for this behavior. 

comp.Move(locScale); on 7.8 should be done as comp.Move(locScale, true); to accept scaling,

Best regards, Dmitrii.