This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
66823b8
commit 52152e8
Showing
4 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
Submodule libsemantic
updated
from 3d8387 to 2e3f78
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
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
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,95 @@ | ||
/** | ||
* Copyright (c) 2017 Melown Technologies SE | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef mapproxy_support_position_hpp_included_ | ||
#define mapproxy_support_position_hpp_included_ | ||
|
||
#include "vts-libs/vts/csconvertor.hpp" | ||
|
||
#include "geo.hpp" | ||
|
||
/** Generate position looking at the scene center having all points in the | ||
* extent. | ||
* | ||
* Data are generated by calling forEachVertex(callback) where callbacks has the | ||
* following prototype: | ||
* | ||
* callback(const math::Point3d &p) | ||
* | ||
* \params rf reference frame | ||
* \params srsDef source (data) SRS definition | ||
* \params center scene center in srsDef | ||
* \params pixel generator | ||
* | ||
*/ | ||
template <typename ForEachVertex> | ||
vr::Position positionFromPoints(const vr::ReferenceFrame &rf | ||
, const geo::SrsDefinition &srsDef | ||
, const math::Point2 ¢er | ||
, const ForEachVertex &forEachVertex); | ||
|
||
// inlines | ||
|
||
template <typename ForEachVertex> | ||
vr::Position positionFromPoints(const vr::ReferenceFrame &rf | ||
, const geo::SrsDefinition &srsDef | ||
, const math::Point2 ¢er | ||
, const ForEachVertex &forEachVertex) | ||
{ | ||
// mesh center in navigation SRS | ||
const auto c(vts::CsConvertor(srsDef, rf.model.navigationSrs)(center)); | ||
|
||
LOG(info4) << "c: " << c; | ||
|
||
vr::Position pos; | ||
pos.type = vr::Position::Type::objective; | ||
pos.heightMode = vr::Position::HeightMode::floating; | ||
pos.position(0) = c(0); | ||
pos.position(1) = c(1); | ||
pos.position(2) = 0.0; // floating -> zero | ||
pos.lookDown(); | ||
pos.verticalFov = vr::Position::naturalFov(); | ||
|
||
// compute vertical extent by taking a "photo" of physical data from | ||
// view's "camera" | ||
const auto trafo(makePlaneTrafo(rf, c)); | ||
const vts::CsConvertor cs(srsDef, rf.model.physicalSrs); | ||
math::Extents2 cameraExtents(math::InvalidExtents{}); | ||
|
||
forEachVertex([&](const math::Point3d &p) | ||
{ | ||
const auto pp(math::transform(trafo, cs(p))); | ||
math::update(cameraExtents, pp(0), pp(1)); | ||
}); | ||
|
||
const auto cameraExtentsSize(math::size(cameraExtents)); | ||
pos.verticalExtent = std::max(cameraExtentsSize.width | ||
, cameraExtentsSize.height); | ||
return pos; | ||
} | ||
|
||
#endif // mapproxy_support_position_hpp_included_ |