1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
-- File: StepSelect.cdl
-- Created: Thu Dec 22 11:03:12 1994
-- Author: Christian CAILLET
-- <cky@anion>
---Copyright: Matra Datavision 1994
package STEPSelections
---Purpose : Step Selections
uses
MMgt,
TCollection,
TColStd,
Interface,
IFGraph,
IFSelect,
StepSelect,
StepBasic,
StepShape,
StepGeom,
StepRepr,
StepData,
XSControl
is
class SelectFaces;
class SelectDerived;
class SelectGSCurves;
class SelectAssembly;
class SelectInstances;
class SelectForTransfer;
-- Classes that are intended for assembly exploration
class SequenceOfAssemblyLink instantiates
Sequence from TCollection (AssemblyLink from STEPSelections);
class HSequenceOfAssemblyLink instantiates
HSequence from TCollection (AssemblyLink from STEPSelections,
SequenceOfAssemblyLink from STEPSelections);
class SequenceOfAssemblyComponent instantiates
Sequence from TCollection (AssemblyComponent from STEPSelections);
class AssemblyComponent;
class AssemblyLink;
class AssemblyExplorer;
class Counter;
end STEPSelections;

View File

@@ -0,0 +1,48 @@
-- File: STEPSelections_AssemblyComponent.cdl
-- Created: Wed Mar 24 14:14:23 1999
-- Author: data exchange team
-- <det@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class AssemblyComponent from STEPSelections inherits TShared from MMgt
---Purpose:
uses
ShapeDefinitionRepresentation from StepShape,
HSequenceOfAssemblyLink from STEPSelections
is
Create returns mutable AssemblyComponent from STEPSelections;
Create (sdr : ShapeDefinitionRepresentation from StepShape;
list: HSequenceOfAssemblyLink from STEPSelections)
returns mutable AssemblyComponent from STEPSelections;
--Methods for getting and obtaining fields
GetSDR(me) returns ShapeDefinitionRepresentation from StepShape;
---Purpose:
---C++: inline
GetList(me) returns HSequenceOfAssemblyLink from STEPSelections;
---Purpose:
---C++: inline
SetSDR(me : mutable; sdr: ShapeDefinitionRepresentation from StepShape);
---Purpose:
---C++: inline
SetList(me : mutable; list: HSequenceOfAssemblyLink from STEPSelections);
---Purpose:
---C++: inline
fields
mySDR : ShapeDefinitionRepresentation from StepShape;
myList: HSequenceOfAssemblyLink from STEPSelections;
end AssemblyComponent;

View File

@@ -0,0 +1,18 @@
// File: STEPSelections_AssemblyComponent.cxx
// Created: Wed Mar 24 16:03:32 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_AssemblyComponent.ixx>
STEPSelections_AssemblyComponent::STEPSelections_AssemblyComponent()
{
}
STEPSelections_AssemblyComponent::STEPSelections_AssemblyComponent(const Handle(StepShape_ShapeDefinitionRepresentation)& sdr,
const Handle(STEPSelections_HSequenceOfAssemblyLink)& list)
{
mySDR = sdr;
myList = list;
}

View File

@@ -0,0 +1,39 @@
// File: STEPSelections_AssemblyComponent.lxx
// Created: Wed Mar 24 15:52:38 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
//=======================================================================
//function : GetSDR
//purpose :
//=======================================================================
inline Handle(StepShape_ShapeDefinitionRepresentation) STEPSelections_AssemblyComponent::GetSDR() const
{
return mySDR;
}
//=======================================================================
//function : GetList
//purpose :
//=======================================================================
inline Handle(STEPSelections_HSequenceOfAssemblyLink) STEPSelections_AssemblyComponent::GetList() const
{
return myList;
}
//=======================================================================
//function : SetSDR
//purpose :
//=======================================================================
inline void STEPSelections_AssemblyComponent::SetSDR(const Handle(StepShape_ShapeDefinitionRepresentation)& sdr)
{
mySDR = sdr;
}
inline void STEPSelections_AssemblyComponent::SetList(const Handle(STEPSelections_HSequenceOfAssemblyLink)& list)
{
myList = list;
}

View File

@@ -0,0 +1,55 @@
-- File: STEPSelections_AssemblyExplorer.cdl
-- Created: Wed Mar 24 15:12:12 1999
-- Author: data exchange team
-- <det@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class AssemblyExplorer from STEPSelections
---Purpose:
uses
Graph from Interface,
SequenceOfAssemblyComponent from STEPSelections,
IndexedDataMapOfTransientTransient from TColStd,
ProductDefinition from StepBasic,
ShapeDefinitionRepresentation from StepShape,
AssemblyComponent from STEPSelections,
NextAssemblyUsageOccurrence from StepRepr
is
Create (G: Graph) returns AssemblyExplorer from STEPSelections;
Init(me: in out; G: Graph);
Dump(me; os: in out OStream from Standard);
FindSDRWithProduct(me; product: ProductDefinition from StepBasic)
returns ShapeDefinitionRepresentation from StepShape;
FillListWithGraph(me: in out; cmp: AssemblyComponent from STEPSelections);
FindItemWithNAUO(me; nauo: NextAssemblyUsageOccurrence from StepRepr)
returns Transient from Standard;
--Methods for fetching the results
NbAssemblies(me) returns Integer;
---Purpose: Returns the number of root assemblies;
---C++: inline
Root(me; rank: Integer = 1) returns AssemblyComponent from STEPSelections;
---Purpose: Returns root of assenbly by its rank;
---C++: inline
fields
myRoots: SequenceOfAssemblyComponent from STEPSelections;
myGraph: Graph from Interface;
myMap : IndexedDataMapOfTransientTransient from TColStd;
end AssemblyExplorer;

View File

