1 // Created on: 2000-01-11
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <StepBasic_ProductDefinition.hxx>
18 #include <StepBasic_ProductDefinitionRelationship.hxx>
19 #include <STEPConstruct.hxx>
20 #include <StepRepr_ProductDefinitionShape.hxx>
21 #include <StepRepr_PropertyDefinition.hxx>
22 #include <StepRepr_RepresentationItem.hxx>
23 #include <StepShape_ContextDependentShapeRepresentation.hxx>
24 #include <StepShape_ShapeDefinitionRepresentation.hxx>
25 #include <TopLoc_Location.hxx>
26 #include <TopoDS_Shape.hxx>
27 #include <Transfer_Binder.hxx>
28 #include <Transfer_FinderProcess.hxx>
29 #include <Transfer_SimpleBinderOfTransient.hxx>
30 #include <Transfer_TransientProcess.hxx>
31 #include <TransferBRep.hxx>
32 #include <TransferBRep_ShapeMapper.hxx>
34 //=======================================================================
35 //function : FindEntity
37 //=======================================================================
38 Handle(StepRepr_RepresentationItem) STEPConstruct::FindEntity (const Handle(Transfer_FinderProcess) &FinderProcess,
39 const TopoDS_Shape &Shape)
41 Handle(StepRepr_RepresentationItem) item;
42 Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess, Shape );
43 FinderProcess->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_RepresentationItem), item);
45 if ( item.IsNull() ) cout << Shape.TShape()->DynamicType()->Name() << ": RepItem not found" << endl;
46 else cout << Shape.TShape()->DynamicType()->Name() << ": RepItem found: " << item->DynamicType()->Name() << endl;
51 //=======================================================================
52 //function : FindEntity
54 //=======================================================================
56 Handle(StepRepr_RepresentationItem) STEPConstruct::FindEntity (const Handle(Transfer_FinderProcess) &FinderProcess,
57 const TopoDS_Shape &Shape,
60 Handle(StepRepr_RepresentationItem) item;
61 Loc = Shape.Location();
62 Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FinderProcess, Shape );
63 if ( ! FinderProcess->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_RepresentationItem), item) &&
64 ! Loc.IsIdentity() ) {
66 TopoDS_Shape S = Shape;
68 mapper = TransferBRep::ShapeMapper ( FinderProcess, S );
69 FinderProcess->FindTypedTransient (mapper,STANDARD_TYPE(StepRepr_RepresentationItem), item);
72 if ( item.IsNull() ) cout << Shape.TShape()->DynamicType()->Name() << ": RepItem not found" << endl;
73 else if ( Loc != Shape.Location() ) cout << Shape.TShape()->DynamicType()->Name() << ": RepItem found for shape without location: " << item->DynamicType()->Name() << endl;
74 else cout << Shape.TShape()->DynamicType()->Name() << ": RepItem found: " << item->DynamicType()->Name() << endl;
79 //=======================================================================
80 //function : FindShape
82 //=======================================================================
84 TopoDS_Shape STEPConstruct::FindShape (const Handle(Transfer_TransientProcess) &TransientProcess,
85 const Handle(StepRepr_RepresentationItem) &item)
88 Handle(Transfer_Binder) binder = TransientProcess->Find(item);
89 if ( ! binder.IsNull() && binder->HasResult() ) {
90 S = TransferBRep::ShapeResult ( TransientProcess, binder );
95 //=======================================================================
98 //=======================================================================
100 Standard_Boolean STEPConstruct::FindCDSR
101 (const Handle(Transfer_Binder)& ComponentBinder,
102 const Handle(StepShape_ShapeDefinitionRepresentation)& AssemblySDR,
103 Handle(StepShape_ContextDependentShapeRepresentation)& ComponentCDSR)
105 Standard_Boolean result = Standard_False;
107 Handle(StepRepr_PropertyDefinition) PropD = AssemblySDR->Definition().PropertyDefinition();
108 if (!PropD.IsNull()) {
109 Handle(StepBasic_ProductDefinition) AssemblyPD = PropD->Definition().ProductDefinition();
110 if (!AssemblyPD.IsNull()) {
111 Handle(Transfer_Binder) binder = ComponentBinder;
112 Handle(Transfer_SimpleBinderOfTransient) trb;
113 Handle(StepRepr_ProductDefinitionShape) PDS;
114 Handle(StepBasic_ProductDefinitionRelationship) NAUO;
115 Handle(StepBasic_ProductDefinition) ComponentPD;
116 while (!binder.IsNull() && !result) {
117 trb = Handle(Transfer_SimpleBinderOfTransient)::DownCast(binder);
119 ComponentCDSR = Handle(StepShape_ContextDependentShapeRepresentation)::DownCast(trb->Result());
120 if (!ComponentCDSR.IsNull()) {
121 PDS = ComponentCDSR->RepresentedProductRelation();
123 NAUO = PDS->Definition().ProductDefinitionRelationship();
124 if (!NAUO.IsNull()) {
125 ComponentPD = NAUO->RelatingProductDefinition();
126 result = (ComponentPD == AssemblyPD);
131 binder = binder->NextResult();