diff --git a/MbDCode/Array.h b/MbDCode/Array.h index b0277b8..45cb164 100644 --- a/MbDCode/Array.h +++ b/MbDCode/Array.h @@ -1,5 +1,6 @@ #pragma once #include +#include namespace MbD { template @@ -9,10 +10,10 @@ namespace MbD { Array(){} Array(int i) : std::vector(i) {} Array(std::initializer_list list) : std::vector{ list } {} - void copy(Array* x); + void copy(std::shared_ptr> x); }; template - inline void Array::copy(Array* x) + inline void Array::copy(std::shared_ptr> x) { for (int i = 0; i < x->size(); i++) { this->at(i) = x->at(i); diff --git a/MbDCode/EndFramec.h b/MbDCode/EndFramec.h index 454d7f3..5dcab49 100644 --- a/MbDCode/EndFramec.h +++ b/MbDCode/EndFramec.h @@ -16,7 +16,7 @@ namespace MbD { MarkerFrame* markerFrame; FullColumn* rOeO = new FullColumn(3); - FullMatrix* aAOe = new FullMatrix(3, 3); + FullMatDptr aAOe = std::make_shared>(3, 3); }; } diff --git a/MbDCode/EndFrameqc.h b/MbDCode/EndFrameqc.h index 848ec5c..f3c0e01 100644 --- a/MbDCode/EndFrameqc.h +++ b/MbDCode/EndFrameqc.h @@ -4,13 +4,14 @@ #include "FullMatrix.h" namespace MbD { + class EndFramec; class EndFrameqc : public EndFramec { //prOeOpE pprOeOpEpE pAOepE ppAOepEpE public: EndFrameqc(); - FullMatrix* prOeOpE = new FullMatrix(3, 4); + FullMatDptr prOeOpE = std::make_shared>(3, 4); FullMatrix>* pprOeOpEpE = new FullMatrix>(3, 4); FullColumn>* pAOepE = new FullColumn>(4); FullMatrix>* ppAOepEpE = new FullMatrix>(4, 4); diff --git a/MbDCode/FullColumn.h b/MbDCode/FullColumn.h index 70c13e3..e418c02 100644 --- a/MbDCode/FullColumn.h +++ b/MbDCode/FullColumn.h @@ -12,3 +12,4 @@ namespace MbD { }; } +typedef std::shared_ptr> FullColDptr; diff --git a/MbDCode/FullMatrix.cpp b/MbDCode/FullMatrix.cpp index 2c252f2..f5284fc 100644 --- a/MbDCode/FullMatrix.cpp +++ b/MbDCode/FullMatrix.cpp @@ -4,7 +4,7 @@ using namespace MbD; FullMatrix::FullMatrix(int m, int n) { for (int i = 0; i < m; i++) { - auto* row = new FullRow(n); + auto row = std::make_shared>(n); this->push_back(row); } } diff --git a/MbDCode/FullMatrix.h b/MbDCode/FullMatrix.h index 05bc320..97e425b 100644 --- a/MbDCode/FullMatrix.h +++ b/MbDCode/FullMatrix.h @@ -4,7 +4,7 @@ namespace MbD { template - class FullMatrix : public RowTypeMatrix*> + class FullMatrix : public RowTypeMatrix>> { public: FullMatrix() { @@ -15,3 +15,4 @@ namespace MbD { }; } +typedef std::shared_ptr> FullMatDptr; diff --git a/MbDCode/FullRow.h b/MbDCode/FullRow.h index b9498c5..222e645 100644 --- a/MbDCode/FullRow.h +++ b/MbDCode/FullRow.h @@ -11,3 +11,4 @@ namespace MbD { }; } +typedef std::shared_ptr> FullRowDptr; diff --git a/MbDCode/MarkerFrame.cpp b/MbDCode/MarkerFrame.cpp index ed2b4c8..2112ab5 100644 --- a/MbDCode/MarkerFrame.cpp +++ b/MbDCode/MarkerFrame.cpp @@ -16,12 +16,12 @@ void MarkerFrame::setPartFrame(PartFrame* partFrm) partFrame = partFrm; } -void MarkerFrame::setrpmp(FullColumn* x) +void MarkerFrame::setrpmp(FullColDptr x) { rpmp->copy(x); } -void MarkerFrame::setaApm(FullMatrix* x) +void MarkerFrame::setaApm(FullMatDptr x) { aApm->copy(x); } diff --git a/MbDCode/MarkerFrame.h b/MbDCode/MarkerFrame.h index d351576..eaecba9 100644 --- a/MbDCode/MarkerFrame.h +++ b/MbDCode/MarkerFrame.h @@ -17,16 +17,16 @@ namespace MbD { public: MarkerFrame(); void setPartFrame(PartFrame* partFrm); - void setrpmp(FullColumn* x); - void setaApm(FullMatrix* x); + void setrpmp(FullColDptr x); + void setaApm(FullMatDptr x); void addEndFrame(std::shared_ptr x); PartFrame* partFrame; - FullColumn* rpmp = new FullColumn(3); - FullMatrix* aApm = new FullMatrix(3, 3); - FullColumn* rOmO = new FullColumn(3); - FullMatrix* aAOm = new FullMatrix(3, 3); - FullMatrix* prOmOpE = new FullMatrix(3, 4); + FullColDptr rpmp = std::make_shared>(3); + FullMatDptr aApm = std::make_shared>(3, 3); + FullColDptr rOmO = std::make_shared>(3); + FullMatDptr aAOm = std::make_shared>(3, 3); + FullMatDptr prOmOpE = std::make_shared>(3, 4); FullColumn>* pAOmpE = new FullColumn>(4); std::vector> endFrames; diff --git a/MbDCode/MbDCode.cpp b/MbDCode/MbDCode.cpp index 47534f3..0a4f8b1 100644 --- a/MbDCode/MbDCode.cpp +++ b/MbDCode/MbDCode.cpp @@ -14,20 +14,23 @@ int main() std::string str = "TheSystem"; TheSystem.setName(str); std::cout << "TheSystem.getName() " << TheSystem.getName() << std::endl; - FullColumn* qX, * qE; - FullColumn* rpmp; - FullMatrix* aApm; - FullRow* fullRow; - auto row = new FullRow{ 0, 0, 0, 1 }; - fullRow = new FullRow(4); + FullColDptr qX, qE; + FullColDptr rpmp; + FullMatDptr aApm; + FullRowDptr fullRow; + auto elements = { 0.0, 0.0, 0.0, 1.0 }; + auto row = std::make_shared>(elements); + fullRow = std::make_shared>(4); fullRow->copy(row); // auto assembly1 = std::make_shared(); str = "Assembly1"; assembly1->setName(str); std::cout << "assembly1->getName() " << assembly1->getName() << std::endl; - qX = new FullColumn{ 0, 0, 0 }; - qE = new FullColumn{ 0, 0, 0, 1 }; + elements = { 0, 0, 0 }; + qX = std::make_shared>(elements); + elements = { 0, 0, 0, 1 }; + qE = std::make_shared>(elements); assembly1->setqX(qX); assembly1->setqE(qE); std::cout << "assembly1->getqX() " << assembly1->getqX()->toString() << std::endl; @@ -37,14 +40,18 @@ int main() auto marker1 = std::make_shared(); str = "Marker1"; marker1->setName(str); - rpmp = new FullColumn{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + rpmp = std::make_shared>(elements); marker1->setrpmp(rpmp); - aApm = new FullMatrix(); - fullRow = new FullRow{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + aApm = std::make_shared>(); + elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + fullRow = std::make_shared>(elements); aApm->push_back(fullRow); - fullRow = new FullRow{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + fullRow = std::make_shared>(elements); aApm->push_back(fullRow); - fullRow = new FullRow{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + fullRow = std::make_shared>(elements); aApm->push_back(fullRow); marker1->setaApm(aApm); assembly1->partFrame->addMarkerFrame(marker1); @@ -52,14 +59,18 @@ int main() auto marker2 = std::make_shared(); str = "Marker2"; marker2->setName(str); - rpmp = new FullColumn{ 0.0, 0.0, 0.0 }; + elements = { 0.0, 0.0, 0.0 }; + rpmp = std::make_shared>(elements); marker2->setrpmp(rpmp); - aApm = new FullMatrix(); - fullRow = new FullRow{ 1.0, 0.0, 0.0 }; + aApm = std::make_shared>(); + elements = { 1.0, 0.0, 0.0 }; + fullRow = std::make_shared>(elements); aApm->push_back(fullRow); - fullRow = new FullRow{ 0.0, 1.0, 0.0 }; + elements = { 0.0, 1.0, 0.0 }; + fullRow = std::make_shared>(elements); aApm->push_back(fullRow); - fullRow = new FullRow{ 0.0, 0.0, 1.0 }; + elements = { 0.0, 0.0, 1.0 }; + fullRow = std::make_shared>(elements); aApm->push_back(fullRow); marker2->setaApm(aApm); assembly1->partFrame->addMarkerFrame(marker2); @@ -68,8 +79,10 @@ int main() auto part1 = std::make_shared(); str = "Part1"; part1->setName(str); - qX = new FullColumn{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; - qE = new FullColumn{ 0.0, 0.0, 1.4248456266393e-10, 1.0 }; + elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; + qX = std::make_shared>(elements); + elements = { 0.0, 0.0, 1.4248456266393e-10, 1.0 }; + qE = std::make_shared>(elements); part1->setqX(qX); part1->setqE(qE); TheSystem.parts.push_back(part1); @@ -77,8 +90,10 @@ int main() auto part2 = std::make_shared(); str = "Part2"; part2->setName(str); - qX = new FullColumn{ 0.38423366582893, 0.49215308269277, 0.048029210642807 }; - qE = new FullColumn{ 0.0, 0.0, 0.89871701272344, 0.4385290538168 }; + elements = { 0.38423366582893, 0.49215308269277, 0.048029210642807 }; + qX = std::make_shared>(elements); + elements = { 0.0, 0.0, 0.89871701272344, 0.4385290538168 }; + qE = std::make_shared>(elements); part2->setqX(qX); part2->setqE(qE); TheSystem.parts.push_back(part2); @@ -86,8 +101,10 @@ int main() auto part3 = std::make_shared(); str = "Part3"; part3->setName(str); - qX = new FullColumn{ -1.284772285311e-18, 1.4645982581368, -4.788228906425e-17 }; - qE = new FullColumn{ 0.70710678118655, 0.70710678118655, 0.0, 0.0 }; + elements = { -1.284772285311e-18, 1.4645982581368, -4.788228906425e-17 }; + qX = std::make_shared>(elements); + elements = { 0.70710678118655, 0.70710678118655, 0.0, 0.0 }; + qE = std::make_shared>(elements); part3->setqX(qX); part3->setqE(qE); TheSystem.parts.push_back(part3); diff --git a/MbDCode/Part.cpp b/MbDCode/Part.cpp index c63f634..24b03eb 100644 --- a/MbDCode/Part.cpp +++ b/MbDCode/Part.cpp @@ -8,19 +8,19 @@ Part::Part() { partFrame = std::make_shared(); } -void Part::setqX(FullColumn* x) { +void Part::setqX(FullColDptr x) { partFrame.get()->setqX(x); } -FullColumn* Part::getqX() { +FullColDptr Part::getqX() { return partFrame.get()->getqX(); } -void Part::setqE(FullColumn* x) { +void Part::setqE(FullColDptr x) { partFrame.get()->setqE(x); } -FullColumn* Part::getqE() { +FullColDptr Part::getqE() { return partFrame.get()->getqE(); } diff --git a/MbDCode/Part.h b/MbDCode/Part.h index 6bc8327..188014b 100644 --- a/MbDCode/Part.h +++ b/MbDCode/Part.h @@ -15,10 +15,10 @@ namespace MbD { //ToDo: ipX ipE m aJ partFrame pX pXdot pE pEdot mX mE mEdot pTpE ppTpEpE ppTpEpEdot public: Part(); - void setqX(FullColumn* x); - FullColumn* getqX(); - void setqE(FullColumn* x); - FullColumn* getqE(); + void setqX(FullColDptr x); + FullColDptr getqX(); + void setqE(FullColDptr x); + FullColDptr getqE(); void setSystem(System& sys); std::shared_ptr partFrame; }; diff --git a/MbDCode/PartFrame.cpp b/MbDCode/PartFrame.cpp index d96501c..baf62a9 100644 --- a/MbDCode/PartFrame.cpp +++ b/MbDCode/PartFrame.cpp @@ -11,16 +11,16 @@ PartFrame::PartFrame() aGabs = std::vector>(); markerFrames = std::vector>(); } -void PartFrame::setqX(FullColumn* x) { +void PartFrame::setqX(FullColDptr x) { qX->copy(x); } -FullColumn* PartFrame::getqX() { +FullColDptr PartFrame::getqX() { return qX; } -void PartFrame::setqE(FullColumn* x) { +void PartFrame::setqE(FullColDptr x) { qE->copy(x); } -FullColumn* PartFrame::getqE() { +FullColDptr PartFrame::getqE() { return qE; } void PartFrame::setPart(std::shared_ptr x) { diff --git a/MbDCode/PartFrame.h b/MbDCode/PartFrame.h index 0c30ab4..d4a29fe 100644 --- a/MbDCode/PartFrame.h +++ b/MbDCode/PartFrame.h @@ -19,18 +19,18 @@ namespace MbD { public: PartFrame(); - void setqX(FullColumn* x); - FullColumn* getqX(); - void setqE(FullColumn* x); - FullColumn* getqE(); + void setqX(FullColDptr x); + FullColDptr getqX(); + void setqE(FullColDptr x); + FullColDptr getqE(); void setPart(std::shared_ptr x); std::shared_ptr getPart(); void addMarkerFrame(std::shared_ptr x); std::weak_ptr part; int iqX, iqE; //Position index of frame variables qX and qE in system list of variables - FullColumn* qX = new FullColumn(3); - FullColumn* qE = new FullColumn(4); + FullColDptr qX = std::make_shared>(3); + FullColDptr qE = std::make_shared>(4); std::shared_ptr aGeu; std::vector> aGabs; std::vector> markerFrames; diff --git a/MbDCode/RowTypeMatrix.h b/MbDCode/RowTypeMatrix.h index c528c9c..c3cf077 100644 --- a/MbDCode/RowTypeMatrix.h +++ b/MbDCode/RowTypeMatrix.h @@ -7,11 +7,11 @@ namespace MbD { public: RowTypeMatrix() {} RowTypeMatrix(std::initializer_list list) : Array{ list } {} - void copy(RowTypeMatrix* x); + void copy(std::shared_ptr> x); }; template - inline void RowTypeMatrix::copy(RowTypeMatrix* x) + inline void RowTypeMatrix::copy(std::shared_ptr> x) { for (int i = 0; i < x->size(); i++) { this->at(i)->copy(x->at(i));