@@ -0,0 +1,175 @@
// File: STEPSelections_AssemblyExplorer.cxx
// Created: Wed Mar 24 16:24:41 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_AssemblyExplorer.ixx>
#include <Interface_Macros.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <Interface_EntityIterator.hxx>
#include <StepShape_ContextDependentShapeRepresentation.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepRepr_MappedItem.hxx>
#include <STEPSelections_AssemblyLink.hxx>
#include <STEPSelections_HSequenceOfAssemblyLink.hxx>
#include <StepBasic_Product.hxx>
#include <StepBasic_ProductDefinitionFormation.hxx>
#include <Interface_InterfaceModel.hxx>
#include <TCollection_HAsciiString.hxx>
STEPSelections_AssemblyExplorer::STEPSelections_AssemblyExplorer(const Interface_Graph &G):myGraph(G)
{
Init(G);
}
Handle(Standard_Transient) STEPSelections_AssemblyExplorer::
FindItemWithNAUO(const Handle(StepRepr_NextAssemblyUsageOccurrence)& nauo) const
{
Handle(Standard_Transient) item;
Handle(StepRepr_ProductDefinitionShape) pds;
Interface_EntityIterator subs = myGraph.Sharings(nauo);
for(subs.Start(); subs.More()&&pds.IsNull(); subs.Next())
if(subs.Value()->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)))
pds = Handle(StepRepr_ProductDefinitionShape)::DownCast(subs.Value());
if(pds.IsNull()) return item;
subs = myGraph.Sharings(pds);
Handle(StepShape_ContextDependentShapeRepresentation) cdsr;
Handle(StepShape_ShapeDefinitionRepresentation) shdefrep;
Handle(Standard_Transient) itmp;
for(subs.Start(); subs.More()&&shdefrep.IsNull(); subs.Next()) {
itmp = subs.Value();
if(itmp->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation)))
return itmp;
if(itmp->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
shdefrep = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(itmp);
}
if(shdefrep.IsNull()) return shdefrep ;
Handle(StepShape_ShapeRepresentation) srep = Handle(StepShape_ShapeRepresentation)::DownCast(shdefrep->UsedRepresentation());
if(srep.IsNull()) return srep;
for(Standard_Integer i = 1; i <= srep->NbItems(); i++) {
Handle(StepRepr_RepresentationItem) repitem = srep->ItemsValue(i);
if(repitem->IsKind(STANDARD_TYPE(StepRepr_MappedItem)))
return repitem;
}
return item;
}
Handle(StepShape_ShapeDefinitionRepresentation) STEPSelections_AssemblyExplorer::
FindSDRWithProduct(const Handle(StepBasic_ProductDefinition)& product) const
{
Interface_EntityIterator subs = myGraph.Sharings(product);
for(subs.Start(); subs.More(); subs.Next())
if(subs.Value()->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition))) {
Interface_EntityIterator subs1 = myGraph.Sharings(subs.Value());
for(subs1.Start(); subs1.More(); subs1.Next())
if(subs1.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
DeclareAndCast(StepShape_ShapeDefinitionRepresentation,SDR,subs1.Value());
return SDR;
}
}
Handle(StepShape_ShapeDefinitionRepresentation) sdr;
return sdr;
}
void STEPSelections_AssemblyExplorer::FillListWithGraph(const Handle(STEPSelections_AssemblyComponent)& cmp)
{
Handle(StepShape_ShapeDefinitionRepresentation) SDR = cmp->GetSDR();
Handle(STEPSelections_HSequenceOfAssemblyLink) list = cmp->GetList();
Handle(StepRepr_ProductDefinitionShape) pdsh =
Handle(StepRepr_ProductDefinitionShape)::DownCast ( SDR->Definition().PropertyDefinition() );
if(pdsh.IsNull()) return;
Handle(StepBasic_ProductDefinition) pdf = pdsh->Definition().ProductDefinition();
if(pdf.IsNull()) return;
Interface_EntityIterator subs = myGraph.Sharings(pdf);
for(subs.Start(); subs.More(); subs.Next())
if(subs.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) {
DeclareAndCast(StepRepr_NextAssemblyUsageOccurrence,nauo,subs.Value());
if(pdf==nauo->RelatingProductDefinition()) {
Handle(STEPSelections_AssemblyLink) link = new STEPSelections_AssemblyLink;
link->SetNAUO(nauo);
link->SetItem(FindItemWithNAUO(nauo));
Handle(StepBasic_ProductDefinition) pdrComponent = nauo->RelatedProductDefinition();
if(pdrComponent.IsNull()) continue;
Handle(StepShape_ShapeDefinitionRepresentation) subSDR = FindSDRWithProduct(pdrComponent);
if(subSDR.IsNull()) continue;
Standard_Integer index = myMap.FindIndex(subSDR);
if(index)
link->SetComponent(Handle(STEPSelections_AssemblyComponent)::DownCast(myMap.FindFromIndex(index)));
else {
Handle(STEPSelections_HSequenceOfAssemblyLink) sublist = new STEPSelections_HSequenceOfAssemblyLink;
Handle(STEPSelections_AssemblyComponent) subCmp = new STEPSelections_AssemblyComponent(subSDR,sublist);
FillListWithGraph(subCmp);
link->SetComponent(subCmp);
myMap.Add(subSDR,subCmp);
}
list->Append(link);
}
}
}
void STEPSelections_AssemblyExplorer::Init(const Interface_Graph &G)
{
myGraph = G;
myRoots.Clear();
myMap.Clear();
Interface_EntityIterator roots = myGraph.RootEntities();
for(roots.Start(); roots.More(); roots.Next())
if(roots.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
Handle(STEPSelections_AssemblyComponent) cmp = new STEPSelections_AssemblyComponent;
cmp->SetSDR(Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(roots.Value()));
cmp->SetList(new STEPSelections_HSequenceOfAssemblyLink);
FillListWithGraph(cmp);
myRoots.Append(cmp);
}
}
static Standard_CString GetProductName(const Handle(StepShape_ShapeDefinitionRepresentation) &SDR)
{
Standard_CString str = "";
Handle(StepBasic_Product) empty;
Handle(StepRepr_PropertyDefinition) PropDf = SDR->Definition().PropertyDefinition();
if ( PropDf.IsNull() ) return str;
Handle(StepBasic_ProductDefinition) PD = PropDf->Definition().ProductDefinition();
if ( PD.IsNull() ) return str;
Handle(StepBasic_ProductDefinitionFormation) PDF = PD->Formation();
if ( PDF.IsNull() ) return str;
return PDF->OfProduct()->Name()->ToCString();
}
static void PrintSubAssembly(Standard_OStream &os,
const Handle(STEPSelections_AssemblyComponent)& cmp,
const Handle(Interface_InterfaceModel) &Model,
Standard_Integer level)
{
//for ( Standard_Integer j=0; j < level; j++ ) os << "\t";
os << "SDR: " <<Model->StringLabel(cmp->GetSDR())->ToCString()<<"\t";
os << "Product: "<<GetProductName(cmp->GetSDR())<<endl;
for ( Standard_Integer i = 1; i <= cmp->GetList()->Length(); i++) {
for ( Standard_Integer j=0; j < level+1; j++ ) os << "\t";
os << "NAUO :"<<Model->StringLabel(cmp->GetList()->Value(i)->GetNAUO())->ToCString()<<";\t";
if(cmp->GetList()->Value(i)->GetItem()->IsKind(STANDARD_TYPE(StepRepr_MappedItem)))
os <<"MI ";
else
if(cmp->GetList()->Value(i)->GetItem()->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation)))
os <<"CDSR ";
else
os <<"UNKNOWN LINK!!!";
PrintSubAssembly(os,cmp->GetList()->Value(i)->GetComponent(),Model,level+1);
}
}
void STEPSelections_AssemblyExplorer::Dump(Standard_OStream &os) const
{
Handle(Interface_InterfaceModel) model = myGraph.Model();
for(Standard_Integer i = 1 ; i <=myRoots.Length(); i++) {
os<<"Assembly N: "<<i<<endl<<endl;
PrintSubAssembly(os,myRoots.Value(i),model,0);
}
}

