DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0033081

Access violation in ShapeAnalysis_FreeBounds::ConnectWiresToWires

CommunityOCCT:Modeling Algorithmsnew2 public notes

Search issues

Description

After 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 (Attachment 4 (BREP) and Attachment 5 (BREP)), the 3D shape (Attachment 1 (STEP)) and their pictures are attached.

Steps to reproduce

Even 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("Attachment 4 (BREP)");
        BRepTools::Read(w1, is, b);
        is.close();
        hWires->Append(w1);

        TopoDS_Shape w2;
        is.open("Attachment 5 (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

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));
  }
}

Public activity

2 archived notes

Participants are labeled by their role within this record.

01Author
File to reproduce the error
Attachment 2 (PNG) (164,211 bytes)   
Attachment 3 (PNG) (14,840 bytes)   
Attachment 5 (BREP) (36,069 bytes)   
Attachment 4 (BREP) (36,716 bytes)   
02Author
3D shape
Attachment 1 (STEP) (587,912 bytes)