}
#endif
-//=======================================================================
-//function : AllocateSubLabel
-//purpose :
-//=======================================================================
-
-static TDF_Label AllocateSubLabel(TDF_Label& theRoot)
-{
- return TDF_TagSource::NewChild(theRoot);
-}
-
//=======================================================================
//function : STEPCAFControl_Reader
//purpose :
//=======================================================================
TDF_Label STEPCAFControl_Reader::SettleShapeData(const Handle(StepRepr_RepresentationItem)& theItem,
- TDF_Label& theLab,
+ const TDF_Label& theLab,
const Handle(XCAFDoc_ShapeTool)& theShapeTool,
const Handle(Transfer_TransientProcess)& TP) const
{
return aResult;
// Allocate sub-Label
- aResult = AllocateSubLabel(theLab);
+ aResult = theShapeTool->AddSubShape(theLab, aShape);
+ if (aResult.IsNull())
+ return aResult;
TCollection_AsciiString aName = hName->String();
TDataStd_Name::Set(aResult, aName);
return aResult;
}
+//=======================================================================
+//function : collectRepresentationItems
+//purpose : recursive collection of representation items for given representation
+// with all representations, related to it.
+//=======================================================================
+
+void collectRepresentationItems(const Interface_Graph& theGraph,
+ const Handle(StepShape_ShapeRepresentation)& theRepresentation,
+ NCollection_Sequence<Handle(StepRepr_RepresentationItem)>& theItems)
+{
+ Handle(StepRepr_HArray1OfRepresentationItem) aReprItems = theRepresentation->Items();
+ for (Standard_Integer itemIt = aReprItems->Lower(); itemIt <= aReprItems->Upper(); itemIt++)
+ theItems.Append(aReprItems->Value(itemIt));
+
+ Interface_EntityIterator entIt = theGraph.TypedSharings(theRepresentation, STANDARD_TYPE(StepRepr_RepresentationRelationship));
+ for (entIt.Start(); entIt.More(); entIt.Next())
+ {
+ Handle(StepRepr_RepresentationRelationship) aRelationship = Handle(StepRepr_RepresentationRelationship)::DownCast(entIt.Value());
+ if (aRelationship->Rep1() == theRepresentation)
+ {
+ Handle(StepShape_ShapeRepresentation)
+ aRepr = Handle(StepShape_ShapeRepresentation)::DownCast(aRelationship->Rep2());
+ if (!aRepr.IsNull())
+ collectRepresentationItems(theGraph, aRepr, theItems);
+ }
+ }
+}
+
//=======================================================================
//function : ExpandSubShapes
//purpose :
continue;
// Access representation items
- Handle(StepRepr_HArray1OfRepresentationItem) aReprItems = aShapeRepr->Items();
+ NCollection_Sequence<Handle(StepRepr_RepresentationItem)> aReprItems;
+ collectRepresentationItems(Graph, aShapeRepr, aReprItems);
- if ( aReprItems.IsNull() )
+ if (aReprItems.Length() == 0)
continue;
if ( !ShapeLabelMap.IsBound(aRootShape) )
continue;
TDF_Label aRootLab = ShapeLabelMap.Find(aRootShape);
+ // Do not add subshapes to assembly,
+ // they will be processed with corresponding Shape_Product_Definition of necessary part.
+ if (ShapeTool->IsAssembly(aRootLab))
+ continue;
StepRepr_SequenceOfRepresentationItem aMSBSeq;
StepRepr_SequenceOfRepresentationItem aSBSMSeq;
// Iterate over the top level representation items collecting the
// topological containers to expand
- for ( Standard_Integer i = aReprItems->Lower(); i <= aReprItems->Upper(); ++i )
+ for (Standard_Integer i = 1; i <= aReprItems.Length(); ++i)
{
- Handle(StepRepr_RepresentationItem) aTRepr = aReprItems->Value(i);
+ Handle(StepRepr_RepresentationItem) aTRepr = aReprItems.Value(i);
if ( aTRepr->IsKind( STANDARD_TYPE(StepShape_ManifoldSolidBrep) ) )
aMSBSeq.Append(aTRepr);
else if ( aTRepr->IsKind( STANDARD_TYPE(StepShape_ShellBasedSurfaceModel) ) )
// Expand Manifold Solid BReps
for ( Standard_Integer i = 1; i <= aMSBSeq.Length(); ++i )
{
- const Handle(StepRepr_RepresentationItem)& aManiRepr = aMSBSeq.Value(i);
-
// Put additional Label for SOLID
- TDF_Label aManiLab;
- if ( doInsertSolidLab )
- aManiLab = SettleShapeData(aManiRepr, aRootLab, ShapeTool, TP);
- else
- aManiLab = aRootLab;
+ if (doInsertSolidLab)
+ SettleShapeData(aMSBSeq.Value(i), aRootLab, ShapeTool, TP);
- ExpandManifoldSolidBrep(aManiLab, aMSBSeq.Value(i), TP, ShapeTool);
+ ExpandManifoldSolidBrep(aRootLab, aMSBSeq.Value(i), TP, ShapeTool);
}
// Expand Shell-Based Surface Models
const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
{
// Record CAF data
- TDF_Label aShellLab = SettleShapeData(Shell, RootLab, ShapeTool, TP);
+ SettleShapeData(Shell, RootLab, ShapeTool, TP);
// Access faces
Handle(StepShape_HArray1OfFace) aFaces = Shell->CfsFaces();
const Handle(StepShape_Face)& aFace = aFaces->Value(f);
// Record CAF data
- TDF_Label aFaceLab = SettleShapeData(aFace, aShellLab, ShapeTool, TP);
+ SettleShapeData(aFace, RootLab, ShapeTool, TP);
// Access face bounds
Handle(StepShape_HArray1OfFaceBound) aWires = aFace->Bounds();
const Handle(StepShape_Loop)& aWire = aWires->Value(w)->Bound();
// Record CAF data
- TDF_Label aWireLab = SettleShapeData(aWire, aFaceLab, ShapeTool, TP);
+ SettleShapeData(aWire, RootLab, ShapeTool, TP);
// Access wire edges
// Currently only EDGE LOOPs are considered (!)
Handle(StepShape_Edge) anEdge = anEdges->Value(e)->EdgeElement();
// Record CAF data
- TDF_Label anEdgeLab = SettleShapeData(anEdge, aWireLab, ShapeTool, TP);
+ SettleShapeData(anEdge, RootLab, ShapeTool, TP);
// Access vertices
Handle(StepShape_Vertex) aV1 = anEdge->EdgeStart();
Handle(StepShape_Vertex) aV2 = anEdge->EdgeEnd();
// Record CAF data
- SettleShapeData(aV1, anEdgeLab, ShapeTool, TP);
- SettleShapeData(aV2, anEdgeLab, ShapeTool, TP);
+ SettleShapeData(aV1, RootLab, ShapeTool, TP);
+ SettleShapeData(aV2, RootLab, ShapeTool, TP);
}
}
}
--- /dev/null
+puts "=========="
+puts "OCC29403"
+puts "=========="
+puts ""
+#########################################################
+# Subshapes names are not imported from step
+#########################################################
+
+param read.stepcaf.subshapes.name 1
+param write.stepcaf.subshapes.name 1
+
+pload DCAF
+
+ReadStep doc [locate_data_file bug29403_ECOR030312.stp]
+set info1 [XStat doc]
+regexp {level N 0 +: +([-0-9.+eE]+)} $info1 full l0
+regexp {level N 1 +: +([-0-9.+eE]+)} $info1 full l1
+regexp {Total number of labels for shapes in the document += +([-0-9.+eE]+)} $info1 full nb
+regexp {Number of labels with name += +([-0-9.+eE]+)} $info1 full nbname
+
+WriteStep doc $imagedir/doc_subshapes.stp
+
+ReadStep after_doc $imagedir/doc_subshapes.stp
+
+set info2 [XStat after_doc]
+regexp {level N 0 +: +([-0-9.+eE]+)} $info2 full l0_1
+regexp {level N 1 +: +([-0-9.+eE]+)} $info2 full l1_1
+regexp {Total number of labels for shapes in the document += +([-0-9.+eE]+)} $info2 full nb_1
+regexp {Number of labels with name += +([-0-9.+eE]+)} $info2 full nbname_1
+
+if { ${l0} != ${l0_1} ||
+ ${l0} != "38" ||
+ ${l1} != ${l1_1} ||
+ ${l1} != "85" ||
+ ${nb} != ${nb_1} ||
+ ${nb} != "123" ||
+ ${nbname} != ${nbname_1} ||
+ ${nbname} != "123"} {
+ puts "Error : Document is read/written wrong!"
+}
+
+Close doc
+Close after_doc
+file delete -force $imagedir/doc_subshapes.stp
+
+param read.stepcaf.subshapes.name 0
+param write.stepcaf.subshapes.name 0
# Original bug : 23384
# Date : 16 Aug 2012
-XOpen [locate_data_file bug23384-doc_subshapes.xbf] doc
+pload DCAF
+XOpen [locate_data_file bug23384-doc_subshapes_plain.xbf] doc
set info1 [XStat doc]
regexp {level N 0 +: +([-0-9.+eE]+)} $info1 full l0
regexp {level N 1 +: +([-0-9.+eE]+)} $info1 full l1
-regexp {level N 2 +: +([-0-9.+eE]+)} $info1 full l2
-regexp {level N 3 +: +([-0-9.+eE]+)} $info1 full l3
-regexp {level N 4 +: +([-0-9.+eE]+)} $info1 full l4
-regexp {level N 5 +: +([-0-9.+eE]+)} $info1 full l5
-regexp {level N 6 +: +([-0-9.+eE]+)} $info1 full l6
regexp {Total number of labels for shapes in the document += +([-0-9.+eE]+)} $info1 full nb
regexp {Number of labels with name += +([-0-9.+eE]+)} $info1 full nbname
set info2 [XStat after_doc]
regexp {level N 0 +: +([-0-9.+eE]+)} $info2 full l0_1
regexp {level N 1 +: +([-0-9.+eE]+)} $info2 full l1_1
-regexp {level N 2 +: +([-0-9.+eE]+)} $info2 full l2_1
-regexp {level N 3 +: +([-0-9.+eE]+)} $info2 full l3_1
-regexp {level N 4 +: +([-0-9.+eE]+)} $info2 full l4_1
-regexp {level N 5 +: +([-0-9.+eE]+)} $info2 full l5_1
-regexp {level N 6 +: +([-0-9.+eE]+)} $info2 full l6_1
regexp {Total number of labels for shapes in the document += +([-0-9.+eE]+)} $info2 full nb_1
regexp {Number of labels with name += +([-0-9.+eE]+)} $info2 full nbname_1
if { ${l0} != ${l0_1} ||
+ ${l0} != "4" ||
${l1} != ${l1_1} ||
- ${l2} != ${l2_1} ||
- ${l3} != ${l3_1} ||
- ${l4} != ${l4_1} ||
- ${l5} != ${l5_1} ||
- ${l6} != ${l6_1} ||
+ ${l1} != "131" ||
${nb} != ${nb_1} ||
- ${nbname} != ${nbname_1} } {
+ ${nb} != "135" ||
+ ${nbname} != ${nbname_1} ||
+ ${nbname} != "135"} {
puts "Error : Document is read/written wrong!"
}
+
+Close doc
+Close after_doc
+file delete -force $imagedir/doc_subshapes.stp