FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
VertexSelection.hpp
1#ifndef VERTEX_SELECTION_HPP
2#define VERTEX_SELECTION_HPP
3
4#include <vector>
5
6#include "gridopDllApi.h"
7
8#include "aerie/BoundingBox.hpp"
9#include "aerie/KDTree.hpp"
10
11#include "ocean/shrimp/PhysicalSpace.hpp"
12
13#include "bundle/GridSelector.hpp"
14#include "field/OnDemandCreator.hpp"
15#include "grid/types/LineSet.hpp"
16#include "grid/CartesianChart.hpp"
17
18
19
20namespace Fiber
21{
22
23
24// idx 0: fragment nr
25// idx 1: vertex nr
26typedef Fiber::MultiIndex<2> VertexSelection_t;
27
28
29
30
32{
33 bool operator() (const VertexSelection_t& lhs, const VertexSelection_t& rhs) const
34 {
35 if( lhs[0] < rhs[0])
36 return true;
37 else if( lhs[0] > rhs[0] )
38 return false;
39 else
40 {
41 if( lhs[1] < rhs[1] )
42 return true;
43 else
44 return false;
45 }
46 }
47};
48
50{
51 virtual bool apply( const std::string&name, int ref, MemCore::RefPtr<Fiber::MemArray<1, VertexSelection_t> >& selection ) = 0;
52};
53
54
63class gridop_API VertexSelection : public MemCore::ReferenceBase<VertexSelection >
64{
66std::string m_name;
67// map fagnr to fragsize in selection
69
70static Fiber::SkeletonID m_id;
71
72public:
74
75 void iterate( VertexSelectionIterator&VSI );
78 MemCore::RefPtr<Fiber::MemArray<1, size_t> > getSelection( unsigned ref_level, unsigned FragNr );
79
80 std::string getName()
81 {
82 return m_name;
83 }
84
85 bool empty()
86 {
87 return m_ref_to_vertex_index.empty();
88 }
89
90 // add the other selection into this one, no check for duplicate selections
91 void add( VertexSelection& vs );
92
93 // add other selection and avoid duplicates
94 void merge( const VertexSelection& vs );
95
96 void speak()
97 {
99 for( it = m_ref_to_vertex_index.begin(); it != m_ref_to_vertex_index.end(); it++ )
100 {
101 std::cout << "ref: " << it->first << ", ";
103 for( size_t i = 0; i < it->second->Size()[0]; i++ )
104 std::cout << m[i][0] << "-" << m[i][1] << " ";
106 }
107 }
108
109 bool hasRefLevel( int ref )
110 {
111 return ( m_ref_to_vertex_index.find( ref ) != m_ref_to_vertex_index.end() );
112 }
113
114 unsigned getMaxRef() // error check?
115 {
116 return m_ref_to_vertex_index.rbegin()->first;
117 }
118
119 static SkeletonID& getID( int refinement = -1 )
120 {
121 m_id.setRefinement( 0,0 );
122 if( refinement > 0)
123 m_id.setRefinement( 0, refinement );
124
125 return m_id;
126 }
127
128};
129
130
137
143extern gridop_API void growVertexSelection( MemCore::RefPtr<Fiber::Grid>& grid, MemCore::RefPtr<Fiber::MemArray<1, VertexSelection_t> >& selection, double radius );
144
146
147
148
150{
151//FragmentIDs m_fids;
154
156 : m_representation( rep )
157 {}
158
159 bool apply( const std::string&name, int ref,
161 {
162 getBoundsHelper( m_representation, selection, bb );
163 return true;
164 }
165
166
167};
168
169
171
172
173// no refinement here yet
175
176
177extern gridop_API MemCore::RefPtr<VertexSelection> getVertexSelection( MemCore::RefPtr<Fiber::Grid>& grid, const std::string& sel_name );
178
179
180extern gridop_API MemCore::RefPtr<VertexSelection> getMergedVertexSelection( const MemCore::RefPtr<Fiber::Grid>& grid, const MemCore::StringList& sel, bool reduce = false );
181
184extern gridop_API bool addVertexSelection( MemCore::RefPtr<Fiber::Grid>& grid,
185 const std::string& sel_name,
187 int refinement_level = -1 );
188
189
190
191
192//typedef std::pair<size_t,size_t> VertexSelection_t;
193
196{
197 bool m_found;
198 std::string m_name;
200
202 : m_found( false )
203 , m_name(name)
204 {}
205
208 {
209 if(!f)
210 return true;
211
212 if( f->Name() == m_name)
213 {
214 m_found = true;
215 m_selection = DC->create();
216
217 return false; // break iteration if found
218 }
219
220 return true;
221 }
222};
223
224extern gridop_API MemCore::RefPtr<Fiber::Field> getVertexSelectionPositions( MemCore::RefPtr<Fiber::Grid>& grid );
225
226
227
228
229
230
231
232
233
235extern gridop_API RefPtr<Field> getCartesianVertexField( GridSelector& gs, double time, string field_name, int ref = 0 );
236
237extern gridop_API RefPtr<Representation> getUnRefinedCartesianRepresentation( const RefPtr<Grid>& grid, double time );
238extern gridop_API RefPtr<Representation> getUnRefinedCartesianRepresentation( GridSelector& gs, double time );
239
240extern gridop_API RefPtr<Representation> getRefinedCartesianRepresentation( const RefPtr<Grid>& grid, double time, int ref );
241
242extern gridop_API RefPtr<Representation> getRefinedCartesianRepresentation( GridSelector& gs, double time, int ref );
243
244extern gridop_API RefPtr<Field> getUnRefinedCartesianVertexField( GridSelector& gs, double time, string field_name );
245extern gridop_API RefPtr<Field> getRefinedCartesianVertexField( GridSelector& gs, double time, string field_name, int ref);
246
247
248/*
249
253extern gridop_API bool addVertexSelection( MemCore::RefPtr<Fiber::Grid>& grid, const std::string& sel_name, const MemCore::RefPtr<Fiber::MemArray<1, size_t> >& sel_indices );
254
255
258extern gridop_API MemCore::RefPtr<Fiber::MemArray<1, size_t> > getVertexSelectionOld( MemCore::RefPtr<Fiber::Grid>& grid, const std::string& sel_name );
259
260*/
261
262}
263
264#endif // VERTEX_SELECTION_HPP
_Expr< _ValFunClos< _ValArray, _Tp >, _Tp > apply(_Tp __func(_Tp)) const
constexpr _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
constexpr iterator_traits< _InputIterator >::value_type reduce(_InputIterator __first, _InputIterator __last)
basic_string< char > string
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
constexpr auto empty(const _Container &__cont) noexcept(noexcept(__cont.empty())) -> decltype(__cont.empty())
ostream cout
bool empty() const noexcept
const_iterator end() const noexcept
const_iterator begin() const noexcept
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Base class for iterators over the fragments of a field.
Definition FragmentID.hpp:249
Context information to select a grid from within a bundle.
Definition GridSelector.hpp:26
Identifier for Skeletons within a Grid.
Definition SkeletonID.hpp:24
Class representing a vertex selection.
Definition VertexSelection.hpp:64
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
void fillVertexSelection(RefPtr< Grid > &grid, RefPtr< MemArray< 1, VertexSelection_t > > &selection)
Fill vertex selection by selecting all points inside the convex hull (3D) of the selection.
Definition VertexSelection.cpp:295
Definition VertexSelection.hpp:150
fragment iterator to extract a selection (fragment) from a field
Definition VertexSelection.hpp:196
Definition VertexSelection.hpp:32
Definition VertexSelection.hpp:50