-- Initially it holds empty TopoDS_Compound
SetShape (me:mutable; L: Label from TDF; S: Shape from TopoDS);
- ---Purpose: Sets representation (TopoDS_Shape) for top-level shape
+ ---Purpose: Sets representation (TopoDS_Shape) for top-level shape.
+ -- If S has location(location.IsIdentity() is false),
+ -- command will be skipped. Sub-shapes of S which is
+ -- subshape of old shape, will be stored ( all atributes will be stored).
+ -- If a sub-label of L is not a sub-shape of the new shape,
+ -- it will be removed.
AddShape (me:mutable; S: Shape from TopoDS;
makeAssembly: Boolean = Standard_True;
RemoveComponent (me; comp: Label from TDF);
---Purpose: Removes a component from its assembly
+ UpdateAssociatedAssembly (me; L: Label from TDF);
+ ---Purpose: Update labels associated with Label <L>
+
UpdateAssembly (me; L: Label from TDF);
---Purpose: Update an assembly at label <L>
//=======================================================================
void XCAFDoc_ShapeTool::SetShape (const TDF_Label& L, const TopoDS_Shape& S)
-{
+{
+ if(IsReference(L) || !IsTopLevel(L) || /*IsAssembly(L) ||*/ !S.Location().IsIdentity())
+ return;
+
+ TDF_LabelSequence aSubShapes;
+ GetSubShapes(L, aSubShapes);
+
TNaming_Builder tnBuild(L);
tnBuild.Generated(S);
Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L);
-// if ( ! L.FindAttribute(XCAFDoc_ShapeMapTool::GetID(), A) ) {
-// A = XCAFDoc_ShapeMapTool::Set(L);
-// L.AddAttribute(A);
-// }
A->SetShape(S);
+ for(Standard_Integer i = 1; i<=aSubShapes.Length(); i++)
+ {
+ TDF_Label aSubLabel = aSubShapes(i);
+ if (!IsSubShape(L, GetShape(aSubLabel)))
+ {
+ aSubLabel.ForgetAllAttributes();
+ }
+ }
+
if(!myShapeLabels.IsBound(S)) {
myShapeLabels.Bind(S,L);
}
-
- //:abv 31.10.01: update assemblies that refer a shape
- TDF_LabelSequence Labels;
- if ( GetUsers ( L, Labels, Standard_True ) ) {
- for ( Standard_Integer i=Labels.Length(); i >=1; i-- )
- UpdateAssembly ( Labels(i) );
- }
+
+ UpdateAssociatedAssembly(L);
}
//=======================================================================
}
}
+//=======================================================================
+//function : UpdateAssociatedAssembly
+//purpose :
+//=======================================================================
+
+void XCAFDoc_ShapeTool::UpdateAssociatedAssembly (const TDF_Label& L) const
+{
+ TDF_LabelSequence Labels;
+ if ( GetUsers ( L, Labels ) ) {
+ for ( Standard_Integer i=Labels.Length(); i >=1; i-- )
+ {
+ TDF_Label anAssemblyLabel = Labels(i).Father();
+ if(!anAssemblyLabel.IsNull())
+ {
+ UpdateAssembly(anAssemblyLabel);
+ }
+ }
+ }
+}
+
//=======================================================================
//function : UpdateAssembly
//purpose :
{
if ( ! IsAssembly(L) ) return;
- TopoDS_Compound newassembly;
BRep_Builder b;
- b.MakeCompound(newassembly);
+ TopoDS_Shape aShape = GetShape(L);
+ Standard_Boolean isFree = aShape.Free();
+ if (!isFree)
+ aShape.Free(Standard_True);
+
+ TopTools_SequenceOfShape aSubShapeSeq;
+ TopoDS_Iterator Iterator(aShape);
+ for (; Iterator.More(); Iterator.Next())
+ aSubShapeSeq.Append(Iterator.Value());
+
+ for (Standard_Integer i = 1; i <= aSubShapeSeq.Length(); i++)
+ b.Remove(aShape, aSubShapeSeq.Value(i));
TDF_ChildIterator chldLabIt(L);
for (; chldLabIt.More(); chldLabIt.Next() ) {
TDF_Label subLabel = chldLabIt.Value();
if ( IsComponent ( subLabel ) ) {
- b.Add(newassembly, GetShape(subLabel));
+ b.Add(aShape, GetShape(subLabel));
}
}
+
+ if (!isFree)
+ aShape.Free(Standard_False);
+
TNaming_Builder tnBuild(L);
- tnBuild.Generated(newassembly);
+ tnBuild.Generated(aShape);
+
+ Handle(XCAFDoc_ShapeMapTool) A = XCAFDoc_ShapeMapTool::Set(L);
+ A->SetShape(aShape);
+
+ UpdateAssociatedAssembly(L);
}
//=======================================================================