1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0023594: XCAFDoc_LayerTool extended to work with layer defined by its label, not string

This commit is contained in:
Roman Lygin 2012-11-28 13:19:04 +04:00
parent f898928aa0
commit a28d577831
2 changed files with 128 additions and 17 deletions

View File

@ -118,16 +118,31 @@ is
---Purpose: Remove link from label <L> and Layer <aLayer>.
-- returns FALSE if no such layer.
UnSetOneLayer (me; L: Label from TDF;
aLayerL: Label from TDF) returns Boolean;
---Purpose: Remove link from label <L> and Layer <aLayerL>.
-- returns FALSE if <aLayerL> is not a layer label.
IsSet (me; L: Label from TDF;
aLayer : ExtendedString from TCollection) returns Boolean;
---Purpose: Returns True if label <L> has a Layer assosiated
-- with the <aLayer>.
IsSet (me; L: Label from TDF;
aLayerL: Label from TDF) returns Boolean;
---Purpose: Returns True if label <L> has a Layer assosiated
-- with the <aLayerL> label.
GetLayers (me: mutable; L: Label from TDF;
aLayerS : out HSequenceOfExtendedString from TColStd)
returns Boolean;
---Purpose: Return sequence of strings <aLayerS> that assosiated with label <L>.
GetLayers (me: mutable; L: Label from TDF;
aLayerLS : out LabelSequence from TDF)
returns Boolean;
---Purpose: Return sequence of labels <aLayerSL> that assosiated with label <L>.
GetLayers (me: mutable; L: Label from TDF) returns HSequenceOfExtendedString from TColStd;
---Purpose: Return sequence of strings that assosiated with label <L>.
@ -174,15 +189,29 @@ is
---Purpose: Remove link between shape <Sh> and layer <aLayer>.
-- returns FALSE if no such layer <aLayer> or shape <Sh>.
UnSetOneLayer (me: mutable; Sh: Shape from TopoDS;
aLayerL: Label from TDF) returns Boolean;
---Purpose: Remove link between shape <Sh> and layer <aLayerL>.
-- returns FALSE if no such layer <aLayerL> or shape <Sh>.
IsSet (me: mutable; Sh: Shape from TopoDS;
aLayer : ExtendedString from TCollection) returns Boolean;
---Purpose: Returns True if shape <Sh> has a Layer assosiated
-- with the <aLayer>.
IsSet (me: mutable; Sh: Shape from TopoDS;
aLayerL : Label from TDF) returns Boolean;
---Purpose: Returns True if shape <Sh> has a Layer assosiated
-- with the <aLayerL>.
GetLayers (me: mutable; Sh: Shape from TopoDS;
aLayerS : out HSequenceOfExtendedString from TColStd) returns Boolean;
---Purpose: Return sequence of strings <aLayerS> that assosiated with shape <Sh>.
GetLayers (me: mutable; Sh: Shape from TopoDS;
aLayerLS : out LabelSequence from TDF) returns Boolean;
---Purpose: Return sequence of labels <aLayerLS> that assosiated with shape <Sh>.
GetLayers (me: mutable; Sh: Shape from TopoDS) returns HSequenceOfExtendedString from TColStd;
---Purpose: Return sequence of strings that assosiated with shape <Sh>.

View File

