summaryrefslogtreecommitdiff
path: root/src/IGESSelect/IGESSelect_SelectPCurves.cxx
blob: 1294eb0c2b4f2a50a844f879525348ea87a193e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <IGESSelect_SelectPCurves.ixx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGeom_CurveOnSurface.hxx>
#include <IGESGeom_TrimmedSurface.hxx>
#include <IGESGeom_BoundedSurface.hxx>
#include <IGESGeom_Boundary.hxx>
#include <IGESBasic_Group.hxx>
#include <IGESSolid_ManifoldSolid.hxx>
#include <IGESSolid_Shell.hxx>
#include <IGESSolid_Face.hxx>
#include <IGESSolid_Loop.hxx>
#include <IGESSelect_SelectBasicGeom.hxx>

#include <Interface_Macros.hxx>

    IGESSelect_SelectPCurves::IGESSelect_SelectPCurves
  (const Standard_Boolean basic)
    : IFSelect_SelectExplore (-1) , thebasic (basic)    {  }


    Standard_Boolean  IGESSelect_SelectPCurves::Explore
  (const Standard_Integer level, const Handle(Standard_Transient)& ent,
   const Interface_Graph& G, Interface_EntityIterator& explored) const
{
  DeclareAndCast(IGESData_IGESEntity,igesent,ent);
  if (igesent.IsNull()) return Standard_False;
  Standard_Integer igt = igesent->TypeNumber();

//   TrimmedSurface 144
  if (igt == 144) {
    DeclareAndCast(IGESGeom_TrimmedSurface,trs,ent);
      explored.AddItem(trs->OuterContour());
      Standard_Integer i, nb = trs->NbInnerContours();
      for (i = 1; i <= nb; i ++) explored.AddItem (trs->InnerContour(i));
    return Standard_True;
  }

//   CurveOnSurface 142
  if (igt == 142) {
    DeclareAndCast(IGESGeom_CurveOnSurface,crf,ent);
    explored.AddItem(crf->CurveUV());
    if (thebasic) IGESSelect_SelectBasicGeom::SubCurves (crf->CurveUV(),explored);
    return Standard_True;
  }

//   Boundary 141
  if (igt == 141) {
    DeclareAndCast(IGESGeom_Boundary,bnd,ent);
    Standard_Integer i, nb = bnd->NbModelSpaceCurves();
    for (i = 1; i <= nb; i ++) {
      Standard_Integer j,np = bnd->NbParameterCurves(i);
      for (j = 1; j <= np; j ++) {
	explored.AddItem (bnd->ParameterCurve(i,j));
      }
    }
    return (nb > 0);
  }

//   BoundedSurface 143
  if (igt == 143) {
    DeclareAndCast(IGESGeom_BoundedSurface,bns,ent);
    Standard_Integer i, nb = bns->NbBoundaries(); //szv#4:S4163:12Mar99 optimized
      for (i = 1; i <= nb; i ++) explored.AddItem (bns->Boundary(i));
      return (nb != 0);
    //return Standard_True; //szv#4:S4163:12Mar99 unreached
  }


//  Groups ... en dernier de la serie 402
  if (igt == 402) {
    DeclareAndCast(IGESBasic_Group,gr,ent);
    if (gr.IsNull()) return Standard_False;
    Standard_Integer i, nb = gr->NbEntities();
    for (i = 1; i <= nb; i ++)  explored.AddItem (gr->Entity(i));
    return Standard_True;
  }


//  ManifoldSolid 186  -> Shells
  if (igt == 186) {
    DeclareAndCast(IGESSolid_ManifoldSolid,msb,ent);
    explored.AddItem (msb->Shell());
    Standard_Integer i, nb = msb->NbVoidShells();
    for (i = 1; i <= nb; i ++)  explored.AddItem (msb->VoidShell(i));
    return Standard_True;
  }

//  Shell 514 -> Faces
  if (igt == 514) {
    DeclareAndCast(IGESSolid_Shell,sh,ent);
    Standard_Integer i, nb = sh->NbFaces();
    for (i = 1; i <= nb; i ++)  explored.AddItem (sh->Face(i));
    return Standard_True;
  }

//  Face 510 -> Loops
  if (igt == 510) {
    DeclareAndCast(IGESSolid_Face,fc,ent);
      Standard_Integer i, nb = fc->NbLoops();
      for (i = 1; i <= nb; i ++)  explored.AddItem (fc->Loop(i));
    return Standard_True;
  }

//  Loop 508 -> PCurves (enfin !)
  if (igt == 508) {
    DeclareAndCast(IGESSolid_Loop,lp,ent);
    Standard_Integer i, nb = lp->NbEdges();
    for (i = 1; i <= nb; i ++)  {
      Standard_Integer j, np = lp->NbParameterCurves(i);
      for (j = 1; j <= np; j ++) //szv#4:S4163:12Mar99 was bug
	explored.AddItem(lp->ParametricCurve(i,j));
    }
    return Standard_True;
  }

//   LES LIGNES : seult si en tant que pcurve : donc level >= 3
//   Lignes en general. Attention CopiousData, aux variantes "habillage"
  if (level < 3) return Standard_False;

  if (igt == 106) return (igesent->FormNumber() < 20);
  if ( (igt >= 100 && igt <= 106) || igt == 110 || igt == 112 || igt == 116 ||
      igt == 126 || igt == 130) return Standard_True;

//  Pas trouve
  return Standard_False;
}


    TCollection_AsciiString IGESSelect_SelectPCurves::ExploreLabel () const
{
  if (thebasic) return TCollection_AsciiString ("Basic PCurves");
  else return TCollection_AsciiString ("Global PCurves");
}