]> OCCT Git - occt.git/commitdiff
Data Exchange, IGES Export - Missing Model Curves in transfer cache #483
authorikochetkova <irina.kochetkova@opencascade.com>
Tue, 22 Apr 2025 17:01:06 +0000 (18:01 +0100)
committerGitHub <noreply@github.com>
Tue, 22 Apr 2025 17:01:06 +0000 (18:01 +0100)
Check if the curve was already created and use it. Works for shared edges cases.

src/DataExchange/TKDEIGES/BRepToIGESBRep/BRepToIGESBRep_Entity.cxx
src/DataExchange/TKDEIGES/GTests/FILES.cmake
src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx [new file with mode: 0644]

index 586f67291ffdb57d091f2fe183fd3a50eb75ce4b..266abaf2fbb288481fcb3a6edf5b80811c48b06f 100644 (file)
@@ -317,6 +317,13 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferShape(
 
 Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferEdge(const TopoDS_Edge& myedge)
 {
+  Standard_Integer anInd = IndexEdge(myedge);
+  if (anInd != 0)
+  {
+    Handle(IGESData_IGESEntity) ICurve3d = Handle(IGESData_IGESEntity)::DownCast(myCurves(anInd));
+    if (!ICurve3d.IsNull())
+      return ICurve3d;
+  }
   BRepToIGES_BRWire BR(*this);
   BR.SetModel(GetModel());
   TopTools_DataMapOfShapeShape anEmptyMap;
index fdd8320015d4ea04865fa06ec18a0a973142be74..dc81956e78ccdbd3a6b5ff5c93d20e418d10dbb6 100644 (file)
@@ -2,4 +2,5 @@
 set(OCCT_TKDEIGES_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
 
 set(OCCT_TKDEIGES_GTests_FILES
+    IGESExportTest.cxx
 )
diff --git a/src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx b/src/DataExchange/TKDEIGES/GTests/IGESExportTest.cxx
new file mode 100644 (file)
index 0000000..1bca401
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (c) 2025 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <IGESData_IGESEntity.hxx>
+#include <IGESData_IGESModel.hxx>
+#include <IGESGeom_Line.hxx>
+#include <IGESControl_Writer.hxx>
+#include <Transfer_SimpleBinderOfTransient.hxx>
+#include <Transfer_FinderProcess.hxx>
+
+#include <gtest/gtest.h>
+
+// Check that 2d curves of shared edges are not lost in BRep mode.
+TEST(IGESExportTest, SharedCurvesBRepMode)
+{
+  TopoDS_Shape aSolid = (TopoDS_Solid)BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 1, 1, 1);
+
+  Standard_Integer   aBRepMode = 1;
+  IGESControl_Writer aWriter("MM", aBRepMode);
+  aWriter.AddShape(aSolid);
+
+  const Handle(Transfer_FinderProcess)& aFP    = aWriter.TransferProcess();
+  const Handle(IGESData_IGESModel)&     aModel = aWriter.Model();
+
+  for (Standard_Integer i = 1; i <= aFP->NbMapped(); i++)
+  {
+    Handle(Transfer_SimpleBinderOfTransient) aBinder =
+      Handle(Transfer_SimpleBinderOfTransient)::DownCast(aFP->MapItem(i));
+    if (aBinder.IsNull())
+      continue;
+
+    Handle(IGESData_IGESEntity) anEnt = Handle(IGESData_IGESEntity)::DownCast(aBinder->Result());
+    if (anEnt.IsNull())
+      continue;
+
+    Handle(IGESGeom_Line) aLine = Handle(IGESGeom_Line)::DownCast(anEnt);
+    if (aLine.IsNull())
+      continue;
+
+    // Check that all the entities are in the model.
+    EXPECT_TRUE(aModel->DNum(anEnt) != 0);
+  }
+}