// Created by: Kirill GAVRILOV
-// Copyright (c) 2014 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
v[1] = theY;
}
- //! Copy constructor.
- NCollection_Vec2 (const NCollection_Vec2& theVec2)
+ //! Assign new values to the vector.
+ void SetValues (const Element_t theX,
+ const Element_t theY)
{
- v[0] = theVec2[0];
- v[1] = theVec2[1];
- }
-
- //! Assignment operator.
- const NCollection_Vec2& operator= (const NCollection_Vec2& theVec2)
- {
- v[0] = theVec2[0];
- v[1] = theVec2[1];
- return *this;
+ v[0] = theX;
+ v[1] = theY;
}
//! Alias to 1st component as X coordinate in XY.
Element_t y() const { return v[1]; }
//! @return 2 components by their names in specified order (in GLSL-style)
- NCOLLECTION_VEC_COMPONENTS_2D(x, y);
+ NCOLLECTION_VEC_COMPONENTS_2D(x, y)
//! Alias to 1st component as X coordinate in XY.
Element_t& x() { return v[0]; }
//! Alias to 2nd component as Y coordinate in XY.
Element_t& y() { return v[1]; }
+ //! Check this vector with another vector for equality (without tolerance!).
+ bool IsEqual (const NCollection_Vec2& theOther) const
+ {
+ return v[0] == theOther.v[0]
+ && v[1] == theOther.v[1];
+ }
+
+ //! Check this vector with another vector for equality (without tolerance!).
+ bool operator== (const NCollection_Vec2& theOther) { return IsEqual (theOther); }
+ bool operator== (const NCollection_Vec2& theOther) const { return IsEqual (theOther); }
+
+ //! Check this vector with another vector for non-equality (without tolerance!).
+ bool operator!= (const NCollection_Vec2& theOther) { return !IsEqual (theOther); }
+ bool operator!= (const NCollection_Vec2& theOther) const { return !IsEqual (theOther); }
+
//! Raw access to the data (for OpenGL exchange).
const Element_t* GetData() const { return v; }
Element_t* ChangeData() { return v; }
v[1] * theFactor);
}
+ //! Compute component-wise minimum of two vectors.
+ NCollection_Vec2 cwiseMin (const NCollection_Vec2& theVec) const
+ {
+ return NCollection_Vec2 (v[0] < theVec.v[0] ? v[0] : theVec.v[0],
+ v[1] < theVec.v[1] ? v[1] : theVec.v[1]);
+ }
+
+ //! Compute component-wise maximum of two vectors.
+ NCollection_Vec2 cwiseMax (const NCollection_Vec2& theVec) const
+ {
+ return NCollection_Vec2 (v[0] > theVec.v[0] ? v[0] : theVec.v[0],
+ v[1] > theVec.v[1] ? v[1] : theVec.v[1]);
+ }
+
+ //! Compute component-wise modulus of the vector.
+ NCollection_Vec2 cwiseAbs() const
+ {
+ return NCollection_Vec2 (std::abs (v[0]),
+ std::abs (v[1]));
+ }
+
+ //! Compute maximum component of the vector.
+ Element_t maxComp() const
+ {
+ return v[0] > v[1] ? v[0] : v[1];
+ }
+
+ //! Compute minimum component of the vector.
+ Element_t minComp() const
+ {
+ return v[0] < v[1] ? v[0] : v[1];
+ }
+
//! Compute per-component multiplication by scale factor.
NCollection_Vec2& operator*= (const Element_t theFactor)
{