1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
snn
014eaedd30 0030341: Unset child/parent links bugs fix 2018-11-07 14:04:33 +03:00
snn
498fc86d8e 0030341: XCAFDoc_GraphNode doesn't copy children upon pasting 2018-11-06 11:32:32 +03:00

View File

@@ -93,7 +93,6 @@ XCAFDoc_GraphNode::XCAFDoc_GraphNode ()
{ {
} }
//======================================================================= //=======================================================================
//function : SetGraphID //function : SetGraphID
//purpose : //purpose :
@@ -105,8 +104,6 @@ void XCAFDoc_GraphNode::SetGraphID (const Standard_GUID& explicitID)
myGraphID = explicitID; myGraphID = explicitID;
} }
//======================================================================= //=======================================================================
//function : SetFather //function : SetFather
//purpose : //purpose :
@@ -142,9 +139,11 @@ void XCAFDoc_GraphNode::UnSetFather(const Handle(XCAFDoc_GraphNode)& F)
{ {
Standard_Integer Findex = FatherIndex(F); Standard_Integer Findex = FatherIndex(F);
if (Findex != 0) if (Findex != 0)
{
F->UnSetChildlink(this); F->UnSetChildlink(this);
UnSetFatherlink(F); UnSetFatherlink(F);
} }
}
//======================================================================= //=======================================================================
@@ -155,9 +154,10 @@ void XCAFDoc_GraphNode::UnSetFather(const Handle(XCAFDoc_GraphNode)& F)
void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex) void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex)
{ {
if (Findex != 0) if (Findex != 0)
{
UnSetFather( GetFather(Findex) ); UnSetFather( GetFather(Findex) );
} }
}
//======================================================================= //=======================================================================
//function : UnSetFatherlink //function : UnSetFatherlink
@@ -167,7 +167,11 @@ void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex)
void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F) void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F)
{ {
Backup(); Backup();
myFathers.Remove( FatherIndex(F) ); Standard_Integer Findex = FatherIndex(F);
if (Findex != 0)
{
myFathers.Remove(Findex);
}
} }
//======================================================================= //=======================================================================
@@ -179,10 +183,11 @@ void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch)
{ {
Standard_Integer Chindex = ChildIndex(Ch); Standard_Integer Chindex = ChildIndex(Ch);
if (Chindex != 0) if (Chindex != 0)
{
Ch->UnSetFatherlink(this); Ch->UnSetFatherlink(this);
UnSetChildlink(Ch); UnSetChildlink(Ch);
} }
}
//======================================================================= //=======================================================================
//function : UnSetChild //function : UnSetChild
@@ -192,9 +197,10 @@ void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch)
void XCAFDoc_GraphNode::UnSetChild(const Standard_Integer Chindex) void XCAFDoc_GraphNode::UnSetChild(const Standard_Integer Chindex)
{ {
if (Chindex != 0) if (Chindex != 0)
{
UnSetChild( GetChild(Chindex) ); UnSetChild( GetChild(Chindex) );
} }
}
//======================================================================= //=======================================================================
//function : UnSetChildlink //function : UnSetChildlink
@@ -204,7 +210,11 @@ void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch)
void XCAFDoc_GraphNode::UnSetChildlink(const Handle(XCAFDoc_GraphNode)& Ch) void XCAFDoc_GraphNode::UnSetChildlink(const Handle(XCAFDoc_GraphNode)& Ch)
{ {
Backup(); Backup();
myChildren.Remove( ChildIndex(Ch) ); Standard_Integer Chindex = ChildIndex(Ch);
if (Chindex != 0)
{
myChildren.Remove(Chindex);
}
} }
//======================================================================= //=======================================================================
@@ -348,15 +358,19 @@ void XCAFDoc_GraphNode::Paste(const Handle(TDF_Attribute)& into,
if (!RT->HasRelocation(myFathers(i), func) && RT->AfterRelocate()) { if (!RT->HasRelocation(myFathers(i), func) && RT->AfterRelocate()) {
func.Nullify(); func.Nullify();
} }
if (!func.IsNull()) {
intof->SetFather(func); intof->SetFather(func);
} }
}
i = 1; i = 1;
for (; i <= NbChildren(); i++) { for (; i <= NbChildren(); i++) {
if (!RT->HasRelocation(myChildren(i), func) && RT->AfterRelocate()) { if (!RT->HasRelocation(myChildren(i), func) && RT->AfterRelocate()) {
func.Nullify(); func.Nullify();
} }
intof->SetFather(func); if (!func.IsNull()) {
intof->SetChild(func);
}
} }
intof->SetGraphID(myGraphID); intof->SetGraphID(myGraphID);
} }