View File

@@ -0,0 +1,24 @@
// File: STEPSelections_AssemblyExplorer.lxx
// Created: Fri Mar 26 16:03:53 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
//=======================================================================
//function : NbAssemblies
//purpose :
//=======================================================================
inline Standard_Integer STEPSelections_AssemblyExplorer::NbAssemblies() const
{
return myRoots.Length();
}
//=======================================================================
//function : Root
//purpose :
//=======================================================================
inline Handle(STEPSelections_AssemblyComponent) STEPSelections_AssemblyExplorer::Root(const Standard_Integer rank) const
{
return myRoots.Value(rank);
}

View File

@@ -0,0 +1,59 @@
-- File: STEPSelections_AssemblyLink.cdl
-- Created: Wed Mar 24 12:40:23 1999
-- Author: data exchange team
-- <det@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class AssemblyLink from STEPSelections inherits TShared from MMgt
---Purpose:
uses
NextAssemblyUsageOccurrence from StepRepr,
ContextDependentShapeRepresentation from StepShape,
AssemblyComponent from STEPSelections
is
Create returns mutable AssemblyLink from STEPSelections;
Create(nauo: NextAssemblyUsageOccurrence from StepRepr;
item: Transient from Standard;
part: AssemblyComponent from STEPSelections)
returns mutable AssemblyLink from STEPSelections;
--Methods for setting and obtaining fields
GetNAUO(me) returns NextAssemblyUsageOccurrence from StepRepr;
---Purpose:
---C++: inline
GetItem(me) returns Transient from Standard;
---Purpose:
---C++: inline
GetComponent(me) returns AssemblyComponent from STEPSelections;
---Purpose:
---C++: inline
SetNAUO(me: mutable; nauo: NextAssemblyUsageOccurrence from StepRepr);
---Purpose:
---C++: inline
SetItem(me: mutable; item: Transient from Standard);
---Purpose:
---C++: inline
SetComponent(me: mutable; part: AssemblyComponent from STEPSelections);
---Purpose:
---C++: inline
fields
myNAUO : NextAssemblyUsageOccurrence from StepRepr;
myItem : Transient from Standard;
myComponent: AssemblyComponent from STEPSelections;
end AssemblyLink;

View File

@@ -0,0 +1,20 @@
// File: STEPSelections_AssemblyLink.cxx
// Created: Wed Mar 24 16:17:01 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_AssemblyLink.ixx>
STEPSelections_AssemblyLink::STEPSelections_AssemblyLink()
{
}
STEPSelections_AssemblyLink::STEPSelections_AssemblyLink(const Handle(StepRepr_NextAssemblyUsageOccurrence)& nauo,
const Handle(Standard_Transient)& item,
const Handle(STEPSelections_AssemblyComponent)& part)
{
myNAUO = nauo;
myItem = item;
myComponent = part;
}

View File

