1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0027975: Data Exchange - Add possibility to connect DGTs to vertices.

Implement new function to find Product_Definition_Shape entity.
Modify Reader to add possibility of import DGTs, connected to some geometry items.
Update test cases.
This commit is contained in:
ika 2016-10-18 13:24:29 +03:00 committed by apn
parent 4d19a2c5e7
commit 43d3f6d8d8
9 changed files with 86 additions and 29 deletions

View File

@ -2224,6 +2224,31 @@ static Standard_Boolean ReadDatums(const Handle(XCAFDoc_ShapeTool) &STool,
return Standard_True;
}
//=======================================================================
//function : FindShapeIndexForDGT
//purpose : auxiliary find shape index in map og imported shapes
//=======================================================================
static Standard_Integer FindShapeIndexForDGT(const Handle(Standard_Transient)& theEnt,
const Handle(XSControl_WorkSession)& theWS)
{
const Handle(Transfer_TransientProcess) &aTP = theWS->TransferReader()->TransientProcess();
// try to find index of given entity
Standard_Integer anIndex = aTP->MapIndex(theEnt);
if (anIndex > 0)
return anIndex;
// if theEnt is a geometry item try to find its topological item
const Interface_Graph& aGraph = aTP->Graph();
Interface_EntityIterator anIter = aGraph.Sharings(theEnt);
for (anIter.Start(); anIter.More(); anIter.Next()) {
if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)))
{
anIndex = aTP->MapIndex(anIter.Value());
if (anIndex > 0)
return anIndex;
}
}
return 0;
}
//=======================================================================
//function : setDatumToXCAF
@ -2306,7 +2331,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
aRI = aPGISU->IdentifiedItemValue(i);
}
if(aRI.IsNull()) continue;
Standard_Integer index = aTP->MapIndex(aRI);
Standard_Integer index = FindShapeIndexForDGT(aRI, theWS);
TopoDS_Shape aSh;
if(index >0) {
Handle(Transfer_Binder) binder = aTP->MapItem(index);
@ -2362,7 +2387,7 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
anItem = aPGISU->IdentifiedItemValue(1);
}
if(anItem.IsNull()) continue;
Standard_Integer anItemIndex = aTP->MapIndex(anItem);
Standard_Integer anItemIndex = FindShapeIndexForDGT(anItem, theWS);
if(anItemIndex >0) {
Handle(Transfer_Binder) binder = aTP->MapItem(anItemIndex);
TopoDS_Shape anItemShape = TransferBRep::ShapeResult(binder);
@ -2658,6 +2683,7 @@ static void collectShapeAspect(const Handle(StepRepr_ShapeAspect)& theSA,
}
}
//=======================================================================
//function : createGeomTolObjectInXCAF
//purpose :
@ -2991,7 +3017,7 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
// Collect shapes
for(Standard_Integer i = aSeqRI1.Lower(); i <= aSeqRI1.Upper() ;i++)
{
Standard_Integer anIndex = aTP->MapIndex(aSeqRI1.Value(i));
Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI1.Value(i), theWS);
TopoDS_Shape aSh;
if(anIndex >0) {
Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
@ -3009,7 +3035,7 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
//for dimensional location
for(Standard_Integer i = aSeqRI2.Lower(); i <= aSeqRI2.Upper() ;i++)
{
Standard_Integer anIndex = aTP->MapIndex(aSeqRI2.Value(i));
Standard_Integer anIndex = FindShapeIndexForDGT(aSeqRI2.Value(i), theWS);
TopoDS_Shape aSh;
if(anIndex >0) {
Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
@ -3412,7 +3438,7 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
for(anIterGRI.Start(); anIterGRI.More() && aPGISU.IsNull(); anIterGRI.Next()) {
aPRI = Handle(StepRepr_RepresentationItem)::DownCast(anIterGRI.Value());
}
Standard_Integer anIndex = aTP->MapIndex(aPRI);
Standard_Integer anIndex = FindShapeIndexForDGT(aPRI, theWS);
TopoDS_Edge aSh;
if(anIndex >0) {
Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);

View File

@ -2112,11 +2112,56 @@ static Standard_Boolean FindPDSforDGT(const Interface_Graph &aGraph,
return Standard_True;
}
//=======================================================================
//function : FindPDS
//purpose : auxilary: find Product_definition_shape entity for given entity
//=======================================================================
static Handle(StepRepr_ProductDefinitionShape) FindPDS(const Interface_Graph &theGraph,
const Handle(Standard_Transient) &theEnt,
Handle(StepRepr_RepresentationContext) &theRC)
{
if (theEnt.IsNull())
return NULL;
Handle(StepRepr_ProductDefinitionShape) aPDS;
// try to find shape_representation in sharings
Interface_EntityIterator anIter = theGraph.Sharings(theEnt);
for (anIter.Start(); anIter.More() && aPDS.IsNull(); anIter.Next()) {
Handle(StepShape_ShapeRepresentation) aSR = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value());
if (aSR.IsNull())
continue;
theRC = aSR->ContextOfItems();
Interface_EntityIterator aSDRIt = theGraph.Sharings(aSR);
for (aSDRIt.Start(); aSDRIt.More() && aPDS.IsNull(); aSDRIt.Next()) {
Handle(StepShape_ShapeDefinitionRepresentation) aSDR =
Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value());
if (aSDR.IsNull()) continue;
Handle(StepRepr_PropertyDefinition) aPropD = aSDR->Definition().PropertyDefinition();
if (aPropD.IsNull()) continue;
aPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aPropD);
}
}
if (!aPDS.IsNull())
return aPDS;
anIter = theGraph.Sharings(theEnt);
for (anIter.Start(); anIter.More(); anIter.Next()) {
if (anIter.Value()->IsKind(STANDARD_TYPE(StepShape_TopologicalRepresentationItem)) ||
anIter.Value()->IsKind(STANDARD_TYPE(StepGeom_GeometricRepresentationItem)))
{
aPDS = FindPDS(theGraph, anIter.Value(), theRC);
if (!aPDS.IsNull())
return aPDS;
}
}
return aPDS;
}
//=======================================================================
//function : GetUnit
//purpose : auxiliary
//=======================================================================
static StepBasic_Unit GetUnit(const Handle(StepRepr_RepresentationContext)& theRC,
const Standard_Boolean isAngle = Standard_False)
{
@ -2264,9 +2309,7 @@ static Handle(StepRepr_ShapeAspect) WriteShapeAspect (const Handle(XSControl_Wor
Handle(StepRepr_ProductDefinitionShape) aPDS;
Handle(StepRepr_RepresentationContext) aRC;
Handle(Standard_Transient) anEnt = aSeqRI.Value(1);
Handle(StepShape_AdvancedFace) anAF;
Handle(StepShape_EdgeCurve) anEC;
FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC);
aPDS = FindPDS(aGraph, anEnt, aRC);
if(aPDS.IsNull())
return NULL;
@ -2335,7 +2378,8 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
Handle(StepVisual_HArray1OfDraughtingCalloutElement) aTAOs = new StepVisual_HArray1OfDraughtingCalloutElement(1, 1);
aTAOs->SetValue(1, aDCElement);
Handle(StepVisual_DraughtingCallout) aDCallout = new StepVisual_DraughtingCallout();
aDCallout->Init(thePrsName, aTAOs);
Handle(TCollection_HAsciiString) aPrsName = thePrsName.IsNull() ? new TCollection_HAsciiString() : thePrsName;
aDCallout->Init(aPrsName, aTAOs);
Handle(StepRepr_HArray1OfRepresentationItem) aDCsForDMIA = new StepRepr_HArray1OfRepresentationItem(1, 1);
aDCsForDMIA->SetValue(1, aDCallout);
StepAP242_ItemIdentifiedRepresentationUsageDefinition aDimension;
@ -2405,7 +2449,8 @@ static void WritePresentation(const Handle(XSControl_WorkSession) &WS,
Handle(StepVisual_HArray1OfDraughtingCalloutElement) aTAOs = new StepVisual_HArray1OfDraughtingCalloutElement(1, 1);
aTAOs->SetValue(1, aDCElement);
Handle(StepVisual_DraughtingCallout) aDCallout = new StepVisual_DraughtingCallout();
aDCallout->Init(thePrsName, aTAOs);
Handle(TCollection_HAsciiString) aPrsName = thePrsName.IsNull() ? new TCollection_HAsciiString() : thePrsName;
aDCallout->Init(aPrsName, aTAOs);
aModel->AddWithRefs(aDCallout);
// Annotation plane
@ -2464,8 +2509,6 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
Handle(StepRepr_ProductDefinitionShape) aPDS;
Handle(StepRepr_RepresentationContext) aRC;
Handle(Standard_Transient) anEnt;
Handle(StepShape_AdvancedFace) anAF;
Handle(StepShape_EdgeCurve) anEC;
TopoDS_Shape aShape;
TopLoc_Location aLoc;
TColStd_SequenceOfTransient aSeqRI;
@ -2477,7 +2520,7 @@ static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSessi
return NULL;
}
anEnt = aSeqRI.Value(1);
FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC);
aPDS = FindPDS(aGraph, anEnt, aRC);
if (aPDS.IsNull())
return NULL;

View File

@ -1,6 +1,6 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27645_nist_ftc_06_asme1_cr3000_rd.prt.stp
puts "TODO CR26859 ALL:Error : 3 differences with reference data found :"
puts "TODO CR26859 ALL:Error : 1 differences with reference data found :"
puts "TODO CR26859 ALL:Error on writing file"
set ref_data {

View File

@ -1,7 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27808_nist_ftc_06_asme1_ct5240_rd.stp
puts "TODO CR26859 ALL:Error : 3 differences with reference data found :"
puts "TODO CR26859 ALL:Error on writing file"
set ref_data {

View File

@ -1,7 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27645_nist_ftc_06_asme1_ct5240_rd-1.stp
puts "TODO CR26859 ALL:Error : 3 differences with reference data found :"
puts "TODO CR26859 ALL:Error on writing file"
set ref_data {

View File

@ -1,7 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27808_nist_ftc_09_asme1_ct5240_rd.stp
puts "TODO CR26859 ALL:Error : 2 differences with reference data found :"
puts "TODO CR26859 ALL:Error on writing file"
set ref_data {

View File

@ -1,10 +1,8 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27808_nist_ftc_06_asme1_ct5240_rd.stp
puts "TODO CR27235 ALL:Error : 4 differences with reference data found :"
puts "TODO CR27235 ALL:Error on writing file"
set ref_data {
Centre of mass: 4.9764239505863603 64.18438466729144 -67.058903377273126
Mass: 24387.315415267363
Centre of mass: 4.9764105227425732 64.184386470151395 -67.058886121406474
Mass: 24387.315219228582
}

View File

@ -1,7 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27645_nist_ftc_06_asme1_ct5240_rd-1.stp
puts "TODO CR27235 ALL:Error : 4 differences with reference data found :"
puts "TODO CR27235 ALL:Error on writing file"
set ref_data {
Centre of mass: 126.40116834489778 1630.2833705491985 -1703.2961457827012

View File

@ -1,7 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug27808_nist_ftc_09_asme1_ct5240_rd.stp
puts "TODO CR27235 ALL:Error : 4 differences with reference data found :"
puts "TODO CR27235 ALL:Error on writing file"
set ref_data {
Centre of mass: -20.281360550123736 7.5575111121398644 -1.4132597243023584