0025816: IGES export - edges within compound are lost if BREP mode (IGES 5.1) is...
authorabv <abv@opencascade.com>
Tue, 10 Feb 2015 19:50:51 +0000 (22:50 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 19 Feb 2015 11:50:56 +0000 (14:50 +0300)
Enable writing wires, edges, and vertices inside compound in IGES in BREP mode.
Create IGES group for compound even if it contains single shape.

src/BRepToIGESBRep/BRepToIGESBRep_Entity.cxx
tests/bugs/begin
tests/bugs/iges/bug25816 [new file with mode: 0644]

index 70be29f..00c5d70 100644 (file)
@@ -869,6 +869,11 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
   for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
     TopoDS_Wire S = TopoDS::Wire(Ex.Current());
     AddWarning(S," a Wire alone is not an IGESBRep entity : no Transfer");
   for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
     TopoDS_Wire S = TopoDS::Wire(Ex.Current());
     AddWarning(S," a Wire alone is not an IGESBRep entity : no Transfer");
+
+    BRepToIGES_BRWire BW(*this);
+    BW.SetModel(GetModel());
+    IShape = BW.TransferWire(S);
+    if (!IShape.IsNull()) Seq->Append(IShape);
   }
 
 
   }
 
 
@@ -876,6 +881,11 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
   for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
     TopoDS_Edge S = TopoDS::Edge(Ex.Current());
     AddWarning(S," a Edge alone is not an IGESBRep entity : no Transfer");
   for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
     TopoDS_Edge S = TopoDS::Edge(Ex.Current());
     AddWarning(S," a Edge alone is not an IGESBRep entity : no Transfer");
+
+    BRepToIGES_BRWire BW(*this);
+    BW.SetModel(GetModel());
+    IShape = BW.TransferEdge(S, Standard_False);
+    if (!IShape.IsNull()) Seq->Append(IShape);
   }
 
 
   }
 
 
@@ -883,27 +893,27 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
   for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
     TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
     AddWarning(S," a Vertex alone is not an IGESBRep entity : no Transfer");
   for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
     TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
     AddWarning(S," a Vertex alone is not an IGESBRep entity : no Transfer");
+
+    BRepToIGES_BRWire BW(*this);
+    BW.SetModel(GetModel());
+    IShape = BW.TransferVertex(S);
+    if (!IShape.IsNull()) Seq->Append(IShape);
   }
 
   // construct the group
   Standard_Integer nbshapes = Seq->Length();
   }
 
   // construct the group
   Standard_Integer nbshapes = Seq->Length();
-  Handle(IGESData_HArray1OfIGESEntity) Tab;
-  if (nbshapes > 1) {
-    Tab =  new IGESData_HArray1OfIGESEntity(1,nbshapes);
+  if (nbshapes > 0) {
+    Handle(IGESData_HArray1OfIGESEntity) Tab =
+      new IGESData_HArray1OfIGESEntity(1,nbshapes);
     for (Standard_Integer itab = 1; itab <= nbshapes; itab++) {
       Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
       Tab->SetValue(itab,item);
     }
     for (Standard_Integer itab = 1; itab <= nbshapes; itab++) {
       Handle(IGESData_IGESEntity) item = GetCasted(IGESData_IGESEntity, Seq->Value(itab));
       Tab->SetValue(itab,item);
     }
-  }
-  
-  if (nbshapes == 1) {
-    res = IShape;
-  }
-  else if(nbshapes > 1) {
+
     Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
     IGroup->Init(Tab);
     res = IGroup;
     Handle(IGESBasic_Group) IGroup = new IGESBasic_Group;
     IGroup->Init(Tab);
     res = IGroup;
-  }
+  }  
 
   SetShapeResult ( start, res );
 
 
   SetShapeResult ( start, res );
 
index a479b20..fa2889f 100755 (executable)
@@ -169,14 +169,15 @@ proc checknbshapes { res nbshapes_expected_s count_locations message} {
 
     set EntityList {VERTEX EDGE WIRE FACE SHELL SOLID COMPSOLID COMPOUND SHAPE}
 
 
     set EntityList {VERTEX EDGE WIRE FACE SHELL SOLID COMPSOLID COMPOUND SHAPE}
 
+    puts "Checking $message"
     foreach Entity ${EntityList} {
        set expr_string "${Entity} +: +(\[-0-9.+eE\]+)"
        if { [regexp "${expr_string}" ${nbshapes_expected_s} full nb_entity1] > 0 } {
                  if { [regexp "${expr_string}" ${nb_info} full nb_entity2] > 0 } {
             if { ${nb_entity2} != ${nb_entity1} } {
     foreach Entity ${EntityList} {
        set expr_string "${Entity} +: +(\[-0-9.+eE\]+)"
        if { [regexp "${expr_string}" ${nbshapes_expected_s} full nb_entity1] > 0 } {
                  if { [regexp "${expr_string}" ${nb_info} full nb_entity2] > 0 } {
             if { ${nb_entity2} != ${nb_entity1} } {
-               puts "Error : ${message} is WRONG because number of ${Entity} entities is ${nb_entity2} while ${nb_entity1} is expected"
+               puts "Error: number of ${Entity} entities is wrong: ${nb_entity2} while ${nb_entity1} is expected"
             } else {
             } else {
-               puts "OK : ${message} is GOOD because number of ${Entity} entities is equal to number of expected ${Entity} entities"
+               puts "OK: number of ${Entity} entities is as expected: ${nb_entity2}"
             }
                  }
        }
             }
                  }
        }
diff --git a/tests/bugs/iges/bug25816 b/tests/bugs/iges/bug25816
new file mode 100644 (file)
index 0000000..c913a4e
--- /dev/null
@@ -0,0 +1,17 @@
+# Test issue #25816: writing edges inside compound to IGES 5.3
+
+pload MODELING DATAEXCHANGE
+
+# make compound containing one edge
+circle c 0 0 0 0 0 1 1
+mkedge e c
+compound e s
+
+# write to IGES in BREP mode
+newmodel
+param write.iges.brep.mode 1
+brepiges s ${imagedir}/${casename}.igs
+
+# read back and check similarity
+igesbrep ${imagedir}/${casename}.igs a *
+checknbshapes a [nbshapes s] t "Number of sub-shapes in result after saving to IGES and reading back"