TDF_ChildIterator aChldLabIt(shapeL);
for (; aChldLabIt.More(); aChldLabIt.Next() ) {
TDF_Label aSubLabel = aChldLabIt.Value();
- TopoDS_Shape aSubShape;
- if (GetShape(aSubLabel, aSubShape) && aSubShape.IsSame(sub)) {
+ Handle(TNaming_NamedShape) NS;
+ if (!aSubLabel.FindAttribute(TNaming_NamedShape::GetID(), NS))
+ continue;
+ TopoDS_Shape aSubShape = TNaming_Tool::GetShape(NS);
+ if (!aSubShape.IsNull() && aSubShape.IsSame(sub)) {
L = aSubLabel;
return Standard_True;
}
}
+
return Standard_False;
}
TNaming_Builder tnBuild(L);
tnBuild.Generated(sub);
-// if(!mySubShapes.IsBound(sub))
-// mySubShapes.Bind(sub,L);
-
return L;
}
+//=======================================================================
+//function : AddSubShape
+//purpose :
+//=======================================================================
+
+Standard_Boolean XCAFDoc_ShapeTool::AddSubShape(const TDF_Label &shapeL,
+ const TopoDS_Shape &sub,
+ TDF_Label &addedSubShapeL) const
+{
+ addedSubShapeL = TDF_Label();
+ // Check if adding subshape is possible
+ if (!IsSimpleShape(shapeL) || !IsTopLevel(shapeL))
+ return Standard_False;
+
+ // Try to find already existed subshape
+ if (FindSubShape(shapeL, sub, addedSubShapeL))
+ return Standard_False;
+
+ if (!IsSubShape(shapeL, sub))
+ return Standard_False;
+
+ TDF_TagSource aTag;
+ addedSubShapeL = aTag.NewChild(shapeL);
+ TNaming_Builder tnBuild(addedSubShapeL);
+ tnBuild.Generated(sub);
+
+ return Standard_True;
+}
+
//=======================================================================
//function : FindMainShapeUsingMap
TopoDS_Iterator anIter(theShape);
Standard_Boolean isCompoundPart = (GetShape(thePart).ShapeType() == TopAbs_COMPOUND);
Standard_Boolean isAssembly = IsAssembly(thePart);
+
for(; anIter.More(); anIter.Next()) {
const TopoDS_Shape& aChildShape = anIter.Value();
TDF_Label aChildLabel;
makeSubShape(theMainShapeL, thePart, aChildShape, theLoc);
continue;
}
-
//get name
Handle(TDataStd_Name) anAttr;
aChildLabel.FindAttribute(TDataStd_Name::GetID(), anAttr);
TopLoc_Location aSubLoc;
// Calculate location for subshapes of compound parts
+ aSubLoc = aChildShape.Location();
if (isCompoundPart)
- aSubLoc = theLoc.Inverted() * aChildShape.Location();
+ aSubLoc = theLoc.Inverted() * aSubLoc;
//make subshape
TDF_Label aSubLabel;
- if (!FindSubShape(thePart, aChildShape.Located(aSubLoc), aSubLabel)) {
- aSubLabel = AddSubShape(thePart, aChildShape.Located(aSubLoc));
+ // Identical location and empty location are not the same for ShapeTool, so try to process both
+ // in case of aSubLoc is not identical, the second Add try will not affect algorithm.
+ Standard_Boolean isNewSubL;
+ isNewSubL = AddSubShape(thePart, aChildShape.Located(aSubLoc), aSubLabel);
+ if (aSubLabel.IsNull())
+ {
+ isNewSubL = AddSubShape(thePart, aChildShape.Located(TopLoc_Location()), aSubLabel);
+ }
+ if (isNewSubL){
//set name to sub shape
if (!anAttr.IsNull()) {
TDataStd_Name::Set(aSubLabel, anAttr->Get());
aChildLabel.ForgetAllAttributes();
}
}
+
makeSubShape(theMainShapeL, thePart, aChildShape, theLoc);
}
}
--- /dev/null
+puts "============================================================================"
+puts "0030779: Data Exchange - Problems with located subshapes in expand compounds"
+puts "============================================================================"
+puts ""
+
+pload DCAF
+
+XOpen [locate_data_file bug30779.xbf] D
+XExpand D 1
+
+# check model structure after expand
+set result [XGetTopLevelShapes D]
+if {$result != "0:1:1:1 0:1:1:2 0:1:1:3 "} {
+ puts "Error: wrong result of Expand compounds."
+}
+
+# check colors of subshapes
+for {set i 1} {$i <= 4} {incr i} {
+ set sublabel 0:1:1:3:$i
+ set color [XGetShapeColor D $sublabel]
+ if {$color != "GRAY"} {
+ puts "Error: wrong color after expand compounds."
+ }
+}
+
+Close D
+