0027960: Configuration - fix compilation of OSD_Directory with MinGW-w64
[occt.git] / src / NCollection / NCollection_Vec3.hxx
index 9e12deb..73b9743 100644 (file)
@@ -1,20 +1,16 @@
 // Created by: Kirill GAVRILOV
-// Copyright (c) 2012 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #ifndef _NCollection_Vec3_H__
 #define _NCollection_Vec3_H__
@@ -77,19 +73,6 @@ public:
     v[2] = Element_t(0);
   }
 
-  //! Copy constructor.
-  NCollection_Vec3 (const NCollection_Vec3& theVec3)
-  {
-    std::memcpy (this, &theVec3, sizeof(NCollection_Vec3));
-  }
-
-  //! Assignment operator.
-  const NCollection_Vec3& operator= (const NCollection_Vec3& theVec3)
-  {
-    std::memcpy (this, &theVec3, sizeof(NCollection_Vec3));
-    return *this;
-  }
-
   //! Alias to 1st component as X coordinate in XYZ.
   Element_t x() const { return v[0]; }
 
@@ -109,12 +92,12 @@ public:
   Element_t b() const { return v[2]; }
 
   //! @return 2 components by their names in specified order (in GLSL-style)
-  NCOLLECTION_VEC_COMPONENTS_2D(x, y);
-  NCOLLECTION_VEC_COMPONENTS_2D(x, z);
-  NCOLLECTION_VEC_COMPONENTS_2D(y, z);
+  NCOLLECTION_VEC_COMPONENTS_2D(x, y)
+  NCOLLECTION_VEC_COMPONENTS_2D(x, z)
+  NCOLLECTION_VEC_COMPONENTS_2D(y, z)
 
   //! @return 3 components by their names in specified order (in GLSL-style)
-  NCOLLECTION_VEC_COMPONENTS_3D(x, y, z);
+  NCOLLECTION_VEC_COMPONENTS_3D(x, y, z)
 
   //! Alias to 1st component as X coordinate in XYZ.
   Element_t& x() { return v[0]; }
@@ -238,6 +221,44 @@ public:
     return aCopyVec3;
   }
 
+  //! Compute component-wise minimum of two vectors.
+  NCollection_Vec3 cwiseMin (const NCollection_Vec3& theVec) const
+  {
+    return NCollection_Vec3 (v[0] < theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] < theVec.v[1] ? v[1] : theVec.v[1],
+                             v[2] < theVec.v[2] ? v[2] : theVec.v[2]);
+  }
+
+  //! Compute component-wise maximum of two vectors.
+  NCollection_Vec3 cwiseMax (const NCollection_Vec3& theVec) const
+  {
+    return NCollection_Vec3 (v[0] > theVec.v[0] ? v[0] : theVec.v[0],
+                             v[1] > theVec.v[1] ? v[1] : theVec.v[1],
+                             v[2] > theVec.v[2] ? v[2] : theVec.v[2]);
+  }
+
+  //! Compute component-wise modulus of the vector.
+  NCollection_Vec3 cwiseAbs() const
+  {
+    return NCollection_Vec3 (std::abs (v[0]),
+                             std::abs (v[1]),
+                             std::abs (v[2]));
+  }
+
+  //! Compute maximum component of the vector.
+  Element_t maxComp() const
+  {
+    return v[0] > v[1] ? (v[0] > v[2] ? v[0] : v[2])
+                       : (v[1] > v[2] ? v[1] : v[2]);
+  }
+
+  //! Compute minimum component of the vector.
+  Element_t minComp() const
+  {
+    return v[0] < v[1] ? (v[0] < v[2] ? v[0] : v[2])
+                       : (v[1] < v[2] ? v[1] : v[2]);
+  }
+
   //! Compute per-component division by scale factor.
   NCollection_Vec3& operator/= (const Element_t theInvFactor)
   {
@@ -250,7 +271,7 @@ public:
   //! Compute per-component division by scale factor.
   NCollection_Vec3 operator/ (const Element_t theInvFactor)
   {
-    NCollection_Vec3 aResult (this);
+    NCollection_Vec3 aResult (*this);
     return aResult /= theInvFactor;
   }