SetLabelNameByLink(L);
}
+TDF_Label XCAFDoc_ShapeTool::SetLocation( const TDF_Label &theLabel,
+ const TopLoc_Location &theLoc)
+{
+ if(theLoc.IsIdentity())
+ {
+ return theLabel;
+ }
+
+ TDF_Label aRefLabel = theLabel;
+
+ if (!IsReference (theLabel))
+ {
+ TDF_TagSource aTag;
+ aRefLabel = aTag.NewChild(Label());
+ MakeReference( aRefLabel,theLabel, theLoc);
+ return aRefLabel;
+
+ }
+ TDF_Label aShapeLabel;
+ TopLoc_Location anOldLoc;
+ GetReferredShape (aRefLabel, aShapeLabel);
+ anOldLoc = GetLocation(aRefLabel);
+ TopLoc_Location aNewLoc (theLoc.Transformation() * anOldLoc.Transformation());
+ aRefLabel.ForgetAllAttributes (Standard_True);
+ MakeReference(aRefLabel, aShapeLabel, aNewLoc);
+ return aRefLabel;
+}
+
+ /* XCAFDoc_Location::Set (aRefLabel, aNewLoc);
+
+ Handle(TDataStd_TreeNode) refNode, mainNode;
+ mainNode = TDataStd_TreeNode::Set ( aRefLabel, XCAFDoc::ShapeRefGUID() );
+ refNode = TDataStd_TreeNode::Set ( aShapeLabel, XCAFDoc::ShapeRefGUID() );
+ refNode->Remove();
+ mainNode->Append(refNode);*/
//=======================================================================
//function : addShape
//purpose : private
//! from upper_usage componet to next_usage
//! Returns null attribute if no SHUO found
Standard_EXPORT static Standard_Boolean FindSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& theSHUOAttr);
+
+ Standard_EXPORT TDF_Label SetLocation( const TDF_Label &theLabel,
+ const TopLoc_Location &theLoc);
//! Convert Shape (compound) to assembly
Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape) ;
return 0;
}
+static Standard_Integer setLocation (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3)
+ {
+ di << "Use: " << argv[0] << " result Doc label shape \n";
+ return 1;
+ }
+ Handle(TDocStd_Document) Doc;
+ DDocStd::GetDocument(argv[2], Doc);
+ if ( Doc.IsNull() ) { di << argv[2] << " is not a document\n"; return 1; }
+ Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
+
+ TDF_Label aLabel;
+ TDF_Tool::Label(Doc->GetData(), argv[3], aLabel);
+ if (aLabel.IsNull()) {di<<"No such Label\n"; return 1;}
+ TopoDS_Shape aInitShape = DBRep::Get(argv[4]);
+ if (aInitShape.IsNull()) {
+ di << "Shape " << argv[2] << " is null\n";
+ return 1;
+ }
+ TopLoc_Location aLoc = aInitShape.Location();
+ TDF_Label aReflabel = myAssembly->SetLocation(aLabel, aLoc);
+ TopLoc_Location aNewLoc = myAssembly->GetLocation(aReflabel);
+ TopoDS_Shape aRes = myAssembly->GetShape(aReflabel);
+ DBRep::Set(argv[1], aRes);
+ return 0;
+}
+
//=======================================================================
//function : InitCommands
//purpose :
di.Add ("XSetInstanceSHUO","Doc shape \t: sets the SHUO structure for indicated component",
__FILE__, setStyledComponent, g);
+
+ di.Add ("XSetLocation", "result Doc Label initshape", __FILE__, setLocation, g);
}