GemaMesh
The GeMA Mesh Plugin
Loading...
Searching...
No Matches
uibhmQuery.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _UIBHM_QUERY_H_
25#define _UIBHM_QUERY_H_
26
27#include "uibhmTopology.h"
28
29#include <gmCellMeshTopology.h>
30
35template <class Geometry>
36class GMP_GEMAMESH_API_EXPORT UibhmQuery : public GmCellMeshTopology
37{
38public:
39
40 // An alias for the topology structure to simplify the call to static functions
42
43 // 'Import' the half side type from the topology object
44 using HalfSide = typename Topology::HalfSide;
45
47 UibhmQuery(UibhmTopology<Geometry>* topology) : _t(topology) { assert(topology); }
48
49 // See comments on the base class
50 virtual bool hasElementsWithoutTopology() const { return _t->strange(); }
51
52 virtual GmCell* adjacentCell(const GmCell* cell, int sideIndex, int* adjSideIndex = NULL) const;
53
54 virtual bool isBorderNode(int nodeIndex) const;
55
56 // See comments on the base class
57 virtual int numBorders() const { return _t->_B.size(); }
58
59 virtual int borderIndex(const GmCell* cell, int sideIndex) const;
60
61 // See comments on the base class
62 virtual void printParameters(const GmLogCategory& logger, GmLogLevel level) const { _t->printParameters(logger, level); }
63
64 // See comments on the base class
65 virtual void print(const GmLogCategory& logger, GmLogLevel level) const { _t->print(logger, level); }
66
67 // See comments on the base class
68 virtual size_t printMemoryStatistics(const GmLogCategory& logger, GmLogLevel level) const { return _t->printMemoryStatistics(logger, level); }
69
70 // See comments on the base class
71 virtual size_t usedMemory() const { return _t->usedMemory(); }
72
73protected:
75};
76
78template <class Geometry>
79class GMP_GEMAMESH_API_EXPORT UibhmSurfaceQuery : public UibhmQuery<Geometry>
80{
81public:
83 UibhmSurfaceQuery(UibhmTopology<Geometry>* topology) : UibhmQuery<Geometry>(topology) {}
84
85 virtual void nodeAdjacentNodes(int nodeIndex, QueryOptions options, QVector<int>& list) const;
86 virtual void nodeAdjacentCells(int nodeIndex, QVector<GmCell*>& list) const;
87
88 // See comments on the base class
89 virtual void nodeAdjacentCells(int nodeIndex, QVector<const GmCell*>& list) const
90 {
91 // to avoid code duplication, lets just call the non-const version of this function
92 nodeAdjacentCells(nodeIndex, (QVector<GmCell*>&)list);
93 }
94
95 virtual void edgeAdjacentCells(const GmCell* cell, int edgeIndex, QVector<GmCell*>& list) const;
96
97 // See comments on the base class
98 virtual void edgeAdjacentCells(const GmCell* cell, int edgeIndex, QVector<const GmCell*>& list) const
99 {
100 // to avoid code duplication, lets just call the non-const version of this function
101 edgeAdjacentCells(cell, edgeIndex, (QVector<GmCell*>&)list);
102 }
103
104 virtual void edgeAdjacentCells(int node1, int node2, QVector<GmCell*>& list) const;
105
106 // See comments on the base class
107 virtual void edgeAdjacentCells(int node1, int node2, QVector<const GmCell*>& list) const
108 {
109 // to avoid code duplication, lets just call the non-const version of this function
110 edgeAdjacentCells(node1, node2, (QVector<GmCell*>&)list);
111 }
112
113 virtual GmCell* firstBorderCurveEdge(int borderCurveIndex, int* edgeIndex) const;
114 virtual GmCell* nextBorderCurveEdge (const GmCell* cell, int edgeIndex, int* nextEdgeIndex) const;
115
116 virtual void* borderTraverseStart(int borderId) const;
117 virtual GmCell* borderTraverseNext(void* context, int* nextSideIndex) const;
118 virtual void borderTraverseEnd(void* context) const;
119
120private:
121
123 struct TraverseContext { HalfSide _start; HalfSide _last; };
124
125 template <class VertexF, class QuadF>
126 void heStar(int node, VertexF vf, QuadF qf, bool addBorder) const;
127};
128
130template <class Geometry>
131class GMP_GEMAMESH_API_EXPORT UibhmSolidQuery : public UibhmQuery<Geometry>
132{
133public:
135 UibhmSolidQuery(UibhmTopology<Geometry>* topology) : UibhmQuery<Geometry>(topology) {}
136
137 virtual void nodeAdjacentNodes(int nodeIndex, QueryOptions options, QVector<int>& list) const;
138 virtual void nodeAdjacentCells(int nodeIndex, QVector<GmCell*>& list) const;
139
140 // See comments on the base class
141 virtual void nodeAdjacentCells(int nodeIndex, QVector<const GmCell*>& list) const
142 {
143 // to avoid code duplication, lets just call the non-const version of this function
144 nodeAdjacentCells(nodeIndex, (QVector<GmCell*>&)list);
145 }
146
147 virtual void edgeAdjacentCells(const GmCell* cell, int edgeIndex, QVector<GmCell*>& list) const;
148
149 // See comments on the base class
150 virtual void edgeAdjacentCells(const GmCell* cell, int edgeIndex, QVector<const GmCell*>& list) const
151 {
152 // to avoid code duplication, lets just call the non-const version of this function
153 edgeAdjacentCells(cell, edgeIndex, (QVector<GmCell*>&)list);
154 }
155
156 // See comments on the base class
157 virtual void edgeAdjacentCells(int node1, int node2, QVector<GmCell*>& list) const
158 {
159 edgeAdjacentCells(Topology::encodeEdge(node1, node2), list);
160 }
161
162 // See comments on the base class
163 virtual void edgeAdjacentCells(int node1, int node2, QVector<const GmCell*>& list) const
164 {
165 edgeAdjacentCells(Topology::encodeEdge(node1, node2), list);
166 }
167
168 // See comments on the base class.
169 virtual void edgeAdjacentCells(size_t encodedEdge, QVector<GmCell*>& list) const;
170
171 // See comments on the base class
172 virtual void edgeAdjacentCells(size_t encodedEdge, QVector<const GmCell*>& list) const
173 {
174 // to avoid code duplication, lets just call the non-const version of this function
175 edgeAdjacentCells(encodedEdge, (QVector<GmCell*>&)list);
176 }
177
178 // See comments on the base class
179 virtual GmCell* firstBorderCurveEdge(int borderCurveIndex, int* edgeIndex) const
180 {
181 Q_UNUSED(borderCurveIndex); Q_UNUSED(edgeIndex);
182 assert(0); // should not be called for solid meshes
183 return NULL;
184 }
185
186 // See comments on the base class
187 virtual GmCell* nextBorderCurveEdge(const GmCell* cell, int edgeIndex, int* nextEdgeIndex) const
188 {
189 Q_UNUSED(cell); Q_UNUSED(edgeIndex); Q_UNUSED(nextEdgeIndex);
190 assert(0); // should not be called for solid meshes
191 return NULL;
192 }
193
194 virtual void* borderTraverseStart(int borderId) const;
195 virtual GmCell* borderTraverseNext(void* context, int* nextSideIndex) const;
196 virtual void borderTraverseEnd(void* context) const;
197
198private:
199 template <class QueryF>
200 bool traverseCells(int nodeIndex, int cellId, QueryF f) const;
201
202 template <class QueryF>
203 bool traverseAroundFlowNode(int nodeIndex, QueryF f) const;
204
205 template <class QueryF>
206 void traverseEdgeAdjacentCellsByNodeQuery(int v1, int v2, QueryF f) const;
207
208 bool edgeAdjacentCells(HalfSide hf, int v1, int v2, QVector<GmCell*>& list) const;
209};
210
211#endif
virtual void print(const GmLogCategory &logger, GmLogLevel level) const=0
virtual GmCell * borderTraverseNext(void *context, int *nextSideIndex) const=0
virtual GmCell * nextBorderCurveEdge(const GmCell *cell, int edgeIndex, int *nextEdgeIndex) const=0
virtual void edgeAdjacentCells(const GmCell *cell, int edgeIndex, QVector< GmCell * > &list) const=0
virtual size_t usedMemory() const=0
virtual void printParameters(const GmLogCategory &logger, GmLogLevel level) const=0
virtual void borderTraverseEnd(void *context) const=0
virtual GmCell * adjacentCell(const GmCell *cell, int sideIndex, int *adjSideIndex=NULL) const=0
virtual size_t printMemoryStatistics(const GmLogCategory &logger, GmLogLevel level) const=0
virtual int numBorders() const=0
virtual void nodeAdjacentNodes(int nodeIndex, QueryOptions options, QVector< int > &list) const=0
virtual bool isBorderNode(int nodeIndex) const=0
virtual void nodeAdjacentCells(int nodeIndex, QVector< GmCell * > &list) const=0
virtual bool hasElementsWithoutTopology() const=0
virtual void * borderTraverseStart(int borderId) const=0
virtual GmCell * firstBorderCurveEdge(int borderCurveIndex, int *edgeIndex) const=0
virtual int borderIndex(const GmCell *cell, int sideIndex) const=0
The basic class for topological queries using the UibhmTopology structure. Implements the GmCellMeshT...
Definition uibhmQuery.h:37
UibhmQuery(UibhmTopology< Geometry > *topology)
Constructor.
Definition uibhmQuery.h:47
The UibhmQuery especialization for solid meshes.
Definition uibhmQuery.h:132
UibhmSolidQuery(UibhmTopology< Geometry > *topology)
Constructor.
Definition uibhmQuery.h:135
The UibhmQuery especialization for surface meshes.
Definition uibhmQuery.h:80
UibhmSurfaceQuery(UibhmTopology< Geometry > *topology)
Constructor.
Definition uibhmQuery.h:83
Definition uibhmTopology.h:172
quint32 HalfSide
The integer type used to represent a half-side index.
Definition uibhmTopology.h:176
GmLogLevel
The context used by borderTraverseXxx()
Definition uibhmQuery.h:123
Declaration of the UibhmTopology familiy of classes.