@@ -0,0 +1,64 @@
// File: STEPSelections_AssemblyLink.lxx
// Created: Wed Mar 24 16:11:23 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
//=======================================================================
//function : GetNAUO
//purpose :
//=======================================================================
inline Handle(StepRepr_NextAssemblyUsageOccurrence) STEPSelections_AssemblyLink::GetNAUO() const
{
return myNAUO;
}
//=======================================================================
//function : GetSDSR
//purpose :
//=======================================================================
inline Handle(Standard_Transient) STEPSelections_AssemblyLink::GetItem() const
{
return myItem;
}
//=======================================================================
//function : GetComponent
//purpose :
//=======================================================================
inline Handle(STEPSelections_AssemblyComponent) STEPSelections_AssemblyLink::GetComponent() const
{
return myComponent;
}
//=======================================================================
//function : SetNAUO
//purpose :
//=======================================================================
inline void STEPSelections_AssemblyLink::SetNAUO(const Handle(StepRepr_NextAssemblyUsageOccurrence)& nauo)
{
myNAUO = nauo;
}
//=======================================================================
//function : SetCDSR
//purpose :
//=======================================================================
inline void STEPSelections_AssemblyLink::SetItem(const Handle(Standard_Transient)& item)
{
myItem = item;
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
inline void STEPSelections_AssemblyLink::SetComponent(const Handle(STEPSelections_AssemblyComponent)& part)
{
myComponent = part;
}

View File

@@ -0,0 +1,94 @@
-- File: STEPSelections_Counter.cdl
-- Created: Thu Feb 11 18:23:32 1999
-- Author: Pavel DURANDIN
-- <pdn@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class Counter from STEPSelections
---Purpose:
uses
Graph from Interface,
MapOfTransient from TColStd,
ConnectedFaceSet from StepShape,
CompositeCurve from StepGeom
is
Create returns Counter from STEPSelections;
Count(me: in out;graph: Graph from Interface;
start: Transient);
Clear(me: in out);
NbInstancesOfFaces(me) returns Integer;
---C++: inline
---Purpose:
POP(me) returns Integer;
---C++: inline
---Purpose:
POP2(me) returns Integer
---C++: inline
;
---Purpose:
NbInstancesOfShells(me) returns Integer;
---C++: inline
---Purpose:
NbInstancesOfSolids(me) returns Integer;
---C++: inline
---Purpose:
NbInstancesOfEdges(me) returns Integer;
---C++: inline
---Purpose:
NbInstancesOfWires(me) returns Integer;
---C++: inline
---Purpose:
NbSourceFaces(me) returns Integer;
---C++: inline
---Purpose:
NbSourceShells(me) returns Integer;
---C++: inline
---Purpose:
NbSourceSolids(me) returns Integer;
---C++: inline
---Purpose:
NbSourceEdges(me) returns Integer;
---C++: inline
---Purpose:
NbSourceWires(me) returns Integer;
---C++: inline
---Purpose:
AddShell(me: in out; cfs: ConnectedFaceSet from StepShape) is private;
AddCompositeCurve(me: in out; ccurve: CompositeCurve from StepGeom) is private;
fields
myNbFaces : Integer;
myNbShells: Integer;
myNbSolids: Integer;
myNbEdges : Integer;
myNbWires : Integer;
myMapOfFaces : MapOfTransient from TColStd;
myMapOfShells: MapOfTransient from TColStd;
myMapOfSolids: MapOfTransient from TColStd;
myMapOfEdges : MapOfTransient from TColStd;
myMapOfWires : MapOfTransient from TColStd;
end Counter;

View File

@@ -0,0 +1,234 @@
// File: STEPSelections_Counter.cxx
// Created: Thu Feb 11 18:46:26 1999
// Author: Pavel DURANDIN
// <pdn@friendox.nnov.matra-dtv.fr>
#include <Interface_Macros.hxx>
#include <STEPSelections_Counter.ixx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <Interface_EntityIterator.hxx>
#include <Interface_Graph.hxx>
#include <StepShape_ContextDependentShapeRepresentation.hxx>
#include <StepShape_FacetedBrep.hxx>
#include <StepShape_BrepWithVoids.hxx>
#include <StepShape_ClosedShell.hxx>
#include <StepShape_OrientedClosedShell.hxx>
#include <StepShape_ShellBasedSurfaceModel.hxx>
#include <StepShape_Shell.hxx>
#include <StepShape_OpenShell.hxx>
#include <StepShape_FacetedBrepAndBrepWithVoids.hxx>
#include <StepRepr_MappedItem.hxx>
#include <StepShape_FaceSurface.hxx>
#include <StepRepr_RepresentationRelationship.hxx>
#include <StepRepr_ShapeRepresentationRelationship.hxx>
#include <STEPConstruct_Assembly.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepShape_GeometricCurveSet.hxx>
#include <StepShape_GeometricSetSelect.hxx>
#include <StepBasic_ProductRelatedProductCategory.hxx>
#include <StepGeom_CompositeCurveSegment.hxx>
#include <StepRepr_RepresentationMap.hxx>
STEPSelections_Counter::STEPSelections_Counter()
{
myNbFaces = 0;
myNbShells = 0;
myNbSolids = 0;
myNbWires = 0;
myNbEdges =0;
}
void STEPSelections_Counter::Count(const Interface_Graph& graph,
const Handle(Standard_Transient)& start)
{
if(start.IsNull()) return;
if (start->IsKind(STANDARD_TYPE(StepBasic_ProductRelatedProductCategory))) return;
if (start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
DeclareAndCast(StepShape_ShapeDefinitionRepresentation,sdr,start);
Count(graph,sdr->UsedRepresentation());
Interface_EntityIterator subs = graph.Shareds(start);
for (subs.Start(); subs.More(); subs.Next()) {
DeclareAndCast(StepShape_ContextDependentShapeRepresentation,anitem,subs.Value());
if (anitem.IsNull()) continue;
Count(graph,anitem);
}
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) {
DeclareAndCast(StepShape_ShapeRepresentation,sr,start);
Standard_Integer nb = sr->NbItems();
for (Standard_Integer i = 1; i <= nb; i++) {
Handle(StepRepr_RepresentationItem) anitem = sr->ItemsValue(i);
Count(graph,anitem);
}
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrep))) {
DeclareAndCast(StepShape_FacetedBrep,fbr,start);
myMapOfSolids.Add(start);
myNbSolids++;
AddShell(fbr->Outer());
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_BrepWithVoids))) {
DeclareAndCast(StepShape_BrepWithVoids,brwv,start);
myMapOfSolids.Add(start);
myNbSolids++;
AddShell(brwv->Outer());
Standard_Integer nbvoids = brwv->NbVoids();
for(Standard_Integer i = 1; i <= nbvoids; i++)
AddShell(brwv->VoidsValue(i));
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) {
DeclareAndCast(StepShape_ManifoldSolidBrep,msbr,start);
myMapOfSolids.Add(start);
myNbSolids++;
AddShell(msbr->Outer());
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))) {
DeclareAndCast(StepShape_ShellBasedSurfaceModel,sbsm,start);
Standard_Integer nbItems = sbsm->NbSbsmBoundary();
for(Standard_Integer i = 1; i <= nbItems; i++) {
Handle(StepShape_OpenShell) osh = sbsm->SbsmBoundaryValue(i).OpenShell();
if(!osh.IsNull()) AddShell(osh);
Handle(StepShape_ClosedShell) csh = sbsm->SbsmBoundaryValue(i).ClosedShell();
if(!csh.IsNull()) AddShell(csh);
}
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrepAndBrepWithVoids))) {
DeclareAndCast(StepShape_FacetedBrepAndBrepWithVoids,fbwv,start);
myMapOfSolids.Add(start);
myNbSolids++;
AddShell(fbwv->Outer());
Standard_Integer nbvoids = fbwv->NbVoids();
for(Standard_Integer i = 1; i <= nbvoids; i++)
AddShell(fbwv->VoidsValue(i));
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) {
DeclareAndCast(StepShape_GeometricSet,gs,start);
Standard_Integer nbElem = gs->NbElements();
for (Standard_Integer i = 1; i <= nbElem ; i++) {
StepShape_GeometricSetSelect aGSS = gs->ElementsValue(i);
Handle(Standard_Transient) ent = aGSS.Value();
Handle(StepGeom_CompositeCurve) ccurve = Handle(StepGeom_CompositeCurve)::DownCast(ent);
if(!ccurve.IsNull()) {
myNbWires++;
myMapOfWires.Add(ccurve);
AddCompositeCurve(ccurve);
} else
if(ent->IsKind(STANDARD_TYPE(StepGeom_Curve))) {
myNbEdges++;
myMapOfEdges.Add(ent);
} else
if(ent->IsKind(STANDARD_TYPE(StepGeom_Surface))) {
myNbFaces++;
myMapOfFaces.Add(ent);
}
}
}
if (start->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) {
DeclareAndCast(StepRepr_MappedItem,mi,start);
Count(graph,mi->MappingTarget());
Handle(StepRepr_RepresentationMap) map = mi->MappingSource();
if(map.IsNull()) return;
Count(graph,map->MappedRepresentation());
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_FaceSurface))) {
myNbFaces++;
myMapOfFaces.Add(start);
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) {
DeclareAndCast(StepShape_ContextDependentShapeRepresentation,CDSR,start);
DeclareAndCast(StepRepr_RepresentationRelationship,SRR,CDSR->RepresentationRelation());
if ( SRR.IsNull() ) return ;
Handle(StepRepr_Representation) rep;
Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph.Model(), CDSR );
if(SRRReversed)
rep = SRR->Rep2();
else
rep = SRR->Rep1();
Interface_EntityIterator subs = graph.Sharings(rep);
for (subs.Start(); subs.More(); subs.Next())
if ( subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
DeclareAndCast(StepShape_ShapeDefinitionRepresentation,SDR,subs.Value());
Count(graph,SDR);
}
//???
return;
}
if (start->IsKind (STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship)) ) {
DeclareAndCast(StepRepr_ShapeRepresentationRelationship,und,start);
for (Standard_Integer i = 1; i <= 2; i ++) {
Handle(Standard_Transient) anitem;
if (i == 1) anitem = und->Rep1();
if (i == 2) anitem = und->Rep2();
Count(graph,anitem);
}
return;
}
}
void STEPSelections_Counter::Clear()
{
myMapOfFaces.Clear();
myMapOfShells.Clear();
myMapOfSolids.Clear();
myMapOfWires.Clear();
myMapOfEdges.Clear();
myNbFaces = 0;
myNbShells = 0;
myNbSolids = 0;
myNbWires = 0;
myNbEdges =0;
}
void STEPSelections_Counter::AddShell(const Handle(StepShape_ConnectedFaceSet)& cfs)
{
myMapOfShells.Add(cfs);
myNbShells++;
Standard_Integer nbf = cfs->NbCfsFaces();
for(Standard_Integer i =1; i <= nbf; i++)
myMapOfFaces.Add(cfs->CfsFacesValue(i));
myNbFaces+=nbf;
return;
}
void STEPSelections_Counter::AddCompositeCurve(const Handle(StepGeom_CompositeCurve)& ccurve)
{
Standard_Integer nbs = ccurve->NbSegments();
for ( Standard_Integer i=1; i <= nbs; i++ ) {
// #ifdef AIX CKY : common code for all platforms: Handle() not Handle()&
Handle(StepGeom_CompositeCurveSegment) ccs = ccurve->SegmentsValue ( i );
Handle(StepGeom_Curve) crv = ccs->ParentCurve();
if(crv->IsKind(STANDARD_TYPE(StepGeom_CompositeCurve)))
AddCompositeCurve(Handle(StepGeom_CompositeCurve)::DownCast(crv));
else {
myNbEdges++;
myMapOfEdges.Add(crv);
}
}
}