@ -273,13 +273,24 @@ Standard_Boolean XCAFDoc_LayerTool::UnSetOneLayer(const TDF_Label& L,
{
TDF_Label alab;
if ( !FindLayer(aLayer, alab) ) return Standard_False;
return UnSetOneLayer (L, alab);
}
//=======================================================================
//function : UnSetOneLayer
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_LayerTool::UnSetOneLayer(const TDF_Label& L,
const TDF_Label& aLayerL) const
{
Handle(XCAFDoc_GraphNode) FGNode, ChGNode;
if ( !L.FindAttribute (XCAFDoc::LayerRefGUID(), ChGNode) ) return Standard_False;
if ( !alab.FindAttribute (XCAFDoc::LayerRefGUID(), FGNode) ) return Standard_False;
if ( !aLayerL.FindAttribute (XCAFDoc::LayerRefGUID(), FGNode) ) return Standard_False;
ChGNode->UnSetFather(FGNode);
return Standard_True;
}
//=======================================================================
//function : IsSet
//purpose :
@ -303,6 +314,28 @@ Standard_Boolean XCAFDoc_LayerTool::IsSet(const TDF_Label& L,
}
//=======================================================================
//function : IsSet
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_LayerTool::IsSet(const TDF_Label& L,
const TDF_Label& aLayerL) const
{
Handle(XCAFDoc_GraphNode) Node;
Handle(TDataStd_Name) aName;
TDF_Label lab;
if (L.FindAttribute(XCAFDoc::LayerRefGUID(), Node) && (Node->NbFathers() != 0 ) ) {
Standard_Integer i = 1;
for (; i <= Node->NbFathers(); i++) {
lab = Node->GetFather(i)->Label();
if (lab == aLayerL)
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : GetLayers
//purpose :
@ -312,10 +345,26 @@ Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TDF_Label& L,
Handle(TColStd_HSequenceOfExtendedString)& aLayerS)
{
aLayerS = GetLayers(L);
if (aLayerS->Length() != 0) return Standard_True;
return Standard_False;
return (aLayerS->Length() != 0);
}
//=======================================================================
//function : GetLayers
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TDF_Label& L,
TDF_LabelSequence& aLayerLS)
{
aLayerLS.Clear();
Handle(XCAFDoc_GraphNode) aGNode;
if ( L.FindAttribute( XCAFDoc::LayerRefGUID(), aGNode) ) {
for (Standard_Integer i = 1; i <= aGNode->NbFathers(); i++) {
aLayerLS.Append (aGNode->GetFather(i)->Label());
}
}
return aLayerLS.Length() > 0;
}
//=======================================================================
//function : GetLayers
@ -325,19 +374,13 @@ Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TDF_Label& L,
Handle(TColStd_HSequenceOfExtendedString) XCAFDoc_LayerTool::GetLayers(const TDF_Label& L)
{
Handle(TColStd_HSequenceOfExtendedString) aLayerS = new TColStd_HSequenceOfExtendedString;
Handle(XCAFDoc_GraphNode) aGNode;
if ( L.FindAttribute( XCAFDoc::LayerRefGUID(), aGNode) ) {
if ( aGNode->NbFathers() == 0 ) {
return aLayerS;
}
Standard_Integer i = 1;
TDF_Label aLab;
TDF_LabelSequence aLayerLS;
if ( GetLayers( L, aLayerLS ) ) {
for (Standard_Integer i = 1; i <= aLayerLS.Length(); ++i) {
const TDF_Label& aLab = aLayerLS(i);
Handle(TDataStd_Name) aName;
for (; i <= aGNode->NbFathers(); i++) {
aLab = aGNode->GetFather(i)->Label();
if ( aLab.FindAttribute( TDataStd_Name::GetID(), aName ) ) {
aLayerS->Append( aName->Get() );
// cout << aName->Get() <<endl;
}
}
}
@ -451,6 +494,19 @@ Standard_Boolean XCAFDoc_LayerTool::UnSetOneLayer(const TopoDS_Shape& Sh,
return UnSetOneLayer(aLab, aLayer);
}
//=======================================================================
//function : UnSetOneLayer
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_LayerTool::UnSetOneLayer(const TopoDS_Shape& Sh,
const TDF_Label& aLayerL)
{
TDF_Label aLab;
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
return UnSetOneLayer(aLab, aLayerL);
}
//=======================================================================
//function : IsSet
//purpose :
@ -465,6 +521,19 @@ Standard_Boolean XCAFDoc_LayerTool::IsSet(const TopoDS_Shape& Sh,
}
//=======================================================================
//function : IsSet
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_LayerTool::IsSet(const TopoDS_Shape& Sh,
const TDF_Label& aLayerL)
{
TDF_Label aLab;
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
return IsSet(aLab, aLayerL);
}
//=======================================================================
//function : GetLayers
//purpose :
@ -478,6 +547,19 @@ Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TopoDS_Shape& Sh,
return GetLayers(aLab, aLayerS);
}
//=======================================================================
//function : GetLayers
//purpose :
//=======================================================================
Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TopoDS_Shape& Sh,
TDF_LabelSequence& aLayerLS)
{
TDF_Label aLab;
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
return GetLayers(aLab, aLayerLS);
}
//=======================================================================
//function : GetLayers