View Issue Details

IDProjectCategoryView StatusLast Update
0033081CommunityOCCT:Modeling Algorithmspublic2022-07-27 04:36
ReporterLuis Diago Assigned Tomsv  
PrioritynormalSeveritycrash 
Status newResolutionopen 
PlatformMacOSOS 
Product Version7.6.2 
Summary0033081: Access violation in ShapeAnalysis_FreeBounds::ConnectWiresToWires
DescriptionAfter slicing a shape with several planes I received EXCEPTION_ACCESS_VIOLATION calling ShapeAnalysis_FreeBounds::ConnectWiresToWires (see details in https://dev.opencascade.org/content/access-violation-shapeanalysisfreeboundsconnectwirestowires). The two problematic wires (w1.brep and w2.brep), the 3D shape (Lmdx-4.STEP) and their pictures are attached.
Steps To ReproduceEven if the wires cannot be connected the code should not raise an exception. The two problematic wires are attached in brep files to reproduce the error using the following code:

[code]
    OSD::SetSignal(false);
    try
    {
        OCC_CATCH_SIGNALS

        BRep_Builder b;
        std::ifstream is;
        Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();

        TopoDS_Shape w1;
        is.open("w1.brep");
        BRepTools::Read(w1, is, b);
        is.close();
        hWires->Append(w1);

        TopoDS_Shape w2;
        is.open("w2.brep");
        BRepTools::Read(w2, is, b);
        is.close();
        hWires->Append(w2);


        Handle(TopTools_HSequenceOfShape) hSorted = new TopTools_HSequenceOfShape();
        ShapeAnalysis_FreeBounds::ConnectWiresToWires(hWires, PrecisionFactor*Precision::Confusion(), false, hSorted);

    }
    catch (const Standard_Failure& theErr)
    {
        Message::SendFail() << "OCCT exception caught:\n" << theErr;
    }
Additional information
and documentation updates
The infinite loop occurs in the ShapeAnalysis_FreeBounds::ConnectWiresToWires function in the following part of the code because the variable lwire is never -1:

[code]

//=======================================================================
//function : ConnectWiresToWires
//purpose :
//=======================================================================

 void ShapeAnalysis_FreeBounds::ConnectWiresToWires(Handle(TopTools_HSequenceOfShape)& iwires,
                            const Standard_Real toler,
                            const Standard_Boolean shared,
                            Handle(TopTools_HSequenceOfShape)& owires,
                            TopTools_DataMapOfShapeShape& vertices)
{
  if (iwires.IsNull() || !iwires->Length()) return;
  Handle(TopTools_HArray1OfShape) arrwires = new TopTools_HArray1OfShape(1, iwires->Length());
  //amv

         ...
  aTreeFiller.Fill();
  Standard_Integer nsel;

  ShapeAnalysis_Edge sae; //szv#4:S4163:12Mar99 moved
  Standard_Boolean done = Standard_False;


  while (!done)
  {
    Standard_Boolean found = Standard_False, tail = Standard_False, direct = Standard_False;
    Standard_Integer lwire=0;
      ...

    if (found)
    {
      if (!direct)
        arrwires->ChangeValue(lwire).Reverse();

      TopoDS_Wire aCurW = TopoDS::Wire (arrwires->Value (lwire));
      Handle(ShapeExtend_WireData) acurwd = new
        ShapeExtend_WireData ( TopoDS::Wire (arrwires->Value (lwire)), Standard_True, isUsedManifoldMode);
      if( !acurwd->NbEdges())
        continue;
      sewd->Add (acurwd, (tail ? 0 : 1));
    }
    else
    {
      // Recherche de la premier edge non traitee pour un autre wire.
      //Searching for first edge for next wire
      lwire = -1;
      for (/*Standard_Integer*/ i = 1 ; i <= arrwires->Length(); i++)
      {
        if (!aSel.ContWire(i))
        {
          lwire = i; //szv#4:S4163:12Mar99 optimized
          sewd->Add (TopoDS::Wire (arrwires->Value (lwire)));
          aSel.LoadList(lwire);

          if (sewd->NbEdges() > 0)
            break;
          sewd->Clear();
        }
      }

      if (lwire == -1)
        done = 1;
    }
  }

  for ( /*Standard_Integer*/ i = 1; i <= iwires->Length(); i++)
  {
    iwires->SetValue (i, arrwires->Value(i));
  }
}
TagsNo tags attached.
Test case number

Attached Files

  • shape_1.png (164,211 bytes)
  • w1_w2.png (14,840 bytes)
  • w2.brep (36,069 bytes)
  • w1.brep (36,716 bytes)
  • Lmdx-4.STEP (587,912 bytes)

Activities

Luis Diago

2022-07-27 04:22

reporter   ~0110011

File to reproduce the error
shape_1.png (164,211 bytes)
w1_w2.png (14,840 bytes)
w2.brep (36,069 bytes)
w1.brep (36,716 bytes)

Luis Diago

2022-07-27 04:36

reporter   ~0110012

3D shape
Lmdx-4.STEP (587,912 bytes)

Issue History

Date Modified Username Field Change
2022-07-27 04:20 Luis Diago New Issue
2022-07-27 04:20 Luis Diago Assigned To => msv
2022-07-27 04:22 Luis Diago Note Added: 0110011
2022-07-27 04:22 Luis Diago File Added: shape_1.png
2022-07-27 04:22 Luis Diago File Added: w1_w2.png
2022-07-27 04:22 Luis Diago File Added: w2.brep
2022-07-27 04:22 Luis Diago File Added: w1.brep
2022-07-27 04:36 Luis Diago Note Added: 0110012
2022-07-27 04:36 Luis Diago File Added: Lmdx-4.STEP