View File

@@ -0,0 +1,55 @@
// File: STEPSelections_Counter.lxx
// Created: Thu Feb 11 18:50:10 1999
// Author: Pavel DURANDIN
// <pdn@friendox.nnov.matra-dtv.fr>
inline Standard_Integer STEPSelections_Counter::NbInstancesOfFaces() const
{
return myNbFaces;
}
inline Standard_Integer STEPSelections_Counter::NbInstancesOfShells() const
{
return myNbShells;
}
inline Standard_Integer STEPSelections_Counter::NbInstancesOfSolids() const
{
return myNbSolids;
}
inline Standard_Integer STEPSelections_Counter::NbInstancesOfEdges() const
{
return myNbEdges;
}
inline Standard_Integer STEPSelections_Counter::NbInstancesOfWires() const
{
return myNbWires;
}
inline Standard_Integer STEPSelections_Counter::NbSourceFaces() const
{
return myMapOfFaces.Extent();
}
inline Standard_Integer STEPSelections_Counter::NbSourceShells() const
{
return myMapOfShells.Extent();
}
inline Standard_Integer STEPSelections_Counter::NbSourceSolids() const
{
return myMapOfSolids.Extent();
}
inline Standard_Integer STEPSelections_Counter::NbSourceEdges() const
{
return myMapOfEdges.Extent();
}
inline Standard_Integer STEPSelections_Counter::NbSourceWires() const
{
return myMapOfWires.Extent();
}

View File

@@ -0,0 +1,29 @@
-- File: STEPSelections_SelectAssembly.cdl
-- Created: Thu Mar 25 12:46:08 1999
-- Author: data exchange team
-- <det@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class SelectAssembly from STEPSelections inherits SelectExplore from IFSelect
---Purpose:
uses
AsciiString from TCollection,
Transient,
EntityIterator,
Graph
is
Create returns mutable SelectAssembly from STEPSelections;
Explore (me; level : Integer; ent : Transient; G : Graph;
explored : in out EntityIterator)
returns Boolean;
---Purpose : Explores an entity, to take its faces
-- Works recursively
ExploreLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Assembly structures"
end SelectAssembly;

View File

