Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
merging master and develop before release
  • Loading branch information
bbercovici committed May 27, 2018
2 parents 63d57df + 28a9bb7 commit eeb39c8
Show file tree
Hide file tree
Showing 29 changed files with 949,996 additions and 74 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ to apply the update (if any).
## Changelog



### [SBGAT 1.05.2](https://github.com/bbercovici/SBGAT/releases/tag/1.05.1)

- Adds `SBGATObsRadar` to `SbgatCore`, a class emulating range/range-rate radar measurements. The corresponding menu and action are also available in `SbgatGui`
- If `gcc` exists in Homebrew's Cellar, SBGAT and its dependencies will be compiled using this OpenMP compliant compiler, giving better performance on multithreaded platforms. [This functionality had to be postponed due to Qt 5.10 incompability with recent gcc versions](https://bugreports.qt.io/browse/QTBUG-66585).


### [SBGAT 1.05.1](https://github.com/bbercovici/SBGAT/releases/tag/1.05.1)

This new release of SBGAT allows import/export of gravity spherical harmonics from/into SBGAT by means of Niels Lohmann's Modern C++ JSON library. This functionality is available from SbgatCore's classes and SbgatGui as well.
Expand Down
15 changes: 11 additions & 4 deletions SbgatCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@
#
#
################################################################################

