[Liblas-commits] hg: manage dimension size in cases of default
construction
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Aug 3 12:17:19 EDT 2010
changeset bedacdc8457f in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=bedacdc8457f
summary: manage dimension size in cases of default construction
diffstat:
include/liblas/lasbounds.hpp | 24 ++++------------------
src/lasbounds.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 19 deletions(-)
diffs (107 lines):
diff -r 8278174840f5 -r bedacdc8457f include/liblas/lasbounds.hpp
--- a/include/liblas/lasbounds.hpp Tue Aug 03 10:33:48 2010 -0500
+++ b/include/liblas/lasbounds.hpp Tue Aug 03 11:17:12 2010 -0500
@@ -62,29 +62,15 @@
Bounds(Bounds const& other);
Bounds& operator=(Bounds const& rhs);
- double min(std::size_t const& index) const
- {
- return mins[index];
- }
-
- void min(std::size_t const& index, double v)
- {
- mins[index] = v;
- }
-
- double max(std::size_t const& index) const
- {
- return maxs[index];
- }
+ double min(std::size_t const& index) const;
+ void min(std::size_t const& index, double v);
+ double max(std::size_t const& index) const;
+ void max(std::size_t const& index, double v);
- void max(std::size_t const& index, double v)
- {
- maxs[index] = v;
- }
-
bool equal(Bounds const& other) const;
bool intersects(Bounds const& other) const;
uint32_t dimension() const;
+ void dimension(uint32_t d);
private:
Vector mins;
diff -r 8278174840f5 -r bedacdc8457f src/lasbounds.cpp
--- a/src/lasbounds.cpp Tue Aug 03 10:33:48 2010 -0500
+++ b/src/lasbounds.cpp Tue Aug 03 11:17:12 2010 -0500
@@ -140,12 +140,47 @@
#endif
}
+
Bounds::Bounds(Bounds const& other)
: mins(other.mins)
, maxs(other.maxs)
{
}
+double Bounds::min(std::size_t const& index) const
+{
+ if (mins.size() <= index) {
+ return 0.0;
+ }
+ return mins[index];
+}
+
+void Bounds::min(std::size_t const& index, double v)
+{
+ if (mins.size() <= index) {
+ mins.resize(index + 1);
+ maxs.resize(index + 1);
+ }
+ mins[index] = v;
+}
+
+double Bounds::max(std::size_t const& index) const
+{
+ if (maxs.size() <= index) {
+ return 0.0;
+ }
+ return maxs[index];
+}
+
+void Bounds::max(std::size_t const& index, double v)
+{
+ if (maxs.size() <= index) {
+ maxs.resize(index + 1);
+ mins.resize(index + 1);
+ }
+ maxs[index] = v;
+}
+
Bounds& Bounds::operator=(Bounds const& rhs)
{
if (&rhs != this)
@@ -160,6 +195,17 @@
{
return mins.size();
}
+
+void Bounds::dimension(uint32_t d)
+{
+ if (maxs.size() < d) {
+ maxs.resize(d);
+ }
+ if (mins.size() < d){
+ mins.resize(d);
+ }
+}
+
void Bounds::verify()
{
for (uint32_t d = 0; d < dimension(); ++d)
More information about the Liblas-commits
mailing list