1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031388: Data Exchange - support kinematics data in STEP format

- add new STEP entities.
This commit is contained in:
dpasukhi
2020-03-12 19:29:21 +03:00
committed by smoskvin
parent 92c1f9728e
commit 812ee2c9be
352 changed files with 34916 additions and 55 deletions

View File

@@ -374,6 +374,7 @@ void STEPCAFControl_Reader::Init(const Handle(XSControl_WorkSession)& WS,
// necessary only in Writer, to set good actor: WS->SelectNorm ( "STEP" );
myReader.SetWS(WS, scratch);
myFiles.Clear();
myMap.Clear();
}
//=======================================================================
@@ -724,26 +725,25 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
// and insert them to the document
Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
if (STool.IsNull()) return Standard_False;
XCAFDoc_DataMapOfShapeLabel map;
if (asOne)
Lseq.Append(AddShape(reader.OneShape(), STool, NewShapesMap, ShapePDMap, PDFileMap, map));
Lseq.Append(AddShape(reader.OneShape(), STool, NewShapesMap, ShapePDMap, PDFileMap));
else {
for (i = 1; i <= num; i++) {
Lseq.Append(AddShape(reader.Shape(i), STool, NewShapesMap, ShapePDMap, PDFileMap, map));
Lseq.Append(AddShape(reader.Shape(i), STool, NewShapesMap, ShapePDMap, PDFileMap));
}
}
// read colors
if (GetColorMode())
ReadColors(reader.WS(), doc, map);
ReadColors(reader.WS(), doc);
// read names
if (GetNameMode())
ReadNames(reader.WS(), doc, PDFileMap, map);
ReadNames(reader.WS(), doc, PDFileMap);
// read validation props
if (GetPropsMode())
ReadValProps(reader.WS(), doc, PDFileMap, map);
ReadValProps(reader.WS(), doc, PDFileMap);
// read layers
if (GetLayerMode())
@@ -751,7 +751,7 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
// read SHUO entities from STEP model
if (GetSHUOMode())
ReadSHUOs(reader.WS(), doc, PDFileMap, map);
ReadSHUOs(reader.WS(), doc, PDFileMap);
// read GDT entities from STEP model
if (GetGDTMode())
@@ -767,7 +767,7 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
// Expand resulting CAF structure for sub-shapes (optionally with their
// names) if requested
ExpandSubShapes(STool, map, ShapePDMap);
ExpandSubShapes(STool, ShapePDMap);
// Update assembly compounds
STool->UpdateAssemblies();
@@ -783,12 +783,11 @@ TDF_Label STEPCAFControl_Reader::AddShape(const TopoDS_Shape &S,
const Handle(XCAFDoc_ShapeTool) &STool,
const TopTools_MapOfShape &NewShapesMap,
const STEPCAFControl_DataMapOfShapePD &ShapePDMap,
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap)
{
// if shape has already been mapped, just return corresponding label
if (ShapeLabelMap.IsBound(S)) {
return ShapeLabelMap.Find(S);
if (myMap.IsBound(S)) {
return myMap.Find(S);
}
// if shape is located, create instance
@@ -796,16 +795,16 @@ TDF_Label STEPCAFControl_Reader::AddShape(const TopoDS_Shape &S,
TopoDS_Shape S0 = S;
TopLoc_Location loc;
S0.Location(loc);
AddShape(S0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap);
AddShape(S0, STool, NewShapesMap, ShapePDMap, PDFileMap);
TDF_Label L = STool->AddShape(S, Standard_False); // should create reference
ShapeLabelMap.Bind(S, L);
myMap.Bind(S, L);
return L;
}
// if shape is not compound, simple add it
if (S.ShapeType() != TopAbs_COMPOUND) {
TDF_Label L = STool->AddShape(S, Standard_False);
ShapeLabelMap.Bind(S, L);
myMap.Bind(S, L);
return L;
}
@@ -833,7 +832,7 @@ TDF_Label STEPCAFControl_Reader::AddShape(const TopoDS_Shape &S,
if (!EF->GetLabel().IsNull()) {
// but if components >0, ignore extern ref!
if (nbComponents <= 0) {
ShapeLabelMap.Bind(S, EF->GetLabel());
myMap.Bind(S, EF->GetLabel());
STool->SetExternRefs(EF->GetLabel(), SHAS);
return EF->GetLabel();
}
@@ -851,7 +850,7 @@ TDF_Label STEPCAFControl_Reader::AddShape(const TopoDS_Shape &S,
if (!isAssembly) {
TDF_Label L = STool->AddShape(S, Standard_False);
if (SHAS.Length() > 0) STool->SetExternRefs(L, SHAS);
ShapeLabelMap.Bind(S, L);
myMap.Bind(S, L);
return L;
}
@@ -862,16 +861,16 @@ TDF_Label STEPCAFControl_Reader::AddShape(const TopoDS_Shape &S,
TopoDS_Shape Sub0 = it.Value();
TopLoc_Location loc;
Sub0.Location(loc);
TDF_Label subL = AddShape(Sub0, STool, NewShapesMap, ShapePDMap, PDFileMap, ShapeLabelMap);
TDF_Label subL = AddShape(Sub0, STool, NewShapesMap, ShapePDMap, PDFileMap);
if (!subL.IsNull()) {
TDF_Label instL = STool->AddComponent(L, subL, it.Value().Location());
if (!ShapeLabelMap.IsBound(it.Value())) {
ShapeLabelMap.Bind(it.Value(), instL);
if (!myMap.IsBound(it.Value())) {
myMap.Bind(it.Value(), instL);
}
}
}
if (SHAS.Length() > 0) STool->SetExternRefs(L, SHAS);
ShapeLabelMap.Bind(S, L);
myMap.Bind(S, L);
//STool->SetShape ( L, S ); // it is necessary for assemblies OCC1747 // commemted by skl for OCC2941
return L;
@@ -991,8 +990,7 @@ static void propagateColorToParts(const Handle(XCAFDoc_ShapeTool)& theSTool,
//=======================================================================
Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSession) &WS,
Handle(TDocStd_Document)& Doc,
const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
Handle(TDocStd_Document)& Doc) const
{
STEPConstruct_Styles Styles(WS);
if (!Styles.LoadStyles()) {
@@ -1086,7 +1084,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
TopoDS_Shape aSh;
// PTV 10.02.2003 to find component of assembly CORRECTLY
STEPConstruct_Tool Tool(WS);
TDF_Label aShLab = FindInstance(NAUO, CTool->ShapeTool(), Tool, ShapeLabelMap);
TDF_Label aShLab = FindInstance(NAUO, CTool->ShapeTool(), Tool, myMap);
aSh = CTool->ShapeTool()->GetShape(aShLab);
if (!aSh.IsNull()) {
S = aSh;
@@ -1241,8 +1239,7 @@ TDF_Label STEPCAFControl_Reader::FindInstance(const Handle(StepRepr_NextAssembly
Standard_Boolean STEPCAFControl_Reader::ReadNames(const Handle(XSControl_WorkSession) &WS,
Handle(TDocStd_Document)& Doc,
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap) const
{
// get starting data
const Handle(Interface_InterfaceModel) &Model = WS->Model();
@@ -1282,7 +1279,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames(const Handle(XSControl_WorkSes
else name = new TCollection_HAsciiString;
}
// find proper label
L = FindInstance(NAUO, STool, Tool, ShapeLabelMap);
L = FindInstance(NAUO, STool, Tool, myMap);
if (L.IsNull()) continue;
TCollection_ExtendedString str = convertName (name->String());
@@ -1304,7 +1301,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadNames(const Handle(XSControl_WorkSes
name = Prod->Id();
else
name = new TCollection_HAsciiString;
L = GetLabelFromPD(PD, STool, TP, PDFileMap, ShapeLabelMap);
L = GetLabelFromPD(PD, STool, TP, PDFileMap, myMap);
if (L.IsNull()) continue;
TCollection_ExtendedString str = convertName (name->String());
TDataStd_Name::Set(L, str);
@@ -1352,8 +1349,7 @@ static TDF_Label GetLabelFromPD(const Handle(StepBasic_ProductDefinition) &PD,
Standard_Boolean STEPCAFControl_Reader::ReadValProps(const Handle(XSControl_WorkSession) &WS,
Handle(TDocStd_Document)& Doc,
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap) const
{
// get starting data
const Handle(XSControl_TransferReader) &TR = WS->TransferReader();
@@ -1393,7 +1389,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadValProps(const Handle(XSControl_Work
NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs1.Value());
}
if (!NAUO.IsNull()) {
L = FindInstance(NAUO, STool, WS, ShapeLabelMap);
L = FindInstance(NAUO, STool, WS, myMap);
if (L.IsNull()) continue;
}
else {
@@ -1405,7 +1401,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadValProps(const Handle(XSControl_Work
ProdDef = Handle(StepBasic_ProductDefinition)::DownCast(subsPDS.Value());
}
if (ProdDef.IsNull()) continue;
L = GetLabelFromPD(ProdDef, STool, Props, PDFileMap, ShapeLabelMap);
L = GetLabelFromPD(ProdDef, STool, Props, PDFileMap, myMap);
}
}
@@ -1450,8 +1446,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadValProps(const Handle(XSControl_Work
TopoDS_Shape S;
S = TransferBRep::ShapeResult(TP, binder);
if (S.IsNull()) continue;
if (ShapeLabelMap.IsBound(S))
L = ShapeLabelMap.Find(S);
if (myMap.IsBound(S))
L = myMap.Find(S);
if (L.IsNull())
STool->Search(S, L, Standard_True, Standard_True, Standard_True);
}
@@ -1656,8 +1652,7 @@ static TDF_Label setSHUOintoDoc(const Handle(XSControl_WorkSession) &WS,
Standard_Boolean STEPCAFControl_Reader::ReadSHUOs(const Handle(XSControl_WorkSession) &WS,
Handle(TDocStd_Document)& Doc,
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap,
const XCAFDoc_DataMapOfShapeLabel &ShapeLabelMap) const
const STEPCAFControl_DataMapOfPDExternFile &PDFileMap) const
{
// the big part code duplication from ReadColors.
// It is possible to share this code functionality, just to decide how ???
@@ -1724,7 +1719,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadSHUOs(const Handle(XSControl_WorkSes
continue;
// set the SHUO structure to the document
TDF_Label aLabelForStyle = setSHUOintoDoc(WS, SHUO, STool, PDFileMap, ShapeLabelMap);
TDF_Label aLabelForStyle = setSHUOintoDoc(WS, SHUO, STool, PDFileMap, myMap);
if (aLabelForStyle.IsNull()) {
#ifdef OCCT_DEBUG
std::cout << "Warning: " << __FILE__ << ": coudnot create SHUO structure in the document" << std::endl;
@@ -4560,7 +4555,6 @@ void collectRepresentationItems(const Interface_Graph& theGraph,
//=======================================================================
void STEPCAFControl_Reader::ExpandSubShapes(const Handle(XCAFDoc_ShapeTool)& ShapeTool,
const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap,
const STEPCAFControl_DataMapOfShapePD& ShapePDMap) const
{
const Handle(Transfer_TransientProcess)& TP = Reader().WS()->TransferReader()->TransientProcess();
@@ -4610,10 +4604,10 @@ void STEPCAFControl_Reader::ExpandSubShapes(const Handle(XCAFDoc_ShapeTool)& Sha
if (aReprItems.Length() == 0)
continue;
if (!ShapeLabelMap.IsBound(aRootShape))
if (!myMap.IsBound(aRootShape))
continue;
TDF_Label aRootLab = ShapeLabelMap.Find(aRootShape);
TDF_Label aRootLab = myMap.Find(aRootShape);
// Do not add subshapes to assembly,
// they will be processed with corresponding Shape_Product_Definition of necessary part.
if (ShapeTool->IsAssembly(aRootLab))

View File

@@ -172,8 +172,7 @@ public:
//! Get View mode
Standard_EXPORT Standard_Boolean GetViewMode() const;
const XCAFDoc_DataMapOfShapeLabel& GetShapeLabelMap() const { return myMap; }
protected:
@@ -195,7 +194,7 @@ protected:
//! Depending on a case, this shape can be added as one, or
//! as assembly, or (in case if it is associated with external
//! reference) taken as that referred shape
Standard_EXPORT TDF_Label AddShape (const TopoDS_Shape& S, const Handle(XCAFDoc_ShapeTool)& STool, const TopTools_MapOfShape& NewShapesMap, const STEPCAFControl_DataMapOfShapePD& ShapePDMap, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap, XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap) const;
Standard_EXPORT TDF_Label AddShape (const TopoDS_Shape& S, const Handle(XCAFDoc_ShapeTool)& STool, const TopTools_MapOfShape& NewShapesMap, const STEPCAFControl_DataMapOfShapePD& ShapePDMap, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap);
//! Reads (or if returns already read) extern file with
//! given name
@@ -208,17 +207,16 @@ protected:
//! corresponding color assignments in the DECAF document
Standard_EXPORT Standard_Boolean ReadColors
(const Handle(XSControl_WorkSession)& WS,
Handle(TDocStd_Document)& doc,
const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap) const;
Handle(TDocStd_Document)& doc) const;
//! Reads names of parts defined in the STEP model and
//! assigns them to corresponding labels in the DECAF document
Standard_EXPORT Standard_Boolean ReadNames (const Handle(XSControl_WorkSession)& WS, Handle(TDocStd_Document)& doc, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap, const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap) const;
Standard_EXPORT Standard_Boolean ReadNames (const Handle(XSControl_WorkSession)& WS, Handle(TDocStd_Document)& doc, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap) const;
//! Reads validation properties assigned to shapes in the STEP
//! model and assigns them to corresponding labels in the DECAF
//! document
Standard_EXPORT Standard_Boolean ReadValProps (const Handle(XSControl_WorkSession)& WS, Handle(TDocStd_Document)& doc, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap, const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap) const;
Standard_EXPORT Standard_Boolean ReadValProps (const Handle(XSControl_WorkSession)& WS, Handle(TDocStd_Document)& doc, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap) const;
//! Reads layers of parts defined in the STEP model and
//! set reference between shape and layers in the DECAF document
@@ -226,7 +224,7 @@ protected:
//! Reads SHUO for instances defined in the STEP model and
//! set reference between shape instances from different assemblyes
Standard_EXPORT Standard_Boolean ReadSHUOs (const Handle(XSControl_WorkSession)& WS, Handle(TDocStd_Document)& doc, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap, const XCAFDoc_DataMapOfShapeLabel& ShapeLabelMap) const;
Standard_EXPORT Standard_Boolean ReadSHUOs (const Handle(XSControl_WorkSession)& WS, Handle(TDocStd_Document)& doc, const STEPCAFControl_DataMapOfPDExternFile& PDFileMap) const;
//! Reads D&GT for instances defined in the STEP model and
//! set reference between shape instances from different assemblyes
@@ -248,7 +246,7 @@ protected:
//! expands their correspondent Labels in XDE Document so that
//! to have a dedicated sub-Label for each sub-shape coming
//! with associated name in its STEP Representation Item.
Standard_EXPORT void ExpandSubShapes (const Handle(XCAFDoc_ShapeTool)& theShapeTool, const XCAFDoc_DataMapOfShapeLabel& theShapeLabelMap, const STEPCAFControl_DataMapOfShapePD& theShapePDMap) const;
Standard_EXPORT void ExpandSubShapes (const Handle(XCAFDoc_ShapeTool)& theShapeTool, const STEPCAFControl_DataMapOfShapePD& theShapePDMap) const;
//! Expands the topological structure of Manifold Solid BRep
//! STEP entity to OCAF sub-tree. Entities having no names
@@ -299,6 +297,7 @@ private:
STEPControl_Reader myReader;
NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> myFiles;
XCAFDoc_DataMapOfShapeLabel myMap;
Standard_Boolean myColorMode;
Standard_Boolean myNameMode;
Standard_Boolean myLayerMode;