forked from ossimlabs/ossim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Garrett Potts
committed
Jul 16, 2019
1 parent
a52b157
commit 6c2e60e
Showing
2 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//******************************************************************* | ||
// | ||
// License: MIT | ||
// | ||
// See LICENSE.txt file in the top level directory for more details. | ||
// | ||
// Description: Contains class definition for ossim2dTo2dCompositeTransform. | ||
// | ||
//******************************************************************* | ||
// $Id$ | ||
#ifndef ossim2dTo2dCompositeTransform_HEADER | ||
#define ossim2dTo2dCompositeTransform_HEADER | ||
#include <ossim/base/ossim2dTo2dTransform.h> | ||
#include <ossim/base/ossimRefPtr.h> | ||
#include <vector> | ||
|
||
/** | ||
* This is the identity transform and just passes the input to the output. | ||
*/ | ||
class OSSIM_DLL ossim2dTo2dCompositeTransform : public ossim2dTo2dTransform | ||
{ | ||
public: | ||
typedef std::vector<ossimRefPtr<ossim2dTo2dTransform> > CompositeTransformList; | ||
ossim2dTo2dCompositeTransform(const CompositeTransformList& compositeTransformList = CompositeTransformList()); | ||
ossim2dTo2dCompositeTransform(const ossim2dTo2dCompositeTransform& rhs); | ||
virtual ~ossim2dTo2dCompositeTransform(); | ||
virtual ossimObject* dup()const; | ||
|
||
|
||
void add(ossimRefPtr<ossim2dTo2dTransform> transform); | ||
void clear(); | ||
|
||
const CompositeTransformList& getCompositeTransformList()const; | ||
|
||
/** | ||
* | ||
*/ | ||
virtual void forward(const ossimDpt& input, | ||
ossimDpt& output) const; | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
virtual void forward(ossimDpt& /* modify_this */) const; | ||
|
||
/** | ||
* inverse transform just passes the point to the output. | ||
*/ | ||
virtual void inverse(const ossimDpt& input, | ||
ossimDpt& output) const; | ||
|
||
/** | ||
* inverse transform nothing is modified on the input point. | ||
*/ | ||
virtual void inverse(ossimDpt& /* modify_this */) const; | ||
|
||
/** | ||
* Pass equality to the parent | ||
*/ | ||
virtual const ossim2dTo2dCompositeTransform& operator=( | ||
const ossim2dTo2dCompositeTransform& rhs) | ||
{ | ||
ossim2dTo2dTransform::operator =(rhs); | ||
|
||
return *this; | ||
} | ||
|
||
virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const; | ||
virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0); | ||
|
||
protected: | ||
CompositeTransformList m_compositeTransforms; | ||
|
||
TYPE_DATA | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include <ossim/base/ossim2dTo2dCompositeTransform.h> | ||
#include <ossim/base/ossimKeywordlist.h> | ||
#include <ossim/base/ossim2dTo2dTransformRegistry.h> | ||
|
||
RTTI_DEF1_INST(ossim2dTo2dCompositeTransform, "ossim2dTo2dCompositeTransform", ossim2dTo2dTransform); | ||
|
||
ossim2dTo2dCompositeTransform::ossim2dTo2dCompositeTransform(const CompositeTransformList& compositeTransformList ) | ||
: m_compositeTransforms(compositeTransformList) | ||
{ | ||
|
||
} | ||
|
||
ossim2dTo2dCompositeTransform::ossim2dTo2dCompositeTransform(const ossim2dTo2dCompositeTransform& rhs) | ||
:m_compositeTransforms(rhs.m_compositeTransforms) | ||
{ | ||
|
||
} | ||
|
||
ossim2dTo2dCompositeTransform::~ossim2dTo2dCompositeTransform() | ||
{ | ||
clear(); | ||
} | ||
|
||
ossimObject* ossim2dTo2dCompositeTransform::dup()const | ||
{ | ||
return new ossim2dTo2dCompositeTransform(*this); | ||
} | ||
|
||
|
||
void ossim2dTo2dCompositeTransform::add(ossimRefPtr<ossim2dTo2dTransform> transform) | ||
{ | ||
if(transform) | ||
{ | ||
m_compositeTransforms.push_back(transform); | ||
} | ||
} | ||
|
||
void ossim2dTo2dCompositeTransform::clear() | ||
{ | ||
m_compositeTransforms.clear(); | ||
} | ||
|
||
const ossim2dTo2dCompositeTransform::CompositeTransformList& ossim2dTo2dCompositeTransform::getCompositeTransformList()const | ||
{ | ||
return m_compositeTransforms; | ||
} | ||
|
||
void ossim2dTo2dCompositeTransform::forward(const ossimDpt& input, | ||
ossimDpt& output) const | ||
{ | ||
ossimDpt tempInput = input; | ||
output = input; | ||
|
||
for(auto transform:m_compositeTransforms) | ||
{ | ||
transform->forward(tempInput, output); | ||
tempInput=output; | ||
} | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
void ossim2dTo2dCompositeTransform::forward(ossimDpt& modify_this) const | ||
{ | ||
forward(ossimDpt(modify_this), modify_this); | ||
} | ||
|
||
/** | ||
* inverse transform just passes the point to the output. | ||
*/ | ||
void ossim2dTo2dCompositeTransform::inverse(const ossimDpt& input, | ||
ossimDpt& output) const | ||
{ | ||
ossimDpt tempInput = input; | ||
output = input; | ||
|
||
for(CompositeTransformList::const_reverse_iterator iter = m_compositeTransforms.rbegin(); | ||
iter != m_compositeTransforms.rend(); | ||
++iter | ||
) | ||
{ | ||
(*iter)->inverse(tempInput, output); | ||
tempInput = output; | ||
} | ||
} | ||
|
||
/** | ||
* inverse transform nothing is modified on the input point. | ||
*/ | ||
void ossim2dTo2dCompositeTransform::inverse(ossimDpt& modify_this) const | ||
{ | ||
inverse(ossimDpt(modify_this), modify_this); | ||
} | ||
|
||
bool ossim2dTo2dCompositeTransform::saveState(ossimKeywordlist& kwl, const char* prefix)const | ||
{ | ||
bool result = ossim2dTo2dTransform::saveState(kwl, prefix); | ||
ossim_uint64 idx = 0; | ||
|
||
for(; idx < m_compositeTransforms.size();++idx) | ||
{ | ||
ossimString newPrefix(prefix); | ||
|
||
newPrefix += ossimString("object") + | ||
ossimString::toString(idx) + | ||
ossimString("."); | ||
result &= m_compositeTransforms[idx]->saveState(kwl, newPrefix.c_str()); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
bool ossim2dTo2dCompositeTransform::loadState(const ossimKeywordlist& kwl, const char* prefix) | ||
{ | ||
bool result = ossim2dTo2dTransform::loadState(kwl, prefix); | ||
|
||
std::vector<ossimString> prefixValues; | ||
clear(); | ||
kwl.getSubstringKeyList(prefixValues, ossimString("^(")+ossimString(prefix)+"object[0-9]+.)"); | ||
|
||
for(auto newPrefix:prefixValues) | ||
{ | ||
ossimRefPtr<ossim2dTo2dTransform> trans = ossim2dTo2dTransformRegistry::instance()->createTransform(kwl, newPrefix.c_str()); | ||
if(trans) | ||
{ | ||
add(trans); | ||
} | ||
} | ||
|
||
return result; | ||
} |