@@ -0,0 +1,77 @@
// File: STEPSelections_SelectAssembly.cxx
// Created: Thu Mar 25 12:50:10 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_SelectAssembly.ixx>
#include <Interface_Macros.hxx>
#include <StepShape_ContextDependentShapeRepresentation.hxx>
#include <StepRepr_ProductDefinitionShape.hxx>
#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
#include <StepRepr_MappedItem.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
STEPSelections_SelectAssembly::STEPSelections_SelectAssembly():IFSelect_SelectExplore (-1){ }
Standard_Boolean STEPSelections_SelectAssembly::Explore(const Standard_Integer level,
const Handle(Standard_Transient)& start,
const Interface_Graph& G,
Interface_EntityIterator& explored) const
{
if(start.IsNull()) return Standard_False;
if(start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) {
DeclareAndCast(StepShape_ContextDependentShapeRepresentation,sdsr,start);
Handle(StepRepr_ProductDefinitionShape) pds = sdsr->RepresentedProductRelation();
if(pds.IsNull()) return Standard_False;
Handle(Standard_Transient) ent = pds->Definition().ProductDefinitionRelationship();
if(ent.IsNull()) return Standard_False;
return (ent->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence)));
}
if(start->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) {
DeclareAndCast(StepRepr_MappedItem,mapped,start);
Interface_EntityIterator subs = G.Sharings(mapped);
Handle(StepShape_ShapeRepresentation) shrep;
for(subs.Start(); subs.More()&&shrep.IsNull(); subs.Next())
if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation)))
shrep = Handle(StepShape_ShapeRepresentation)::DownCast(subs.Value());
if(shrep.IsNull()) return Standard_False;
subs = G.Sharings(shrep);
Handle(StepShape_ShapeDefinitionRepresentation) shdefrep;
for(subs.Start(); subs.More()&&shdefrep.IsNull(); subs.Next())
if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
shdefrep = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value());
if(shdefrep.IsNull()) return Standard_False;
Handle(StepRepr_ProductDefinitionShape) pds =
Handle(StepRepr_ProductDefinitionShape)::DownCast ( shdefrep->Definition().PropertyDefinition() );
if(pds.IsNull()) return Standard_False;
Handle(Standard_Transient) ent = pds->Definition().ProductDefinitionRelationship();
if(ent.IsNull()) return Standard_False;
return (ent->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence)));
}
Interface_EntityIterator subs = G.Shareds(start);
subs.Start();
Standard_Boolean isSome = subs.More();
for (; subs.More(); subs.Next())
explored.AddItem (subs.Value());
return isSome;
}
TCollection_AsciiString STEPSelections_SelectAssembly::ExploreLabel() const
{
return TCollection_AsciiString ("Assembly components");
}

View File

@@ -0,0 +1,26 @@
-- File: StepSelect_StepDerived.cdl
-- Created: Thu Feb 18 12:29:17 1999
-- Author: Pavel DURANDIN
-- <pdn@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class SelectDerived from STEPSelections inherits StepType from StepSelect
---Purpose:
uses
CString,
AsciiString from TCollection,
Protocol from Interface,
InterfaceModel,
Protocol from StepData
is
Create returns mutable SelectDerived;
Matches (me; ent : Transient; model : InterfaceModel;
text : AsciiString; exact : Boolean)
returns Boolean is redefined;
end SelectDerived;

View File

@@ -0,0 +1,59 @@
// File: StepSelect_StepDerived.cxx
// Created: Thu Feb 18 12:36:51 1999
// Author: Pavel DURANDIN
// <pdn@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_SelectDerived.ixx>
#include <StepData_ReadWriteModule.hxx>
#include <RWStepAP214_GeneralModule.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <Interface_Macros.hxx>
STEPSelections_SelectDerived::STEPSelections_SelectDerived():StepSelect_StepType()
{
}
static Handle(Standard_Type) GetStepType(const Handle(StepData_ReadWriteModule)& module,
const TCollection_AsciiString& type)
{
Handle(Standard_Type) atype;
if(module.IsNull()) return atype;
Standard_Integer num = module->CaseStep(type);
if(num == 0) return atype;
Handle(Standard_Transient) ent;
RWStepAP214_GeneralModule genModul;
genModul.NewVoid(num,ent);
atype = ent->DynamicType();
return atype;
}
Standard_Boolean STEPSelections_SelectDerived::Matches(const Handle(Standard_Transient)& ent,
const Handle(Interface_InterfaceModel)& model,
const TCollection_AsciiString& text,
const Standard_Boolean exact) const
{
Standard_Integer CN;
Handle(StepData_ReadWriteModule) module;
Standard_Boolean ok = thelib.Select (ent,module,CN);
if(!ok) return Standard_False;
Handle(Standard_Type) checker = GetStepType(module,text);
if(checker.IsNull()) return Standard_False;
Standard_Boolean plex = module->IsComplex(CN);
if (!plex) {
DeclareAndCast(Standard_Type,atype,ent);
if (atype.IsNull()) atype = ent->DynamicType();
return atype->SubType(checker);
} else {
TColStd_SequenceOfAsciiString list;
module->ComplexType (CN,list);
Standard_Integer nb = list.Length();
for (Standard_Integer i = 1; i <= nb; i ++) {
Handle(Standard_Type) atype = GetStepType(module,list.Value(i));
if(atype->SubType(checker)) return Standard_True;
}
}
return Standard_False;
}

View File

@@ -0,0 +1,32 @@
-- File: StepSelect_SelectFaces.cdl
-- Created: Thu Feb 11 14:32:43 1999
-- Author: Pavel DURANDIN
-- <pdn@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class SelectFaces from STEPSelections inherits SelectExplore from IFSelect
---Purpose: This selection returns "STEP faces"
uses
AsciiString from TCollection,
Transient,
EntityIterator,
Graph
is
Create returns mutable SelectFaces;
Explore (me; level : Integer; ent : Transient; G : Graph;
explored : in out EntityIterator)
returns Boolean;
---Purpose : Explores an entity, to take its faces
-- Works recursively
ExploreLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Faces"
end SelectFaces;

View File