# Building procedure
get_filename_component(dirName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(LIB_NAME "SbgatCore" CACHE STRING "Name of executable to be created.")

cmake_minimum_required(VERSION 3.0.0)

if (${USE_GCC})
include(cmake/FindOmpGcc.cmake)
else()
set(CMAKE_C_COMPILER /usr/bin/gcc CACHE STRING "C Compiler" FORCE)
set(CMAKE_CXX_COMPILER /usr/bin/g++ CACHE STRING "C++ Compiler" FORCE)
endif()

# Building procedure
get_filename_component(dirName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(LIB_NAME "SbgatCore" CACHE STRING "Name of executable to be created.")

project(${LIB_NAME})

# Specify the version used
Expand Down Expand Up @@ -123,6 +128,8 @@ add_library(${LIB_NAME}
source/SBGATSrpYorp.cpp
source/SBGATSphericalHarmo.cpp
source/SBGATObjWriter.cpp
source/SBGATObsRadar.cpp

)

# Linking
Expand Down
10 changes: 6 additions & 4 deletions SbgatCore/cmake/FindOmpGcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ if(APPLE)
# If len == 0, nothing to do here
if(${len} EQUAL 0)
message("No OMP-compliant compiler was found on this Mac.")
set(CMAKE_C_COMPILER "/usr/bin/gcc" CACHE STRING "C Compiler" FORCE)
set(CMAKE_CXX_COMPILER "/usr/bin/g++" CACHE STRING "C++ Compiler" FORCE)
else()
# Looping over each directory to extract major/intermediate versions
foreach(dir ${compiler_dirs})
Expand Down Expand Up @@ -91,12 +93,12 @@ if(APPLE)
endif()
else()
message("No OMP-compliant compiler was found on this Mac.")

set(CMAKE_C_COMPILER "/usr/bin/gcc" CACHE STRING "C Compiler" FORCE)
set(CMAKE_CXX_COMPILER "/usr/bin/g++" CACHE STRING "C++ Compiler" FORCE)
endif()

else()
# Running on Linux. Will switch back to compiler in /usr/local/bin
message("Switching to /usr/local/gcc ")
set(CMAKE_C_COMPILER "/usr/local/bin/gcc" CACHE STRING "C Compiler" FORCE)
set(CMAKE_CXX_COMPILER "/usr/local/bin/g++" CACHE STRING "C++ Compiler" FORCE)
set(CMAKE_C_COMPILER "/usr/bin/gcc" CACHE STRING "C Compiler" FORCE)
set(CMAKE_CXX_COMPILER "/usr/bin/g++" CACHE STRING "C++ Compiler" FORCE)
endif()
166 changes: 166 additions & 0 deletions SbgatCore/include/SbgatCore/SBGATObsRadar.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/** MIT License
Copyright (c) 2018 Benjamin Bercovici and Jay McMahon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

/*=========================================================================
Program: Small Body Geophysical Analysis
Module: SBGATObsRadar.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class SBGATObsRadar
* @author Benjamin Bercovici
* @brief Computes range/range-rate Doppler images over the surface of
provided small body
*
* @details Computes range/range-rate Doppler images over the surface of
provided small body
*
*/

#ifndef SBGATObsRadar_H
#define SBGATObsRadar_H

#include <vtkFiltersCoreModule.h> // For export macro
#include <vtkPolyDataAlgorithm.h>

#include <vtkModifiedBSPTree.h>
#include <vtkImageData.h>

#include <armadillo>
#include <array>


typedef typename std::vector<std::vector<std::array<double, 2> > > SBGATMeasurementsSequence;


class VTKFILTERSCORE_EXPORT SBGATObsRadar : public vtkPolyDataAlgorithm{
public:
/**
* Constructs with initial values of zero.
*/
static SBGATObsRadar *New();

vtkTypeMacro(SBGATObsRadar,vtkPolyDataAlgorithm);
void PrintSelf(std::ostream& os, vtkIndent indent) override;
void PrintHeader(std::ostream& os, vtkIndent indent) override;
void PrintTrailer(std::ostream& os, vtkIndent indent) override;

/**
Collects range/range-rate samples over the surface of the small body at the
specified time after epoch.
The radar source is positionned at 1e6 * l meters from the target's center of mass, where
l is a measure of the object's diagonal
@param measurements_sequence reference to MeasurementsSequence, holding collected range/range-rate measurements at each observation time
@param N maximum number of measurements to produce per illuminated facet
@param dt time since epoch (s)
@param period rotation period of target (s)
@param dir (unit vector) direction of radar-to-target vector expressed in the target's body frame at epoch
@param spin (unit vector) direction of target's spin vector expressed in the target's body frame
*/
void CollectMeasurementsSimpleSpin(
SBGATMeasurementsSequence & measurements_sequence,
const int & N,
const double & dt,
const double & period,
const arma::vec & dir,
const arma::vec & spin);

/**
Bins the provided measurements sequence into a series of 2d-histogram
Will throw an std::runtime_error exception if ither of the provided bin sizes are invalid (i.e <= 0)
@param measurements_sequence reference to MeasurementsSequence, holding collected range/range-rate measurements at each observation time
@param r_bin range bin size (m)
@param rr_bin range-rate bin size (m/s)
*/
void BinObservations(
const SBGATMeasurementsSequence & measurements_sequence,
const double & r_bin,
const double & rr_bin);

/**
Save the binned radar images to the prescribed folder
@param savepath path to folder where images will be saved (ex: "output/")
*/
void SaveImages(std::string savepath);

/**
Sets the scale factor to 1, indicative that the polydata has its coordinates expressed in meters (default)
*/
void SetScaleMeters() { this -> scaleFactor = 1; }

/**
Sets the scale factor to 1000, indicative that the polydata has its coordinates expressed in kilometers
*/
void SetScaleKiloMeters() { this -> scaleFactor = 1000; }

/**
Return vector holding the computed images
@return vector of radar images
*/
std::vector<vtkSmartPointer<vtkImageData>> GetImages() const;

/**
Clears images, if any
*/

void ClearImages() { this -> images.clear();}


protected:
SBGATObsRadar();
~SBGATObsRadar() override;

int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;


vtkSmartPointer<vtkModifiedBSPTree> bspTree;

std::vector<vtkSmartPointer<vtkImageData>> images;

arma::vec center_of_mass;

double scaleFactor = 1;
double max_value;

private:
SBGATObsRadar(const SBGATObsRadar&) = delete;
void operator=(const SBGATObsRadar&) = delete;
};

#endif


2 changes: 0 additions & 2 deletions SbgatCore/include/SbgatCore/SBGATSphericalHarmo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ class VTKFILTERSCORE_EXPORT SBGATSphericalHarmo : public vtkPolyDataAlgorithm{
bool scaleFactorSet;
bool setFromJSON;



private:
SBGATSphericalHarmo(const SBGATSphericalHarmo&) = delete;
void operator=(const SBGATSphericalHarmo&) = delete;
Expand Down
12 changes: 4 additions & 8 deletions SbgatCore/source/SBGATMassProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,9 @@ int SBGATMassProperties::RequestData(
kxyz[idx] = 0.0;
}

for (cellId=0; cellId < numCells; cellId++)
{
if ( input->GetCellType(cellId) != VTK_TRIANGLE)
{
vtkWarningMacro(<< "Input data type must be VTK_TRIANGLE not "
<< input->GetCellType(cellId));
for (cellId=0; cellId < numCells; cellId++){
if ( input->GetCellType(cellId) != VTK_TRIANGLE){
vtkWarningMacro(<< "Input data type must be VTK_TRIANGLE not "<< input->GetCellType(cellId));
continue;
}
input->GetCellPoints(cellId,ptIds);
Expand All @@ -173,8 +170,7 @@ int SBGATMassProperties::RequestData(

// store current vertex (x,y,z) coordinates ...
// Note that the coordinates are normalized!
for (idx=0; idx < numIds; idx++)
{
for (idx=0; idx < numIds; idx++){
input->GetPoint(ptIds->GetId(idx), p);
x[idx] = p[0] / l; y[idx] = p[1] / l; z[idx] = p[2] / l;
}
Expand Down
Loading

0 comments on commit eeb39c8

Please sign in to comment.