Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. bool TopoNamingHelper::AppendTopoHistory(const std::string& BaseRoot, const TopoNamingHelper& InputData, const std::string& InputTargetNode){
  2.     TDF_Label BaseNode  = this->LabelFromTag(BaseRoot);
  3.     TDF_Label BaseInput = InputData.LabelFromTag(InputTargetNode);
  4.     if (BaseInput.NbChildren() - BaseNode.NbChildren() <= 0){
  5.         // Note, should NOT be less than 0
  6.         return false;
  7.     }
  8.     else{
  9.         // Loop over every node in the InputData that is not in the BaseRoot
  10.         for (int i = (BaseNode.NbChildren() + 1); i <= BaseInput.NbChildren(); i++){
  11.             // This is the new node to add
  12.             TDF_Label NewNode = BaseInput.FindChild(i, false);
  13.             // This method should recursiviely append all children from NewNode into
  14.             // BaseNode...
  15.             this->AppendNode(BaseNode, NewNode);
  16.         }
  17.     }
  18.     return true;
  19. }
  20.  
  21. void TopoNamingHelper::AppendNode(const TDF_Label& Parent, const TDF_Label& Target){
  22.     TDF_Label NewNode = TDF_TagSource::NewChild(Parent);
  23.     TNaming_Builder Builder(NewNode);
  24.     if (Target.IsAttribute(TNaming_NamedShape::GetID())){
  25.         Handle(TNaming_NamedShape) TargetNS;
  26.         Target.FindAttribute(TNaming_NamedShape::GetID(), TargetNS);
  27.         switch (TargetNS->Evolution()){
  28.             case TNaming_PRIMITIVE:{
  29.                 TopoDS_Shape NewShape = TNaming_Tool::GetShape(TargetNS);
  30.                 Builder.Generated(NewShape);
  31.                 break;}
  32.             case TNaming_GENERATED:{
  33.                 TopoDS_Shape OldShape = TNaming_Tool::OriginalShape(TargetNS);
  34.                 TopoDS_Shape NewShape = TNaming_Tool::GetShape(TargetNS);
  35.                 Builder.Generated(OldShape, NewShape);
  36.                 break;}
  37.             case TNaming_MODIFY   :{
  38.                 TopoDS_Shape OldShape = TNaming_Tool::OriginalShape(TargetNS);
  39.                 TopoDS_Shape NewShape = TNaming_Tool::GetShape(TargetNS);
  40.                 Builder.Modify(OldShape, NewShape);
  41.                 break;}
  42.             case TNaming_DELETE   :{
  43.                 TopoDS_Shape OldShape = TNaming_Tool::OriginalShape(TargetNS);
  44.                 Builder.Delete(OldShape);
  45.                 break;}
  46.             default:{
  47.                 std::runtime_error("Do not recognize this TNaming Evolution..."); }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement