libsurf
Programmer's Documentation

producttree.h (r6227/r5385)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_PRODUCTTREE_H
16 #define SURF_PRODUCTTREE_H
17 
18 #include "instance.h"
19 #include "forward.h"
20 #include <genua/cgmesh.h>
21 #include <genua/mxmesh.h>
22 #include <boost/shared_ptr.hpp>
23 #include <vector>
24 
32 class ProductTree : public Instance
33 {
34 public:
35 
37  ProductTree() : m_etype(NotFound) {}
38 
40  virtual ~ProductTree() {}
41 
43  uint nchildren() const {return m_siblings.size();}
44 
46  bool leafNode() const {return (nchildren() == 0);}
47 
49  uint depth() const;
50 
52  void append(ProductTreePtr p) { m_siblings.push_back(p); }
53 
55  ProductTreePtr child(uint k) const {
56  assert(k < nchildren());
57  return m_siblings[k];
58  }
59 
61  CgMeshPtr cgRep() const {return m_cgr;}
62 
64  void cgRep(const CgMeshPtr & cgr) {m_cgr = cgr;}
65 
67  bool isSurface() const {return (m_psf.get() != 0);}
68 
70  bool isCurve() const {return (m_pcv.get() != 0);}
71 
73  SurfacePtr surface() const {return m_psf;}
74 
76  void surface(const SurfacePtr & psf) {m_psf = psf;}
77 
79  AbstractCurvePtr curve() const {return m_pcv;}
80 
82  void curve(const AbstractCurvePtr & pcv) {m_pcv = pcv;}
83 
85  void enumerate(uint & offset);
86 
88  void mergeNodeCg();
89 
91  void mergeCg(bool clearChildren);
92 
94  void collapseMesh();
95 
97  uint ntriangles() const;
98 
100  void toMxSection(MxMesh & mx) const;
101 
103  virtual XmlElement toXml(bool share) const;
104 
106  virtual void fromXml(const XmlElement & xe);
107 
109  bool fromIges(const IgesFile & file, uint ide, int importScope);
110 
112  virtual void clear();
113 
115  void print(int indent=0) const;
116 
118  static void connectParents(ProductTreePtr node);
119 
120 protected:
121 
123  ProductTreePtr m_parent;
124 
126  ProductArray m_siblings;
127 
129  SurfacePtr m_psf;
130 
132  AbstractCurvePtr m_pcv;
133 
135  CgMeshPtr m_cgr;
136 
138  uint m_etype;
139 };
140 
141 //inline bool operator< (const ProductTreePtr & a, const ProductTreePtr & b)
142 //{
143 // return a->id() < b.id();
144 //}
145 
146 #endif // PRODUCTTREE_H
void curve(const AbstractCurvePtr &pcv)
set curve pointer
Definition: producttree.h:82
virtual ~ProductTree()
base class
Definition: producttree.h:40
virtual void fromXml(const XmlElement &xe)
recover from xml
Definition: producttree.cpp:66
CgMeshPtr m_cgr
graphical representation (may be zero)
Definition: producttree.h:135
bool isSurface() const
whether this node is a surface object
Definition: producttree.h:67
bool fromIges(const IgesFile &file, uint ide, int importScope)
read as a flat object from IGES file
Definition: producttree.cpp:83
void collapseMesh()
collapse mesh in parallel
Definition: producttree.cpp:203
void cgRep(const CgMeshPtr &cgr)
access CG representation
Definition: producttree.h:64
SurfacePtr m_psf
surface pointer associated with this node, if any
Definition: producttree.h:129
void mergeCg(bool clearChildren)
pull up child CgMesh representations
Definition: producttree.cpp:184
Main interface to IGES files.
Definition: igesfile.h:32
ProductTreePtr m_parent
parent node
Definition: producttree.h:123
Tree structure for geometric instances.
Definition: producttree.h:32
uint m_etype
IGES entity type.
Definition: producttree.h:138
void enumerate(uint &offset)
assign a sequence of IDs to the complete tree
Definition: producttree.cpp:39
void toMxSection(MxMesh &mx) const
generate a section in MxMesh
Definition: producttree.cpp:305
void print(int indent=0) const
write out text representation (debugging)
Definition: producttree.cpp:342
virtual XmlElement toXml(bool share) const
store as xml
Definition: producttree.cpp:47
ProductTreePtr child(uint k) const
access child node
Definition: producttree.h:55
static void connectParents(ProductTreePtr node)
reconnect parent nodes recursively
Definition: producttree.cpp:365
void surface(const SurfacePtr &psf)
set surface pointer
Definition: producttree.h:76
AbstractCurvePtr curve() const
access curve (may be nil)
Definition: producttree.h:79
ProductArray m_siblings
sibling nodes
Definition: producttree.h:126
void append(ProductTreePtr p)
append sibling node
Definition: producttree.h:52
bool isCurve() const
whether this node is a curve object
Definition: producttree.h:70
bool leafNode() const
leaf node?
Definition: producttree.h:46
ProductTree()
create empty tree
Definition: producttree.h:37
void mergeNodeCg()
merge sibling tesselations into *this
Definition: producttree.cpp:159
virtual void clear()
clear all data
Definition: producttree.cpp:374
AbstractCurvePtr m_pcv
curve pointer associated with node, if any
Definition: producttree.h:132
uint ntriangles() const
compute the number of triangles in the CG representation
Definition: producttree.cpp:330
SurfacePtr surface() const
access surface
Definition: producttree.h:73
uint depth() const
compute tree depth
Definition: producttree.cpp:31
CgMeshPtr cgRep() const
access CG representation
Definition: producttree.h:61
Base class for geometric object instancing.
Definition: instance.h:42
uint nchildren() const
number of child nodes
Definition: producttree.h:43
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5