@@ -0,0 +1,50 @@
// File: StepSelect_SelectFaces.cxx
// Created: Thu Feb 11 14:39:20 1999
// Author: Pavel DURANDIN
// <pdn@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_SelectFaces.ixx>
#include <StepShape_FaceSurface.hxx>
#include <StepGeom_Surface.hxx>
#include <StepShape_GeometricSet.hxx>
#include <StepGeom_Surface.hxx>
STEPSelections_SelectFaces::STEPSelections_SelectFaces():IFSelect_SelectExplore (-1){ }
Standard_Boolean STEPSelections_SelectFaces::Explore(const Standard_Integer level,
const Handle(Standard_Transient)& start,
const Interface_Graph& G,
Interface_EntityIterator& explored) const
{
if(start.IsNull()) return Standard_False;
if (start->IsKind(STANDARD_TYPE(StepShape_FaceSurface))) return Standard_True;
Standard_Boolean isInFaceOfInSurface = Standard_False;
if (start->IsKind(STANDARD_TYPE(StepGeom_Surface))) {
Interface_EntityIterator subs = G.Sharings(start);
for (subs.Start(); subs.More(); subs.Next()) {
if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet)))
return Standard_True;
if(subs.Value()->IsKind(STANDARD_TYPE(StepGeom_Surface)))
isInFaceOfInSurface = Standard_True;
if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_FaceSurface)))
isInFaceOfInSurface = Standard_True;
}
return !isInFaceOfInSurface;
}
Interface_EntityIterator subs = G.Shareds(start);
subs.Start();
Standard_Boolean isSome = subs.More();
for (; subs.More(); subs.Next())
explored.AddItem (subs.Value());
return isSome;
}
TCollection_AsciiString STEPSelections_SelectFaces::ExploreLabel() const
{
return TCollection_AsciiString ("Faces");
}

View File

@@ -0,0 +1,23 @@
-- File: STEPSelections_SelectForTransfer.cdl
-- Created: Mon Jun 2 16:45:25 2003
-- Author: Galina KULIKOVA
-- <gka@zamox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2003
class SelectForTransfer from STEPSelections inherits SelectForTransfer from XSControl
---Purpose:
uses
EntityIterator,
Graph,
TransferReader from XSControl
is
Create returns mutable SelectForTransfer;
Create (TR : TransferReader from XSControl) returns mutable SelectForTransfer;
RootResult(me; G : Graph) returns EntityIterator is redefined;
end SelectForTransfer;

View File

@@ -0,0 +1,38 @@
#include <STEPSelections_SelectForTransfer.ixx>
#include <Interface_EntityIterator.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Transfer_TransientProcess.hxx>
//=======================================================================
//function : STEPSelections_SelectForTransfer
//purpose :
//=======================================================================
STEPSelections_SelectForTransfer::STEPSelections_SelectForTransfer()
{
}
//=======================================================================
//function : STEPSelections_SelectForTransfer
//purpose :
//=======================================================================
STEPSelections_SelectForTransfer::STEPSelections_SelectForTransfer(const Handle(XSControl_TransferReader)& TR)
{
SetReader(TR);
}
//=======================================================================
//function : RootResult
//purpose :
//=======================================================================
Interface_EntityIterator STEPSelections_SelectForTransfer::RootResult(const Interface_Graph& /*G*/) const
{
Interface_EntityIterator iter;
Handle(TColStd_HSequenceOfTransient) roots = Reader()->TransientProcess()->RootsForTransfer();
Standard_Integer nb = roots->Length();
for(Standard_Integer i = 1; i <= nb ; i++)
iter.GetOneItem(roots->Value(i));
return iter;
}

View File

@@ -0,0 +1,31 @@
-- File: StepSelect_STEPGSCurves.cdl
-- Created: Mon Mar 22 17:55:38 1999
-- Author: data exchange team
-- <det@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class SelectGSCurves from STEPSelections inherits SelectExplore from IFSelect
---Purpose: This selection returns "curves in the geometric_set (except composite curves)"
uses
AsciiString from TCollection,
Transient,
EntityIterator,
Graph
is
Create returns mutable SelectGSCurves;
Explore(me; level: Integer; ent: Transient; G: Graph;
explored: in out EntityIterator)
returns Boolean;
---Purpose:
ExploreLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Curves"
end SelectGSCurves;

View File

@@ -0,0 +1,67 @@
// File: StepSelect_STEPGSCurves.cxx
// Created: Mon Mar 22 18:01:05 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_SelectGSCurves.ixx>
#include <StepGeom_Curve.hxx>
#include <StepGeom_CompositeCurve.hxx>
#include <StepShape_GeometricSet.hxx>
#include <StepGeom_CompositeCurveSegment.hxx>
static Standard_Integer flag;
STEPSelections_SelectGSCurves::STEPSelections_SelectGSCurves():IFSelect_SelectExplore (-1){ flag = 1;}
Standard_Boolean STEPSelections_SelectGSCurves::Explore(const Standard_Integer level,
const Handle(Standard_Transient)& start,
const Interface_Graph& G,
Interface_EntityIterator& explored) const
{
if(start.IsNull()) return Standard_False;
if (start->IsKind(STANDARD_TYPE(StepGeom_Curve))) {
if(start->IsKind(STANDARD_TYPE(StepGeom_CompositeCurve))) {
Interface_EntityIterator subs = G.Sharings(start);
Standard_Boolean isInGeomSet = Standard_False;
for (subs.Start(); subs.More()&&!isInGeomSet; subs.Next())
if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))){
if(flag) {
explored.AddItem (subs.Value());
flag =0;
}
isInGeomSet = Standard_True;
}
if(isInGeomSet) {
Interface_EntityIterator subs = G.Shareds(start);
subs.Start();
Standard_Boolean isSome = subs.More();
for (; subs.More(); subs.Next())
explored.AddItem (subs.Value());
return isSome;
} else
return Standard_False;
} else {
Interface_EntityIterator subs = G.Sharings(start);
for (subs.Start(); subs.More(); subs.Next()) {
if(subs.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))||
subs.Value()->IsKind(STANDARD_TYPE(StepGeom_CompositeCurveSegment)))
return Standard_True;
}
}
}
Interface_EntityIterator subs = G.Shareds(start);
subs.Start();
Standard_Boolean isSome = subs.More();
for (; subs.More(); subs.Next())
explored.AddItem (subs.Value());
return isSome;
}
TCollection_AsciiString STEPSelections_SelectGSCurves::ExploreLabel() const
{
return TCollection_AsciiString ("Curves in GS");
}

View File

@@ -0,0 +1,32 @@
-- File: STEPSelections_SelectInstances.cdl
-- Created: Tue Mar 23 15:10:13 1999
-- Author: data exchange team
-- <det@friendox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class SelectInstances from STEPSelections inherits SelectExplore from IFSelect
---Purpose:
uses
AsciiString from TCollection,
EntityIterator,
Graph
is
Create returns mutable SelectInstances;
RootResult(me; G : Graph) returns EntityIterator;
Explore (me; level : Integer; ent : Transient; G : Graph;
explored : in out EntityIterator)
returns Boolean;
ExploreLabel (me) returns AsciiString from TCollection;
---Purpose : Returns a text defining the criterium : "Instances"
HasUniqueResult (me) returns Boolean is redefined protected;
end SelectInstances;

