Skip to content

Commit 083e872

Browse files
author
tpat
committed
Error when no vectors given. Warning when zero vector and default to small
vector. Composite renamed to CompositeGeometryObject.
1 parent 4f4d85f commit 083e872

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

src/Graphics/Datatypes/GeometryImpl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ isClippable_(isClippable)
3939

4040
}
4141

42-
Composite::~Composite()
42+
CompositeGeometryObject::~CompositeGeometryObject()
4343
{
4444
}
4545

46-
void Composite::addToList(GeometryBaseHandle handle, GeomList& list)
46+
void CompositeGeometryObject::addToList(GeometryBaseHandle handle, GeomList& list)
4747
{
4848
if (handle.get() == this)
4949
{

src/Graphics/Datatypes/GeometryImpl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,14 @@ namespace SCIRun {
287287

288288
typedef boost::shared_ptr<GeometryObjectSpire> GeometryHandle;
289289

290-
class SCISHARE Composite : public GeometryObjectSpire
290+
class SCISHARE CompositeGeometryObject : public GeometryObjectSpire
291291
{
292292
public:
293293
template <typename GeomIter>
294-
Composite(const Core::GeometryIDGenerator& idGenerator, const std::string& tag, GeomIter begin, GeomIter end)
294+
CompositeGeometryObject(const Core::GeometryIDGenerator& idGenerator, const std::string& tag, GeomIter begin, GeomIter end)
295295
: GeometryObjectSpire(idGenerator, tag, true), geoms_(begin, end)
296296
{}
297-
~Composite();
297+
~CompositeGeometryObject();
298298
void addToList(Core::Datatypes::GeometryBaseHandle handle, Core::Datatypes::GeomList& list) override;
299299
private:
300300
std::vector<GeometryHandle> geoms_;
@@ -303,7 +303,7 @@ namespace SCIRun {
303303
template <typename GeomIter>
304304
static GeometryHandle createGeomComposite(const Core::GeometryIDGenerator& idGenerator, const std::string& tag, GeomIter begin, GeomIter end)
305305
{
306-
return boost::make_shared<Composite>(idGenerator, tag, begin, end);
306+
return boost::make_shared<CompositeGeometryObject>(idGenerator, tag, begin, end);
307307
}
308308
}
309309
}

src/Modules/Legacy/Visualization/ShowAndEditDipoles.cc

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ ShowAndEditDipoles::ShowAndEditDipoles()
102102
widgetIter_ = 0;
103103
resolution_ = 20;
104104
previousScaleFactor_ = 0.0;
105+
zeroVectorRescale_ = 1.0e-3;
105106
}
106107

107108
void ShowAndEditDipoles::setStateDefaults()
@@ -135,6 +136,11 @@ void ShowAndEditDipoles::execute()
135136
error("Input field was not a valid point cloud.");
136137
return;
137138
}
139+
else if(!fi.is_vector())
140+
{
141+
error("Input field does not contain vectors.");
142+
return;
143+
}
138144

139145
loadData();
140146

@@ -205,7 +211,26 @@ void ShowAndEditDipoles::loadData()
205211
}
206212
}
207213

208-
if(state->getValue(Sizing).toInt() == SizingType::NORMALIZE_VECTOR_DATA)
214+
bool zeroVector = false;
215+
for(int i = 0; i < scale_.size(); i++)
216+
{
217+
if(scale_[i] == 0.0)
218+
{
219+
scale_[i] = zeroVectorRescale_;
220+
direction_[i] = Vector(1, 1, 1).normal();
221+
zeroVector = true;
222+
std::cout << "zero vec resc " << zeroVectorRescale_ << std::endl;
223+
}
224+
}
225+
226+
if(zeroVector)
227+
{
228+
warning("Input data contains zero vectors.");
229+
return;
230+
}
231+
232+
if((previousSizing_ != state->getValue(Sizing).toInt() || state->getValue(Reset).toBool())
233+
&& state->getValue(Sizing).toInt() == SizingType::NORMALIZE_VECTOR_DATA)
209234
{
210235
scale_.clear();
211236
for(int i = 0; i < pos_.size(); i++)
@@ -215,6 +240,8 @@ void ShowAndEditDipoles::loadData()
215240
}
216241
}
217242

243+
244+
218245
void ShowAndEditDipoles::loadFromParameters()
219246
{
220247
auto state = get_state();
@@ -660,7 +687,7 @@ GeometryHandle ShowAndEditDipoles::addLines()
660687
// Create lines between every point
661688
for(int a = 0; a < pos_.size(); a++)
662689
{
663-
for(int b = 0; b < pos_.size(); b++)
690+
for(int b = a + 1; b < pos_.size(); b++)
664691
{
665692
glyphs.addLine(pos_[a], pos_[b], lineCol_, lineCol_);
666693
}

src/Modules/Legacy/Visualization/ShowAndEditDipoles.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ namespace SCIRun {
9696
int widgetIter_;
9797
double resolution_;
9898
double previousScaleFactor_;
99+
double zeroVectorRescale_;
99100

100101
Core::Datatypes::ColorRGB deflPointCol_;
101102
Core::Datatypes::ColorRGB deflCol_;

0 commit comments

Comments
 (0)