Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

ProductOccurrenceWalker.h
1 // Copyright (c) Tech Soft 3D
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 #pragma once
11 
12 #include "ExchangeWrapper.h"
13 
14 
16 {
17 public:
19  A3DAsmProductOccurrence * a3dPocc)
20  : rootPocc(a3dPocc)
21  {}
22 
23  template <typename Function>
24  void ForPart(
25  Function function)
26  {
27  ForPart(rootPocc.data, function);
28  }
29 
30  template <typename Function>
31  void ForEachChildProductOccurence(
32  Function function)
33  {
34  ForEachChildProductOccurrence(rootPocc.data, function);
35  }
36 
37 private:
38  template <typename Function>
39  void ForPart(
40  A3DAsmProductOccurrenceData const & data,
41  Function function)
42  {
43  if (data.m_pPart)
44  function(data.m_pPart);
45  else if (!ForPrototypePart(data.m_pPrototype, function))
46  {
47  if (data.m_uiPOccurrencesSize == 0 && data.m_pExternalData)
48  {
49  Query::AsmProductOccurrence external(data.m_pExternalData);
50  ForPart(external.data, function);
51  }
52  }
53  }
54 
55  template <typename Function>
56  bool ForPrototypePart(
57  A3DAsmProductOccurrence * a3dPrototype,
58  Function function)
59  {
60  if (!a3dPrototype)
61  return false;
62 
63  Query::AsmProductOccurrence prototype(a3dPrototype);
64  if (prototype->m_pPart)
65  {
66  function(prototype->m_pPart);
67  return true;
68  }
69  else
70  return ForPrototypePart(prototype->m_pPrototype, function);
71  }
72 
73  template <typename Function>
74  void ForEachChildProductOccurrence(
75  A3DAsmProductOccurrenceData const & data,
76  Function function)
77  {
78  bool foundChildren = ForEachChildOrPrototypeChildProductOccurrence(data, function);
79 
80  A3DAsmProductOccurrence * a3dExternal = data.m_pExternalData;
81  if (a3dExternal)
82  {
83  if (foundChildren)
84  function(a3dExternal);
85  else
86  {
87  Query::AsmProductOccurrence external(a3dExternal);
88  ForEachChildProductOccurrence(external.data, function);
89  }
90  }
91  }
92 
93  template <typename Function>
94  bool ForEachChildOrPrototypeChildProductOccurrence(
95  A3DAsmProductOccurrenceData const & data,
96  Function function)
97  {
98  bool foundChildren = false;
99  if (data.m_uiPOccurrencesSize > 0)
100  {
101  for (A3DUns32 i = 0; i < data.m_uiPOccurrencesSize; ++i)
102  function(data.m_ppPOccurrences[i]);
103 
104  foundChildren = true;
105  }
106  else if (data.m_pPrototype)
107  {
108  Query::AsmProductOccurrence prototype(data.m_pPrototype);
109  foundChildren = ForEachChildOrPrototypeChildProductOccurrence(prototype.data, function);
110  }
111 
112  return foundChildren;
113  }
114 
115 private:
117 };
Definition: ProductOccurrenceWalker.h:15
Definition: ExchangeWrapper.h:563