else
{
// store a plain list of sub-shapes in case if they have custom attributes (usually per-face color)
- RWMesh_NodeAttributes aSubShapeAttribs;
for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); aSubShapeIter.More(); aSubShapeIter.Next())
{
- const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
- if (myAttribMap.Find (aSubShape.Located (TopLoc_Location()), aSubShapeAttribs))
- {
- addSubShapeIntoDoc (theTools, aSubShape, aNewRefLabel, aSubShapeAttribs);
- }
+ addSubShapeIntoDoc(theTools, aSubShapeIter.Value(), aNewRefLabel);
}
}
return Standard_True;
// =======================================================================
Standard_Boolean RWMesh_CafReader::addSubShapeIntoDoc (CafDocumentTools& theTools,
const TopoDS_Shape& theShape,
- const TDF_Label& theParentLabel,
- const RWMesh_NodeAttributes& theAttribs)
+ const TDF_Label& theParentLabel)
{
if (theShape.IsNull()
|| myXdeDoc.IsNull())
return Standard_False;
}
+ RWMesh_NodeAttributes aShapeAttribs;
const TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
- TDF_Label aNewLabel = theTools.ShapeTool->AddSubShape (theParentLabel, theShape);
- if (aNewLabel.IsNull())
+ const Standard_Boolean aHasAttribs = myAttribMap.Find(theShape.Located(TopLoc_Location()), aShapeAttribs);
+
+ // check for the attribute
+ // shell or wire may not contain an attribute, but its subshapes need to be checked
+ if (!aHasAttribs && aShapeType != TopAbs_SHELL &&
+ aShapeType != TopAbs_WIRE)
+ {
+ return Standard_False;
+ }
+
+ for (TopoDS_Iterator aSubShapeIter(theShape, Standard_True, Standard_False); aSubShapeIter.More(); aSubShapeIter.Next())
+ {
+ addSubShapeIntoDoc(theTools, aSubShapeIter.Value(), theParentLabel);
+ }
+
+ if (!aHasAttribs)
{
return Standard_False;
}
+ TDF_Label aNewLabel = theTools.ShapeTool->AddSubShape (theParentLabel, theShape);
+ if (aNewLabel.IsNull())
{
- Handle(XCAFDoc_ShapeMapTool) aShapeMapTool = XCAFDoc_ShapeMapTool::Set (aNewLabel);
- aShapeMapTool->SetShape (theShape);
+ return Standard_False;
}
+ Handle(XCAFDoc_ShapeMapTool) aShapeMapTool = XCAFDoc_ShapeMapTool::Set(aNewLabel);
+ aShapeMapTool->SetShape(theShape);
+
// if new label is a reference get referred shape
TDF_Label aNewRefLabel = aNewLabel;
theTools.ShapeTool->GetReferredShape (aNewLabel, aNewRefLabel);
// put attributes to the Product (shared across Instances)
static const TCollection_AsciiString anEmptyString;
- setShapeName (aNewRefLabel, aShapeType, theAttribs.Name, TDF_Label(), anEmptyString);
- setShapeStyle (theTools, aNewRefLabel, theAttribs.Style);
- setShapeNamedData (theTools, aNewRefLabel, theAttribs.NamedData);
+ setShapeName (aNewRefLabel, aShapeType, aShapeAttribs.Name, TDF_Label(), anEmptyString);
+ setShapeStyle (theTools, aNewRefLabel, aShapeAttribs.Style);
+ setShapeNamedData (theTools, aNewRefLabel, aShapeAttribs.NamedData);
- RWMesh_NodeAttributes aSubShapeAttribs;
- for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); aSubShapeIter.More(); aSubShapeIter.Next())
- {
- const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
- if (myAttribMap.Find (aSubShape.Located (TopLoc_Location()), aSubShapeAttribs))
- {
- addSubShapeIntoDoc (theTools, aSubShape, theParentLabel, aSubShapeAttribs);
- }
- }
return Standard_True;
}
protected:
//! Fill document with new root shapes.
- Standard_EXPORT void fillDocument();
+ Standard_EXPORT virtual void fillDocument();
//! Append new shape into the document (recursively).
Standard_EXPORT Standard_Boolean addShapeIntoDoc (CafDocumentTools& theTools,
//! Append new sub-shape into the document (recursively).
Standard_EXPORT Standard_Boolean addSubShapeIntoDoc (CafDocumentTools& theTools,
const TopoDS_Shape& theShape,
- const TDF_Label& theParentLabel,
- const RWMesh_NodeAttributes& theAttribs);
+ const TDF_Label& theParentLabel);
//! Put name attribute onto the label.
Standard_EXPORT void setShapeName (const TDF_Label& theLabel,