[r36927]: trunk / contrib / brl / bbas / volm / volm_vrml_io.cxx  Maximize  Restore  History

Download this file

91 lines (78 with data), 3.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <volm/volm_vrml_io.h>
#include <vcl_cmath.h>
#include <vsph/vsph_unit_sphere.h>
#include <vgl/vgl_point_3d.h>
void volm_vrml_io::display_spherical_region_by_attrbute(vcl_ostream& str ,
volm_spherical_region & region,
spherical_region_attributes att,
double factor, // this mis multipled by 1.0 and is used to display outwards or inwards of the unit sphere.
double tol)
{
float r,g,b ;
unsigned char val;
if (!region.attribute_value(att,val))
return;
r = volm_vrml_io_data::color_codes[(val)%8 ][0];
g = volm_vrml_io_data::color_codes[(val)%8][1];
b = volm_vrml_io_data::color_codes[(val)%8][2];
region.bbox_ref().display_box(str,r,g,b,tol,factor);
}
void volm_vrml_io::display_spherical_region_layer_by_attrbute(vcl_ostream& str ,
volm_spherical_regions_layer layer,
spherical_region_attributes att,
double factor, //: this is multiplied by 1.0 and is used to display outwards or inwards of the unit sphere.
double tol)
{
vcl_map<unsigned char, vcl_vector<unsigned int> > ids = layer.attributed_regions_by_type(att);
vcl_vector<volm_spherical_region> regions = layer.regions();
for (vcl_map<unsigned char, vcl_vector<unsigned int> >::iterator iter = ids.begin() ; iter!= ids.end(); ++iter)
for (unsigned i = 0; i < iter->second.size(); ++i)
volm_vrml_io::display_spherical_region_by_attrbute(str,regions[iter->second[i]],att,factor,tol);
}
void volm_vrml_io::display_segment_sphere(vcl_ostream& str ,
vsph_segment_sphere * sph,
double factor)
{
vcl_map<int, vcl_vector<int> >::const_iterator rit = sph->regions().begin();
vsph_unit_sphere usph = sph->unit_sphere();
vcl_vector<vgl_vector_3d<double> > unit_vectors = usph.cart_vectors();
vcl_vector<vgl_vector_3d<double> > points;
vcl_vector<vgl_point_3d<double> > colors;
for (; rit != sph->regions().end(); ++rit) {
const vcl_vector<int>& pt_ids = rit->second;
unsigned char val =(unsigned char) vcl_floor(sph->region_median(rit->first));
vgl_point_3d<double> pc((double) volm_vrml_io_data::color_codes[(val)%8][0], (double) volm_vrml_io_data::color_codes[(val)%8][1], (double) volm_vrml_io_data::color_codes[(val)%8][2]);
if(val > 100)
{
pc.x()=0.5;
pc.y()=1.0;
pc.z()=1.0;
}
for(unsigned i = 0 ; i < pt_ids.size(); i++)
{
points.push_back(unit_vectors[pt_ids[i]]);
colors.push_back(pc);
}
}
str<<"Transform {\n"
<<"translation 0 0 0\n"
<<"children [\n"
<<"Shape {\n"
<<"geometry PointSet {\n"
<<"coord Coordinate {\n"
<<"point [\n";
for(unsigned i = 0; i < points.size(); i++)
str<<points[i].x()<<" "<<points[i].y()<<" "<<points[i].z()<<",\n";
str<<" ]\n"
<<" }\n"
<<"color Color {\n"
<<" color [ \n";
for(unsigned i = 0; i < colors.size(); i++)
str<<colors[i].x()<<" "<<colors[i].y()<<" "<<colors[i].z()<<",\n";
str<<" ]\n"
<<" }\n"
<<" }\n"
<<" }\n"
<<"]\n"
<<"}\n";
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks