/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGNDDArray_HH_ #define _MGNDDArray_HH_ /** @file */ /** @addtogroup BASE * @{ */ #include "mg/MGCL.h" // MGNDDArray.h // // Forward Declaration class MGBPointSeq; class MGKnotVector; class MGKnot; class MGIfstream; class MGOfstream; ///Defines non-decreasing double data array. ///Used for data point abscissa, or knot vector, etc. ///MGNDDArray has size and effective data length. class MG_DLL_DECLR MGNDDArray{ public: ///Friend Function MG_DLL_DECLR friend MGNDDArray operator* (double scale, const MGNDDArray& nd); ///String stream Function MG_DLL_DECLR friend std::ostream& operator<< (std::ostream&, const MGNDDArray&); //////////// Constructor //////////// ///void constructor. MGNDDArray():m_capacity(0),m_length(0),m_current(0),m_element(0){;}; ///Constructor MGNDDArray of size n and lenght=n. explicit MGNDDArray( int n, ///=length(), ///original data point parameters and the multiplicities are preserved. ///Same as change_number(). MGNDDArray(const MGNDDArray&, int nnew); /// From data point, obtain data point of updated value range. ///Update so that (*this)(0)=ts, and (*this)(lenght()-1)=te. ///Must be ts tau(i-1). ///When i>=capacity(), reshape will take place. ///The data validity after i is not checked. void store_with_capacityCheck( int i, ///=start if index>=0. ///Function's return value locate_multi is actual multiplicity at the ///index, i.e. locate_multi>=multi. ///If position of the multiplicity is not found to the end, ///index=(lenght()-1) (index of the last element) and locate_multi=0 ///will be returned. ///multi must be >=1. virtual int locate_multi(int start, int multi, int& index) const; ///Update so that (*this)(0)=ts, and (*this)(lenght()-1)=te. ///Must be ts=length(), ///original data point parameters and the multiplicities are preserved. MGNDDArray& change_number(int nnew); ///Reference to i-th element. double ref(int i) const{ return m_element[i];}; ///Remove too near data points. void remove_too_near( bool allow_multi=false, ///ratio or (t(i+1)-ti)/(ti-t(i-1))<1/ratio, ///length(). bool allow_multi=false, ///ratio or (t(i+1)-ti)/(ti-t(i-1))<1/ratio, ///0, first 'start' data will be garbage. ///Original data will be held as long as the storage permits. void reshape(int size, int start=0); ///Resize the array. Result will contain garbages. ///length() and size() will have nsize. void resize(int nsize); /// Return the size of MGNDDArray. int capacity() const { return m_capacity; }; ///Obtain data point from KnotVector t and replace own with it. MGNDDArray& update_from_knot(const MGKnotVector& t); ///Dump Functions. ///Calculate dump size virtual int dump_size() const; ///Dump Function virtual int dump(MGOfstream&)const; ///Restore Function virtual int restore(MGIfstream& ); //////////// Member data ///////// protected: mutable int m_current;///