Skip to content

Commit f897f86

Browse files
author
tpat
committed
Added generate points function for boxes
1 parent 96cb0d4 commit f897f86

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/Graphics/Glyphs/GlyphGeom.cc

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,22 @@ void reorderTensor(std::vector<Vector>& eigvectors, Vector& eigvals)
749749
}
750750
}
751751

752+
std::vector<Vector> GlyphGeom::generateBoxPoints(Transform& trans, Vector& eigvals)
753+
{
754+
std::vector<Vector> box_points;
755+
for(int x : {-1, 1})
756+
{
757+
for(int y : {-1, 1})
758+
{
759+
for(int z : {-1, 1})
760+
{
761+
box_points.emplace_back(trans * Point(x * eigvals.x(), y * eigvals.y(), z * eigvals.z()));
762+
}
763+
}
764+
}
765+
return box_points;
766+
}
767+
752768
void GlyphGeom::generateBox(const Point& center, Tensor& t, double scale, ColorRGB& node_color, bool normalize)
753769
{
754770
static const double zeroThreshold = 0.000001;
@@ -799,19 +815,7 @@ void GlyphGeom::generateBox(const Point& center, Tensor& t, double scale, ColorR
799815
Transform trans, rotate;
800816
generateTransforms(center, eigvectors[0], eigvectors[1], eigvectors[2], trans, rotate);
801817

802-
// Rotate and translate points
803-
std::vector<Vector> box_points;
804-
for(int x : {-1, 1})
805-
{
806-
for(int y : {-1, 1})
807-
{
808-
for(int z : {-1, 1})
809-
{
810-
box_points.emplace_back(trans * Point(x * eigvals.x(), y * eigvals.y(), z * eigvals.z()));
811-
}
812-
}
813-
}
814-
818+
std::vector<Vector> box_points = generateBoxPoints(trans, eigvals);
815819
std::vector<Vector> column_vectors = rotate.get_column_vectors();
816820

817821
generateBoxSide(box_points[5], box_points[4], box_points[7], box_points[6], column_vectors[0], node_color);

src/Graphics/Glyphs/GlyphGeom.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ namespace SCIRun {
108108

109109
void generateCylinder(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);
110110
void generateSphere(const Core::Geometry::Point& center, double radius, int resolution, const Core::Datatypes::ColorRGB& color);
111+
std::vector<Core::Geometry::Vector> generateBoxPoints(Core::Geometry::Transform& trans, Core::Geometry::Vector& eigvals);
111112
void generateBox(const Core::Geometry::Point& center, Core::Geometry::Tensor& t, double scale, Core::Datatypes::ColorRGB& node_color, bool normalize);
112113
void generateBoxSide(const Core::Geometry::Vector& p1, const Core::Geometry::Vector& p2,
113114
const Core::Geometry::Vector& p3, const Core::Geometry::Vector& p4,

0 commit comments

Comments
 (0)