Skip to content

Commit b704649

Browse files
author
tpat
committed
Disks now have width and radius flipped. Added torus glyphs. Reduced default
secondary vector parameter from 0.5 to 0.25
1 parent 159b86a commit b704649

File tree

3 files changed

+75
-45
lines changed

3 files changed

+75
-45
lines changed

src/Graphics/Glyphs/GlyphGeom.cc

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ void GlyphGeom::addDisk(const Point& p1, const Point& p2, double radius, int res
260260
generateCylinder(p1, p2, radius, radius, resolution, color1, color2, true, true);
261261
}
262262

263+
void GlyphGeom::addTorus(const Point& p1, const Point& p2, double major_radius, double minor_radius, int resolution,
264+
const ColorRGB& color1, const ColorRGB& color2)
265+
{
266+
generateTorus(p1, p2, major_radius, minor_radius, resolution, color1);
267+
}
268+
263269
void GlyphGeom::addCone(const Point& p1, const Point& p2, double radius, int resolution,
264270
bool render_base, const ColorRGB& color1, const ColorRGB& color2)
265271
{
@@ -1121,62 +1127,73 @@ void GlyphGeom::generateSuperEllipsoid(const Point& center, Tensor& t, double sc
11211127
for(int jj = 0; jj < 6; jj++) indices_.pop_back();
11221128
}
11231129

1124-
// template <class T>
1125-
// void GeomGlyph::gen_torus(const Point& center, const T& t,
1126-
// double major_radius, double minor_radius,
1127-
// int nu, int nv,
1128-
// std::vector< QuadStrip >& quadstrips )
1129-
// {
1130-
// nu++; //Bring nu to expected value for shape.
1130+
void GlyphGeom::generateTorus(const Point& p1, const Point& p2, double major_radius, double minor_radius,
1131+
int resolution, const ColorRGB& color)
1132+
{
1133+
std::cout << "minor, major rad: " << minor_radius << ", " << major_radius << std::endl;
1134+
int nv = resolution;
1135+
int nu = nv + 1;
11311136

1132-
// SinCosTable tab1(nu, 0, 2*M_PI);
1133-
// SinCosTable tab2(nv, 0, 2*M_PI, minor_radius);
1137+
SinCosTable tab1(nu, 0, 2*M_PI);
1138+
SinCosTable tab2(nv, 0, 2*M_PI, minor_radius);
11341139

1135-
// Transform trans;
1136-
// Transform rotate;
1137-
// gen_transforms( center, t, trans, rotate );
1140+
Transform trans;
1141+
Transform rotate;
1142+
/* Point center = p1 + (p2-p1) * 0.5; */
1143+
generateTransforms( p1, (p2-p1), trans, rotate );
11381144

11391145
// Draw the torus
1140-
// for (int v=0; v<nv-1; v++)
1141-
// {
1142-
// double z1 = tab2.cos(v+1);
1143-
// double z2 = tab2.cos(v);
1146+
for (int v=0; v<nv-1; v++)
1147+
{
1148+
double z1 = tab2.cos(v+1);
1149+
double z2 = tab2.cos(v);
11441150

1145-
// double nr1 = tab2.sin(v+1);
1146-
// double nr2 = tab2.sin(v);
1151+
double nr1 = tab2.sin(v+1);
1152+
double nr2 = tab2.sin(v);
11471153

1148-
// double r1 = major_radius + nr1;
1149-
// double r2 = major_radius + nr2;
1154+
double r1 = major_radius + nr1;
1155+
double r2 = major_radius + nr2;
11501156

1151-
// QuadStrip quadstrip;
1157+
for (int u=0; u<nu; u++)
1158+
{
1159+
uint32_t offset = static_cast<uint32_t>(numVBOElements_);
11521160

1153-
// for (int u=0; u<nu; u++)
1154-
// {
1155-
// double nx = tab1.sin(u);
1156-
// double ny = tab1.cos(u);
1161+
double nx = tab1.sin(u);
1162+
double ny = tab1.cos(u);
11571163

1158-
// double x1 = r1 * nx;
1159-
// double y1 = r1 * ny;
1164+
double x1 = r1 * nx;
1165+
double y1 = r1 * ny;
11601166

1161-
// double x2 = r2 * nx;
1162-
// double y2 = r2 * ny;
1167+
double x2 = r2 * nx;
1168+
double y2 = r2 * ny;
11631169

1164-
// Point p1 = trans * Point(x1, y1, z1);
1165-
// Point p2 = trans * Point(x2, y2, z2);
1170+
Vector p1 = Vector(trans * Point(x1, y1, z1));
1171+
Vector p2 = Vector(trans * Point(x2, y2, z2));
1172+
points_.push_back(p1);
1173+
points_.push_back(p2);
11661174

1167-
// Vector v1 = rotate * Vector(nr1*nx, nr1*ny, z1);
1168-
// Vector v2 = rotate * Vector(nr2*nx, nr2*ny, z2);
1175+
Vector v1 = rotate * Vector(nr1*nx, nr1*ny, z1);
1176+
Vector v2 = rotate * Vector(nr2*nx, nr2*ny, z2);
1177+
v1.safe_normalize();
1178+
v2.safe_normalize();
1179+
normals_.push_back(v1);
1180+
normals_.push_back(v2);
11691181

1170-
// v1.safe_normalize();
1171-
// v2.safe_normalize();
1182+
colors_.push_back(color);
1183+
colors_.push_back(color);
11721184

1173-
// quadstrip.push_back( std::make_pair(p1, v1) );
1174-
// quadstrip.push_back( std::make_pair(p2, v2) );
1175-
// }
1185+
numVBOElements_ += 2;
11761186

1177-
// quadstrips.push_back( quadstrip );
1178-
// }
1179-
// }
1187+
indices_.push_back(0 + offset);
1188+
indices_.push_back(1 + offset);
1189+
indices_.push_back(2 + offset);
1190+
indices_.push_back(2 + offset);
1191+
indices_.push_back(1 + offset);
1192+
indices_.push_back(3 + offset);
1193+
}
1194+
}
1195+
for(int jj = 0; jj < 6; jj++) indices_.pop_back();
1196+
}
11801197

11811198
void GlyphGeom::generateLine(const Point& p1, const Point& p2, const ColorRGB& color1, const ColorRGB& color2)
11821199
{

src/Graphics/Glyphs/GlyphGeom.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ namespace SCIRun {
7474
const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2);
7575
void addComet(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2, double radius, int resolution,
7676
const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2, double sphere_extrusion);
77+
void addTorus(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2, double major_radius, double minor_radius,
78+
int resolution, const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2);
7779
void addClippingPlane(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2,
7880
const Core::Geometry::Point& p3, const Core::Geometry::Point& p4, double radius, int resolution,
7981
const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2);
@@ -113,7 +115,8 @@ namespace SCIRun {
113115
void generateEllipsoid(const Core::Geometry::Point& center, Core::Geometry::Tensor& t, double scale, int resolution, const Core::Datatypes::ColorRGB& color, bool half, bool normalize);
114116
void generateSuperEllipsoid(const Core::Geometry::Point& center, Core::Geometry::Tensor& t, double scale, int resolution, const Core::Datatypes::ColorRGB& color, bool normalize, double emphasis);
115117
void generateCone(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2, double radius, int resolution, bool renderBase, const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2);
116-
/* void generateDisk(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2, double radius1, double radius2, int resolution, const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2); */
118+
void generateTorus(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2, double major_radius, double minor_radius,
119+
int resolution, const Core::Datatypes::ColorRGB& color1);
117120
void generateLine(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2, const Core::Datatypes::ColorRGB& color1, const Core::Datatypes::ColorRGB& color2);
118121
void generatePoint(const Core::Geometry::Point& p, const Core::Datatypes::ColorRGB& color);
119122
void generatePlane(const Core::Geometry::Point& p1, const Core::Geometry::Point& p2,

src/Modules/Visualization/ShowFieldGlyphs.cc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,21 @@ void GlyphBuilder::addGlyph(
190190
glyphs.addArrow(p1, p2, radius, ratio, resolution, node_color, node_color, render_base1, render_base2);
191191
break;
192192
case RenderState::GlyphType::DISK_GLYPH:
193-
glyphs.addDisk(p1, p2, radius, resolution, node_color, node_color);
193+
{
194+
Vector dir = (p2 - p1);
195+
Point new_p2 = p1 + dir * radius * 2.0;
196+
glyphs.addDisk(p1, new_p2, dir.length()*0.5, resolution, node_color, node_color);
194197
break;
198+
}
195199
case RenderState::GlyphType::RING_GLYPH:
196-
BOOST_THROW_EXCEPTION(AlgorithmInputException() << ErrorMessage("Ring Geom is not supported yet."));
200+
{
201+
// double torusRatio = 6.0;
202+
double length = (p2 - p1).length();
203+
double major_radius = length * 0.5;
204+
double minor_radius = length * radius * 2.0;
205+
glyphs.addTorus(p1, p2, major_radius, minor_radius, resolution, node_color, node_color);
197206
break;
207+
}
198208
case RenderState::GlyphType::SPRING_GLYPH:
199209
BOOST_THROW_EXCEPTION(AlgorithmInputException() << ErrorMessage("Spring Geom is not supported yet."));
200210
break;
@@ -237,7 +247,7 @@ void ShowFieldGlyphs::setStateDefaults()
237247
// state->setValue(VectorsTransparencyDataInput, std::string("Primary"));
238248
state->setValue(SecondaryVectorParameterScalingType, SecondaryVectorParameterScalingTypeEnum::USE_INPUT);
239249
state->setValue(SecondaryVectorParameterDataInput, std::string("Primary"));
240-
state->setValue(SecondaryVectorParameterScale, 0.5);
250+
state->setValue(SecondaryVectorParameterScale, 0.25);
241251
state->setValue(NormalizeVectors, false);
242252
state->setValue(VectorsScale, 1.0);
243253
state->setValue(RenderVectorsBelowThreshold, true);

0 commit comments

Comments
 (0)