View File

@@ -0,0 +1,166 @@
// File: STEPSelections_SelectInstances.cxx
// Created: Tue Mar 23 15:14:34 1999
// Author: data exchange team
// <det@friendox.nnov.matra-dtv.fr>
#include <STEPSelections_SelectInstances.ixx>
#include <Interface_Macros.hxx>
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <StepShape_ContextDependentShapeRepresentation.hxx>
#include <StepShape_ShapeRepresentation.hxx>
#include <StepRepr_RepresentationItem.hxx>
#include <StepShape_FacetedBrep.hxx>
#include <StepShape_BrepWithVoids.hxx>
#include <StepShape_ManifoldSolidBrep.hxx>
#include <StepShape_ShellBasedSurfaceModel.hxx>
#include <StepShape_FacetedBrepAndBrepWithVoids.hxx>
#include <StepShape_GeometricSet.hxx>
#include <StepShape_FaceSurface.hxx>
#include <StepRepr_MappedItem.hxx>
#include <STEPConstruct_Assembly.hxx>
#include <StepRepr_ShapeRepresentationRelationship.hxx>
#include <TColStd_IndexedMapOfTransient.hxx>
#include <Interface_HGraph.hxx>
static Handle(Interface_HGraph) myGraph;
static Interface_EntityIterator myEntities;
STEPSelections_SelectInstances::STEPSelections_SelectInstances():IFSelect_SelectExplore (-1){ }
static void AddAllSharings(const Handle(Standard_Transient)& start,
const Interface_Graph& graph,
Interface_EntityIterator& explored)
{
if(start.IsNull()) return;
Interface_EntityIterator subs = graph.Shareds(start);
for (subs.Start(); subs.More(); subs.Next()) {
explored.AddItem(subs.Value());
AddAllSharings(subs.Value(), graph, explored);
}
}
static void AddInstances(const Handle(Standard_Transient)& start,
const Interface_Graph& graph,
Interface_EntityIterator& explored)
{
if(start.IsNull()) return;
explored.AddItem(start);
if (start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
DeclareAndCast(StepShape_ShapeDefinitionRepresentation,sdr,start);
AddInstances(sdr->UsedRepresentation(),graph,explored);
Interface_EntityIterator subs = graph.Shareds(start);
for (subs.Start(); subs.More(); subs.Next()) {
DeclareAndCast(StepShape_ContextDependentShapeRepresentation,anitem,subs.Value());
if (anitem.IsNull()) continue;
AddInstances(anitem,graph,explored);
}
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) {
DeclareAndCast(StepShape_ShapeRepresentation,sr,start);
Standard_Integer nb = sr->NbItems();
for (Standard_Integer i = 1; i <= nb; i++) {
Handle(StepRepr_RepresentationItem) anitem = sr->ItemsValue(i);
AddInstances(anitem,graph,explored);
}
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_FacetedBrep))||
start->IsKind(STANDARD_TYPE(StepShape_BrepWithVoids))||
start->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))||
start->IsKind(STANDARD_TYPE(StepShape_ShellBasedSurfaceModel))||
start->IsKind(STANDARD_TYPE(StepShape_FacetedBrepAndBrepWithVoids))||
start->IsKind(STANDARD_TYPE(StepShape_GeometricSet))||
start->IsKind(STANDARD_TYPE(StepShape_FaceSurface))||
start->IsKind(STANDARD_TYPE(StepRepr_MappedItem))) {
AddAllSharings(start, graph, explored);
return;
}
if (start->IsKind(STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation))) {
DeclareAndCast(StepShape_ContextDependentShapeRepresentation,CDSR,start);
DeclareAndCast(StepRepr_RepresentationRelationship,SRR,CDSR->RepresentationRelation());
if ( SRR.IsNull() ) return ;
Handle(StepRepr_Representation) rep;
Standard_Boolean SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph.Model(), CDSR );
if(SRRReversed)
rep = SRR->Rep2();
else
rep = SRR->Rep1();
Interface_EntityIterator subs = graph.Sharings(rep);
for (subs.Start(); subs.More(); subs.Next())
if ( subs.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) {
DeclareAndCast(StepShape_ShapeDefinitionRepresentation,SDR,subs.Value());
AddInstances(SDR,graph,explored);
}
//???
return;
}
if (start->IsKind (STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship)) ) {
DeclareAndCast(StepRepr_ShapeRepresentationRelationship,und,start);
for (Standard_Integer i = 1; i <= 2; i ++) {
Handle(Standard_Transient) anitem;
if (i == 1) anitem = und->Rep1();
if (i == 2) anitem = und->Rep2();
AddInstances(anitem,graph,explored);
}
return;
}
}
Interface_EntityIterator STEPSelections_SelectInstances::RootResult(const Interface_Graph &G) const
{
if(myGraph.IsNull()||(G.Model()!=myGraph->Graph().Model()))
{
Interface_EntityIterator roots = G.RootEntities();
myGraph = new Interface_HGraph(G);
myEntities.Destroy();
for (roots.Start(); roots.More(); roots.Next())
AddInstances(roots.Value(), G, myEntities);
}
if(HasInput()||HasAlternate()) {
Interface_EntityIterator select = InputResult(G);
Standard_Integer nbSelected = select.NbEntities();
TColStd_IndexedMapOfTransient filter (nbSelected);
for(select.Start(); select.More(); select.Next())
filter.Add(select.Value());
Interface_EntityIterator result;
for(myEntities.Start(); myEntities.More(); myEntities.Next())
if(filter.Contains(myEntities.Value()))
result.AddItem(myEntities.Value());
return result;
}
else
return myEntities;
}
Standard_Boolean STEPSelections_SelectInstances::Explore(const Standard_Integer level,
const Handle(Standard_Transient)& start,
const Interface_Graph& G,
Interface_EntityIterator& explored) const
{
return Standard_False;
}
Standard_Boolean STEPSelections_SelectInstances::HasUniqueResult() const
{
return Standard_True;
}
TCollection_AsciiString STEPSelections_SelectInstances::ExploreLabel() const
{
return TCollection_AsciiString ("Instances");
}