43 #ifdef RINGMESH_WITH_GRAPHICS 56 template < index_t DIMENSION >
57 GeoModelGfxEntity< DIMENSION >::GeoModelGfxEntity(
58 GeoModelGfx< DIMENSION >& gfx )
63 template < index_t DIMENSION >
64 void GeoModelGfxEntity< DIMENSION >::set_scalar_attribute(
65 GEO::MeshElementsFlags subelements,
66 const std::string& name,
69 GLuint colormap_texture )
71 for( std::unique_ptr< MeshEntityGfx< DIMENSION > >& e : entities_ )
73 e->set_scalar_attribute(
74 subelements, name, attr_min, attr_max, colormap_texture );
78 template < index_t DIMENSION >
79 void GeoModelGfxEntity< DIMENSION >::unset_scalar_attribute()
81 for( std::unique_ptr< MeshEntityGfx< DIMENSION > >& e : entities_ )
83 e->unset_scalar_attribute();
87 template < index_t DIMENSION >
88 void GeoModelGfxEntity< DIMENSION >::set_vertex_visibility(
91 for(
auto e : range( entities_.size() ) )
93 set_vertex_visibility( e, is_visible );
97 template < index_t DIMENSION >
98 void GeoModelGfxEntity< DIMENSION >::set_vertex_visibility(
99 index_t entity_id,
bool is_visible )
101 entities_[entity_id]->set_vertex_visible( is_visible );
104 template < index_t DIMENSION >
105 void GeoModelGfxEntity< DIMENSION >::set_vertex_color(
106 float red,
float green,
float blue )
108 for(
auto e : range( entities_.size() ) )
110 set_vertex_color( e, red, green, blue );
114 template < index_t DIMENSION >
115 void GeoModelGfxEntity< DIMENSION >::set_vertex_color(
116 index_t entity_id,
float red,
float green,
float blue )
118 entities_[entity_id]->set_vertex_color( red, green, blue );
121 template < index_t DIMENSION >
122 void GeoModelGfxEntity< DIMENSION >::set_vertex_size( index_t s )
124 for(
auto e : range( entities_.size() ) )
126 set_vertex_size( e, s );
130 template < index_t DIMENSION >
131 void GeoModelGfxEntity< DIMENSION >::set_vertex_size(
132 index_t entity_id, index_t s )
134 entities_[entity_id]->set_vertex_size( s );
139 template < index_t DIMENSION >
140 CornerGfxEntity< DIMENSION >::CornerGfxEntity(
141 GeoModelGfx< DIMENSION >& gfx )
142 : GeoModelGfxEntity< DIMENSION >( gfx )
146 template < index_t DIMENSION >
147 PointSetMeshGfx< DIMENSION >& CornerGfxEntity< DIMENSION >::corner(
151 return static_cast< PointSetMeshGfx< DIMENSION >&
>(
152 *this->entities_[corner_id] );
155 template < index_t DIMENSION >
156 void CornerGfxEntity< DIMENSION >::initialize()
158 if( this->entities_.empty() )
160 this->entities_.reserve( this->gfx_.geomodel()->nb_corners() );
161 for(
const auto& corner : this->gfx_.geomodel()->corners() )
163 this->entities_.push_back(
164 PointSetMeshGfx< DIMENSION >::create_gfx( corner.mesh() ) );
169 template < index_t DIMENSION >
170 void CornerGfxEntity< DIMENSION >::draw()
172 for(
auto c : range( this->entities_.size() ) )
174 PointSetMeshGfx< DIMENSION >& pointset = corner( c );
175 if( pointset.get_vertex_visible() )
176 pointset.draw_vertices();
182 template < index_t DIMENSION >
183 LineGfxEntity< DIMENSION >::LineGfxEntity( GeoModelGfx< DIMENSION >& gfx )
184 : GeoModelGfxEntity< DIMENSION >( gfx )
188 template < index_t DIMENSION >
189 LineMeshGfx< DIMENSION >& LineGfxEntity< DIMENSION >::line(
193 return static_cast< LineMeshGfx< DIMENSION >&
>(
194 *this->entities_[line_id] );
197 template < index_t DIMENSION >
198 void LineGfxEntity< DIMENSION >::initialize()
200 if( this->entities_.empty() )
202 this->entities_.reserve( this->gfx_.geomodel()->nb_lines() );
203 for(
const auto& line : this->gfx_.geomodel()->lines() )
205 this->entities_.push_back(
206 LineMeshGfx< DIMENSION >::create_gfx( line.mesh() ) );
211 template < index_t DIMENSION >
212 void LineGfxEntity< DIMENSION >::draw()
214 for(
auto l : range( this->entities_.size() ) )
216 LineMeshGfx< DIMENSION >& line = this->line( l );
217 if( line.get_vertex_visible() )
218 line.draw_vertices();
219 if( line.get_edge_visible() )
224 template < index_t DIMENSION >
225 void LineGfxEntity< DIMENSION >::set_line_color(
226 float red,
float green,
float blue )
228 for(
auto l : range( this->entities_.size() ) )
230 set_line_color( l, red, green, blue );
234 template < index_t DIMENSION >
235 void LineGfxEntity< DIMENSION >::set_line_color(
236 index_t line_id,
float red,
float green,
float blue )
238 line( line_id ).set_edge_color( red, green, blue );
241 template < index_t DIMENSION >
242 void LineGfxEntity< DIMENSION >::set_line_visibility(
bool is_visible )
244 for(
auto l : range( this->entities_.size() ) )
246 set_line_visibility( l, is_visible );
250 template < index_t DIMENSION >
251 void LineGfxEntity< DIMENSION >::set_line_visibility(
252 index_t line_id,
bool is_visible )
254 line( line_id ).set_edge_visible( is_visible );
257 template < index_t DIMENSION >
258 void LineGfxEntity< DIMENSION >::set_line_size( index_t size )
260 for(
auto l : range( this->entities_.size() ) )
262 set_line_size( l, size );
266 template < index_t DIMENSION >
267 void LineGfxEntity< DIMENSION >::set_line_size(
268 index_t line_id, index_t size )
270 line( line_id ).set_edge_width( size );
275 template < index_t DIMENSION >
276 SurfaceGfxEntity< DIMENSION >::SurfaceGfxEntity(
277 GeoModelGfx< DIMENSION >& gfx )
278 : GeoModelGfxEntity< DIMENSION >( gfx )
282 template < index_t DIMENSION >
283 SurfaceMeshGfx< DIMENSION >& SurfaceGfxEntity< DIMENSION >::surface(
287 return static_cast< SurfaceMeshGfx< DIMENSION >&
>(
288 *this->entities_[surface_id] );
291 template < index_t DIMENSION >
292 void SurfaceGfxEntity< DIMENSION >::initialize()
294 if( this->entities_.empty() )
296 this->entities_.reserve( this->gfx_.geomodel()->nb_surfaces() );
297 for(
const auto& surface : this->gfx_.geomodel()->surfaces() )
299 this->entities_.push_back(
300 SurfaceMeshGfx< DIMENSION >::create_gfx( surface.mesh() ) );
305 template < index_t DIMENSION >
306 void SurfaceGfxEntity< DIMENSION >::draw()
308 for(
auto s : range( this->entities_.size() ) )
310 SurfaceMeshGfx< DIMENSION >& surface = this->surface( s );
311 if( surface.get_vertex_visible() )
312 surface.draw_vertices();
313 if( surface.get_surface_visible() )
314 surface.draw_surface();
318 template < index_t DIMENSION >
319 void SurfaceGfxEntity< DIMENSION >::set_surface_color(
320 float red,
float green,
float blue )
322 for(
auto s : range( this->entities_.size() ) )
324 set_surface_color( s, red, green, blue );
328 template < index_t DIMENSION >
329 void SurfaceGfxEntity< DIMENSION >::set_surface_color(
330 index_t surface_id,
float red,
float green,
float blue )
332 surface( surface_id ).set_surface_color( red, green, blue );
335 template < index_t DIMENSION >
336 void SurfaceGfxEntity< DIMENSION >::set_backface_surface_color(
337 float red,
float green,
float blue )
339 for(
auto s : range( this->entities_.size() ) )
341 set_backface_surface_color( s, red, green, blue );
345 template < index_t DIMENSION >
346 void SurfaceGfxEntity< DIMENSION >::set_backface_surface_color(
347 index_t surface_id,
float red,
float green,
float blue )
349 surface( surface_id ).set_backface_surface_color( red, green, blue );
352 template < index_t DIMENSION >
353 void SurfaceGfxEntity< DIMENSION >::set_surface_visibility(
356 for(
auto s : range( this->entities_.size() ) )
358 set_surface_visibility( s, is_visible );
362 template < index_t DIMENSION >
363 void SurfaceGfxEntity< DIMENSION >::set_surface_visibility(
364 index_t surface_id,
bool is_visible )
366 surface( surface_id ).set_surface_visible( is_visible );
369 template < index_t DIMENSION >
370 void SurfaceGfxEntity< DIMENSION >::set_mesh_color(
371 float red,
float green,
float blue )
373 for(
auto s : range( this->entities_.size() ) )
375 set_mesh_color( s, red, green, blue );
379 template < index_t DIMENSION >
380 void SurfaceGfxEntity< DIMENSION >::set_mesh_color(
381 index_t surface_id,
float red,
float green,
float blue )
383 surface( surface_id ).set_mesh_color( red, green, blue );
386 template < index_t DIMENSION >
387 void SurfaceGfxEntity< DIMENSION >::set_mesh_visibility(
bool is_visible )
389 for(
auto s : range( this->entities_.size() ) )
391 set_mesh_visibility( s, is_visible );
395 template < index_t DIMENSION >
396 void SurfaceGfxEntity< DIMENSION >::set_mesh_visibility(
397 index_t surface_id,
bool is_visible )
399 surface( surface_id ).set_mesh_visibility( is_visible );
402 template < index_t DIMENSION >
403 void SurfaceGfxEntity< DIMENSION >::set_mesh_size( index_t size )
405 for(
auto s : range( this->entities_.size() ) )
407 set_mesh_size( s, size );
411 template < index_t DIMENSION >
412 void SurfaceGfxEntity< DIMENSION >::set_mesh_size(
413 index_t surface_id, index_t size )
415 surface( surface_id ).set_mesh_width( size );
420 template < index_t DIMENSION >
421 RegionGfxEntity< DIMENSION >::RegionGfxEntity( GeoModelGfx3D& gfx )
422 : GeoModelGfxEntity< DIMENSION >( gfx )
426 template < index_t DIMENSION >
427 VolumeMeshGfx< DIMENSION >& RegionGfxEntity< DIMENSION >::region(
431 return static_cast< VolumeMeshGfx< DIMENSION >&
>(
432 *entities_[region_id] );
435 template < index_t DIMENSION >
436 void RegionGfxEntity< DIMENSION >::initialize()
438 if( entities_.empty() )
440 entities_.reserve( gfx_.geomodel()->nb_regions() );
441 for(
const auto& region : gfx_.geomodel()->regions() )
444 VolumeMeshGfx< DIMENSION >::create_gfx( region.mesh() ) );
449 template < index_t DIMENSION >
450 void RegionGfxEntity< DIMENSION >::draw()
452 for(
auto r : range( entities_.size() ) )
454 VolumeMeshGfx< DIMENSION >& region = this->region( r );
455 if( region.get_vertex_visible() )
456 region.draw_vertices();
457 if( region.get_region_visible() )
458 region.draw_volume();
462 template < index_t DIMENSION >
463 void RegionGfxEntity< DIMENSION >::set_mesh_color(
464 float red,
float green,
float blue )
466 for(
auto r : range( entities_.size() ) )
468 set_mesh_color( r, red, green, blue );
472 template < index_t DIMENSION >
473 void RegionGfxEntity< DIMENSION >::set_mesh_color(
474 index_t region_id,
float red,
float green,
float blue )
476 region( region_id ).set_mesh_color( red, green, blue );
479 template < index_t DIMENSION >
480 void RegionGfxEntity< DIMENSION >::set_cell_colors_by_type()
482 for(
auto r : range( entities_.size() ) )
484 set_cell_colors_by_type( r );
488 template < index_t DIMENSION >
489 void RegionGfxEntity< DIMENSION >::set_draw_cells(
CellType type,
bool x )
491 for(
auto r : range( entities_.size() ) )
493 set_draw_cells( r, type, x );
497 template < index_t DIMENSION >
498 void RegionGfxEntity< DIMENSION >::set_draw_cells(
499 index_t region_id,
CellType type,
bool x )
501 region( region_id ).set_draw_cells( type, x );
504 template < index_t DIMENSION >
505 void RegionGfxEntity< DIMENSION >::set_cell_colors_by_type(
508 region( region_id ).set_cell_colors_by_type();
511 template < index_t DIMENSION >
512 void RegionGfxEntity< DIMENSION >::set_mesh_visibility(
bool is_visible )
514 for(
auto r : range( entities_.size() ) )
516 set_mesh_visibility( r, is_visible );
520 template < index_t DIMENSION >
521 void RegionGfxEntity< DIMENSION >::set_mesh_visibility(
522 index_t region_id,
bool is_visible )
524 region( region_id ).set_mesh_visibility( is_visible );
527 template < index_t DIMENSION >
528 void RegionGfxEntity< DIMENSION >::set_mesh_size( index_t size )
530 for(
auto r : range( entities_.size() ) )
532 set_mesh_size( r, size );
536 template < index_t DIMENSION >
537 void RegionGfxEntity< DIMENSION >::set_mesh_size(
538 index_t region_id, index_t size )
540 region( region_id ).set_mesh_width( size );
543 template < index_t DIMENSION >
544 void RegionGfxEntity< DIMENSION >::set_region_color(
545 float red,
float green,
float blue )
547 for(
auto r : range( entities_.size() ) )
549 set_region_color( r, red, green, blue );
553 template < index_t DIMENSION >
554 void RegionGfxEntity< DIMENSION >::set_region_color(
555 index_t region_id,
float red,
float green,
float blue )
557 region( region_id ).set_cells_color( red, green, blue );
560 template < index_t DIMENSION >
561 void RegionGfxEntity< DIMENSION >::set_region_visibility(
bool is_visible )
563 for(
auto r : range( entities_.size() ) )
565 set_region_visibility( r, is_visible );
569 template < index_t DIMENSION >
570 void RegionGfxEntity< DIMENSION >::set_region_visibility(
571 index_t region_id,
bool is_visible )
573 region( region_id ).set_region_visible( is_visible );
576 template < index_t DIMENSION >
577 void RegionGfxEntity< DIMENSION >::set_cell_type_visibility(
580 for(
auto r : range( entities_.size() ) )
582 set_cell_type_visibility( r, t, is_visible );
586 template < index_t DIMENSION >
587 void RegionGfxEntity< DIMENSION >::set_cell_type_visibility(
588 index_t region_id,
CellType t,
bool is_visible )
590 region( region_id ).set_draw_cells( t, is_visible );
593 template < index_t DIMENSION >
594 void RegionGfxEntity< DIMENSION >::set_shrink(
double shrink )
596 for(
auto r : range( entities_.size() ) )
598 set_shrink( r, shrink );
602 template < index_t DIMENSION >
603 void RegionGfxEntity< DIMENSION >::set_shrink(
604 index_t region_id,
double shrink )
606 region( region_id ).set_shrink( shrink );
609 template class RINGMESH_API GeoModelGfxEntity< 2 >;
610 template class RINGMESH_API CornerGfxEntity< 2 >;
611 template class RINGMESH_API LineGfxEntity< 2 >;
612 template class RINGMESH_API SurfaceGfxEntity< 2 >;
614 template class RINGMESH_API GeoModelGfxEntity< 3 >;
615 template class RINGMESH_API CornerGfxEntity< 3 >;
616 template class RINGMESH_API LineGfxEntity< 3 >;
617 template class RINGMESH_API SurfaceGfxEntity< 3 >;
618 template class RINGMESH_API RegionGfxEntity< 3 >;
#define ringmesh_assert(x)
Classes to build GeoModel from various inputs.