mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030919: ACIS Import - Improving translation of string attributes into XDE
- Added possibility to get (or create if absent) a properties attribute via ShapeTool; - Added Draw command to print properties attached to a Label.
This commit is contained in:
parent
fb64d0f4a2
commit
07f2064617
@ -2108,3 +2108,38 @@ Standard_Boolean XCAFDoc_ShapeTool::updateComponent(const TDF_Label& theItemLabe
|
|||||||
|
|
||||||
return isModified;
|
return isModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetNamedProperties
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Handle(TDataStd_NamedData) XCAFDoc_ShapeTool::GetNamedProperties (const TDF_Label& theLabel,
|
||||||
|
const Standard_Boolean theToCreate) const
|
||||||
|
{
|
||||||
|
Handle(TDataStd_NamedData) aNamedProperty;
|
||||||
|
if (!theLabel.FindAttribute(TDataStd_NamedData::GetID(), aNamedProperty) && theToCreate)
|
||||||
|
{
|
||||||
|
aNamedProperty = TDataStd_NamedData::Set(theLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return aNamedProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetNamedProperties
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Handle(TDataStd_NamedData) XCAFDoc_ShapeTool::GetNamedProperties (const TopoDS_Shape& theShape,
|
||||||
|
const Standard_Boolean theToCreate) const
|
||||||
|
{
|
||||||
|
Handle(TDataStd_NamedData) aNamedProperty;
|
||||||
|
TDF_Label aLabel;
|
||||||
|
if (!Search (theShape, aLabel))
|
||||||
|
return aNamedProperty;
|
||||||
|
|
||||||
|
aNamedProperty = GetNamedProperties (aLabel, theToCreate);
|
||||||
|
|
||||||
|
return aNamedProperty;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <XCAFDoc_DataMapOfShapeLabel.hxx>
|
#include <XCAFDoc_DataMapOfShapeLabel.hxx>
|
||||||
#include <Standard_Boolean.hxx>
|
#include <Standard_Boolean.hxx>
|
||||||
|
#include <TDataStd_NamedData.hxx>
|
||||||
#include <TDF_Attribute.hxx>
|
#include <TDF_Attribute.hxx>
|
||||||
#include <TDF_LabelSequence.hxx>
|
#include <TDF_LabelSequence.hxx>
|
||||||
#include <Standard_Integer.hxx>
|
#include <Standard_Integer.hxx>
|
||||||
@ -410,8 +411,19 @@ public:
|
|||||||
Standard_EXPORT static Standard_Boolean FindSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& theSHUOAttr);
|
Standard_EXPORT static Standard_Boolean FindSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& theSHUOAttr);
|
||||||
|
|
||||||
//! Convert Shape (compound/compsolid/shell/wire) to assembly
|
//! Convert Shape (compound/compsolid/shell/wire) to assembly
|
||||||
Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape) ;
|
Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape);
|
||||||
|
|
||||||
|
//! Method to get NamedData attribute assigned to the given shape label.
|
||||||
|
//! @param theLabel [in] the shape Label
|
||||||
|
//! @param theToCreate [in] create and assign attribute if it doesn't exist
|
||||||
|
//! @return Handle to the NamedData attribute or Null if there is none
|
||||||
|
Standard_EXPORT Handle(TDataStd_NamedData) GetNamedProperties (const TDF_Label& theLabel, const Standard_Boolean theToCreate = Standard_False) const;
|
||||||
|
|
||||||
|
//! Method to get NamedData attribute assigned to a label of the given shape.
|
||||||
|
//! @param theShape [in] input shape
|
||||||
|
//! @param theToCreate [in] create and assign attribute if it doesn't exist
|
||||||
|
//! @return Handle to the NamedData attribute or Null if there is none
|
||||||
|
Standard_EXPORT Handle(TDataStd_NamedData) GetNamedProperties(const TopoDS_Shape& theShape, const Standard_Boolean theToCreate = Standard_False) const;
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_ShapeTool,TDF_Attribute)
|
DEFINE_STANDARD_RTTIEXT(XCAFDoc_ShapeTool,TDF_Attribute)
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <Draw.hxx>
|
#include <Draw.hxx>
|
||||||
#include <gp_Trsf.hxx>
|
#include <gp_Trsf.hxx>
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
#include <TDataStd_NamedData.hxx>
|
||||||
#include <TDF_AttributeSequence.hxx>
|
#include <TDF_AttributeSequence.hxx>
|
||||||
#include <TDF_Label.hxx>
|
#include <TDF_Label.hxx>
|
||||||
#include <TDF_LabelSequence.hxx>
|
#include <TDF_LabelSequence.hxx>
|
||||||
@ -927,6 +928,64 @@ static Standard_Integer updateAssemblies(Draw_Interpretor& di, Standard_Integer
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Standard_Integer XGetProperties(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||||
|
{
|
||||||
|
if (argc != 3)
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: wrong number of arguments\nUse: " << argv[0] << " Doc Label\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(TDocStd_Document) aDoc;
|
||||||
|
DDocStd::GetDocument(argv[1], aDoc);
|
||||||
|
if (aDoc.IsNull())
|
||||||
|
{
|
||||||
|
std::cout << "Syntax error: " << argv[1] << " is not a document\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TDF_Label aLabel;
|
||||||
|
TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel);
|
||||||
|
|
||||||
|
// Get XDE shape tool
|
||||||
|
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
||||||
|
|
||||||
|
Handle(TDataStd_NamedData) aNamedData = aShapeTool->GetNamedProperties(aLabel);
|
||||||
|
|
||||||
|
if (aNamedData.IsNull())
|
||||||
|
{
|
||||||
|
di << argv[2] << " has no properties\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aNamedData->HasIntegers())
|
||||||
|
{
|
||||||
|
TColStd_DataMapOfStringInteger anIntProperties = aNamedData->GetIntegersContainer();
|
||||||
|
for (TColStd_DataMapIteratorOfDataMapOfStringInteger anIter(anIntProperties); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
di << anIter.Key() << " : " << anIter.Value() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aNamedData->HasReals())
|
||||||
|
{
|
||||||
|
TDataStd_DataMapOfStringReal aRealProperties = aNamedData->GetRealsContainer();
|
||||||
|
for (TDataStd_DataMapIteratorOfDataMapOfStringReal anIter(aRealProperties); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
di << anIter.Key() << " : " << anIter.Value() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aNamedData->HasStrings())
|
||||||
|
{
|
||||||
|
TDataStd_DataMapOfStringString aStringProperties = aNamedData->GetStringsContainer();
|
||||||
|
for (TDataStd_DataMapIteratorOfDataMapOfStringString anIter(aStringProperties); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
di << anIter.Key() << " : " << anIter.Value() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : InitCommands
|
//function : InitCommands
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -1039,4 +1098,7 @@ void XDEDRAW_Shapes::InitCommands(Draw_Interpretor& di)
|
|||||||
|
|
||||||
di.Add ("XUpdateAssemblies","Doc \t: updates assembly compounds",
|
di.Add ("XUpdateAssemblies","Doc \t: updates assembly compounds",
|
||||||
__FILE__, updateAssemblies, g);
|
__FILE__, updateAssemblies, g);
|
||||||
|
|
||||||
|
di.Add("XGetProperties", "Doc Label \t: prints named properties assigned to the Label",
|
||||||
|
__FILE__, XGetProperties, g);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user