|
|
|||
File indexing completed on 2026-09-11 09:18:27
0001 // Created on: 2007-03-07 0002 // Created by: msv@EUCLIDEX 0003 // Copyright (c) 2007-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef MeshVS_Buffer_HeaderFile 0017 #define MeshVS_Buffer_HeaderFile 0018 0019 #include <Standard.hxx> 0020 #include <gp_Pnt.hxx> 0021 0022 /** 0023 * General purpose buffer that is allocated on the stack with a 0024 * constant size MeshVS_BufSize, or is allocated dynamically if the requested 0025 * size exceeds the standard one. 0026 * It is useful when an allocation of an array of unknown size is needed, 0027 * and most often the array is small enough to allocate as automatic C array. 0028 */ 0029 0030 //! define the constant to the size of 10 points 0031 #define MeshVS_BufSize 10 * 3 * sizeof(double) 0032 0033 class MeshVS_Buffer 0034 { 0035 public: 0036 //! Constructor of the buffer of the requested size 0037 MeshVS_Buffer(const size_t theSize) 0038 : myDynData(nullptr) 0039 { 0040 if (theSize > MeshVS_BufSize) 0041 myDynData = Standard::Allocate(theSize); 0042 } 0043 0044 //! Destructor 0045 ~MeshVS_Buffer() 0046 { 0047 Standard::Free(myDynData); 0048 myDynData = nullptr; 0049 } 0050 0051 //! Cast the buffer to the void pointer 0052 operator void*() { return myDynData ? myDynData : (void*)myAutoData; } 0053 0054 //! Interpret the buffer as a reference to double 0055 operator double&() { return *(myDynData ? (double*)myDynData : (double*)myAutoData); } 0056 0057 //! Interpret the buffer as a reference to int 0058 operator int&() { return *(myDynData ? (int*)myDynData : (int*)myAutoData); } 0059 0060 //! Interpret the buffer as a reference to gp_Pnt 0061 operator gp_Pnt&() { return *(myDynData ? (gp_Pnt*)myDynData : (gp_Pnt*)myAutoData); } 0062 0063 private: 0064 //! Deprecate copy constructor 0065 MeshVS_Buffer(const MeshVS_Buffer&) {} 0066 0067 //! Deprecate copy operation 0068 MeshVS_Buffer& operator=(const MeshVS_Buffer&) { return *this; } 0069 0070 char myAutoData[MeshVS_BufSize]; 0071 void* myDynData; 0072 }; 0073 0074 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|