Skip to content

Commit

Permalink
update interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hbivens committed Oct 21, 2024
1 parent 874d8a5 commit cbfc685
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 57 deletions.
3 changes: 1 addition & 2 deletions SpecUtils/EnergyCalibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ namespace SpecUtils
\sa set_polynomial, EnergyCalCheckType::Normal
*/
static const float sm_polynomial_offset_limit;

protected:

/** Checks the channel energies is acceptable (e.g., enough channels, and monotonically
increasing values).
Expand Down
6 changes: 6 additions & 0 deletions SpecUtils/SpecFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@ class Measurement
from a file.
*/
void set_energy_calibration( const std::shared_ptr<const EnergyCalibration> &cal );

/// @brief Used for testing
void set_ecal( const std::shared_ptr<const EnergyCalibration> &cal )
{
energy_calibration_ = cal;
}



Expand Down
5 changes: 4 additions & 1 deletion bindings/swig/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ if (SpecUtils_FORTRAN_SWIG_GEN)
OUTPUT ${SWIG_CPP_WRAPPER} ${SWIG_FORTRAN_WRAPPER}
COMMAND ${CMAKE_COMMAND} -E echo "Generating SWIG wrapper..."
COMMAND swig -I../../../ -fortran -c++ -outdir ${CMAKE_CURRENT_BINARY_DIR} -o ${SWIG_CPP_WRAPPER} ${SWIG_INTERFACE_FILE}
DEPENDS ${SWIG_INTERFACE_FILE}
DEPENDS ${SWIG_INTERFACE_FILE}
${CMAKE_SOURCE_DIR}/SpecUtils/EnergyCalibration.h
${CMAKE_SOURCE_DIR}/SpecUtils/SpecFile.h
${CMAKE_SOURCE_DIR}/SpecUtils/FileSystem.h
COMMENT "Generating SWIG **Fortran** wrapper code"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
Expand Down
6 changes: 0 additions & 6 deletions bindings/swig/fortran/SpecUtilsFortran.i
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <SpecUtils/DateTime.h>
#include <SpecUtils/StringAlgo.h>
#include <SpecUtils/Filesystem.h>
#include <iostream>

%}


Expand Down Expand Up @@ -120,11 +118,7 @@ namespace std {
/// @param index is 1-based
std::shared_ptr<const SpecUtils::Measurement> measurement_at(int index)
{

auto newIndex = static_cast<size_t>(index-1);

std::cout << __func__ << ": newIndex: " << newIndex << std::endl;
std::cout << __func__ << ": num_measurements: " << $self->num_measurements() << std::endl;
return $self->measurement(newIndex);
}

Expand Down
141 changes: 135 additions & 6 deletions bindings/swig/fortran/SpecUtilsFortran_wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ template <typename T> T SwigValueInit() {
#include <SpecUtils/DateTime.h>
#include <SpecUtils/StringAlgo.h>
#include <SpecUtils/Filesystem.h>
#include <iostream>



#include <utility>
Expand Down Expand Up @@ -622,11 +620,7 @@ SWIGINTERN void SpecUtils_Measurement_get_spectrum(SpecUtils::Measurement *self,
}
}
SWIGINTERN std::shared_ptr< SpecUtils::Measurement const > SpecUtils_SpecFile_measurement_at(SpecUtils::SpecFile *self,int index){

auto newIndex = static_cast<size_t>(index-1);

std::cout << __func__ << ": newIndex: " << newIndex << std::endl;
std::cout << __func__ << ": num_measurements: " << self->num_measurements() << std::endl;
return self->measurement(newIndex);
}
SWIGINTERN int SpecUtils_SpecFile_get_max_channel_count(SpecUtils::SpecFile *self){
Expand Down Expand Up @@ -2657,6 +2651,19 @@ SWIGEXPORT void _wrap_Measurement_set_energy_calibration(SwigClassWrapper *farg1
}


SWIGEXPORT void _wrap_Measurement_set_ecal(SwigClassWrapper *farg1, SwigClassWrapper const *farg2) {
SpecUtils::Measurement *arg1 = (SpecUtils::Measurement *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration const > *arg2 = 0 ;
std::shared_ptr< SpecUtils::Measurement > *smartarg1 ;
std::shared_ptr< SpecUtils::EnergyCalibration const > tempnull2 ;

smartarg1 = (std::shared_ptr< SpecUtils::Measurement >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::Measurement*)(smartarg1->get()) : NULL;
arg2 = farg2->cptr ? static_cast<std::shared_ptr< SpecUtils::EnergyCalibration const > * >(farg2->cptr) : &tempnull2;
(arg1)->set_ecal((std::shared_ptr< SpecUtils::EnergyCalibration const > const &)*arg2);
}


SWIGEXPORT void _wrap_Measurement_set_info_from_2006_N42_spectrum_node(SwigClassWrapper *farg1, SwigClassWrapper *farg2) {
SpecUtils::Measurement *arg1 = (SpecUtils::Measurement *) 0 ;
rapidxml::xml_node< char > *arg2 = (rapidxml::xml_node< char > *) (rapidxml::xml_node< char > *)0 ;
Expand Down Expand Up @@ -7148,6 +7155,128 @@ SWIGEXPORT float _wrap_EnergyCalibration_sm_polynomial_offset_limit_get() {
}


SWIGEXPORT void _wrap_EnergyCalibration_check_lower_energies(SwigClassWrapper *farg1, int const *farg2, SwigClassWrapper *farg3) {
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
size_t arg2 ;
std::vector< float > *arg3 = 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
arg2 = (size_t)(*farg2);
SWIG_check_nonnull(farg3->cptr, "std::vector< float > const &", "FloatVector", "SpecUtils::EnergyCalibration::check_lower_energies(size_t const,std::vector< float > const &)", return );
arg3 = (std::vector< float > *)farg3->cptr;
(arg1)->check_lower_energies(arg2,(std::vector< float > const &)*arg3);
}


SWIGEXPORT void _wrap_EnergyCalibration_m_type_set(SwigClassWrapper *farg1, int const *farg2) {
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
SpecUtils::EnergyCalType arg2 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
arg2 = (SpecUtils::EnergyCalType)(*farg2);
if (arg1) (arg1)->m_type = arg2;
}


SWIGEXPORT int _wrap_EnergyCalibration_m_type_get(SwigClassWrapper *farg1) {
int fresult ;
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;
SpecUtils::EnergyCalType result;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
result = (SpecUtils::EnergyCalType) ((arg1)->m_type);
fresult = (int)(result);
return fresult;
}


SWIGEXPORT void _wrap_EnergyCalibration_m_coefficients_set(SwigClassWrapper *farg1, SwigClassWrapper *farg2) {
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::vector< float > *arg2 = (std::vector< float > *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
arg2 = (std::vector< float > *)farg2->cptr;
if (arg1) (arg1)->m_coefficients = *arg2;
}


SWIGEXPORT SwigClassWrapper _wrap_EnergyCalibration_m_coefficients_get(SwigClassWrapper *farg1) {
SwigClassWrapper fresult ;
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;
std::vector< float > *result = 0 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
result = (std::vector< float > *)& ((arg1)->m_coefficients);
fresult.cptr = (void*)result;
fresult.cmemflags = SWIG_MEM_RVALUE | (0 ? SWIG_MEM_OWN : 0);
return fresult;
}


SWIGEXPORT void _wrap_EnergyCalibration_m_deviation_pairs_set(SwigClassWrapper *farg1, SwigClassWrapper *farg2) {
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::vector< std::pair< float,float > > *arg2 = (std::vector< std::pair< float,float > > *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
arg2 = (std::vector< std::pair< float,float > > *)farg2->cptr;
if (arg1) (arg1)->m_deviation_pairs = *arg2;
}


SWIGEXPORT SwigClassWrapper _wrap_EnergyCalibration_m_deviation_pairs_get(SwigClassWrapper *farg1) {
SwigClassWrapper fresult ;
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;
std::vector< std::pair< float,float > > *result = 0 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
result = (std::vector< std::pair< float,float > > *)& ((arg1)->m_deviation_pairs);
fresult.cptr = (void*)result;
fresult.cmemflags = SWIG_MEM_RVALUE | (0 ? SWIG_MEM_OWN : 0);
return fresult;
}


SWIGEXPORT void _wrap_EnergyCalibration_m_channel_energies_set(SwigClassWrapper *farg1, SwigClassWrapper *farg2) {
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::shared_ptr< std::vector< float > const > *arg2 = (std::shared_ptr< std::vector< float > const > *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
arg2 = (std::shared_ptr< std::vector< float > const > *)farg2->cptr;
if (arg1) (arg1)->m_channel_energies = *arg2;
}


SWIGEXPORT SwigClassWrapper _wrap_EnergyCalibration_m_channel_energies_get(SwigClassWrapper *farg1) {
SwigClassWrapper fresult ;
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;
std::shared_ptr< std::vector< float > const > *result = 0 ;

smartarg1 = (std::shared_ptr< SpecUtils::EnergyCalibration >*)(farg1->cptr);
arg1 = smartarg1 ? (SpecUtils::EnergyCalibration*)(smartarg1->get()) : NULL;
result = (std::shared_ptr< std::vector< float > const > *)& ((arg1)->m_channel_energies);
fresult.cptr = (void*)result;
fresult.cmemflags = SWIG_MEM_RVALUE | (0 ? SWIG_MEM_OWN : 0);
return fresult;
}


SWIGEXPORT void _wrap_delete_EnergyCalibration(SwigClassWrapper *farg1) {
SpecUtils::EnergyCalibration *arg1 = (SpecUtils::EnergyCalibration *) 0 ;
std::shared_ptr< SpecUtils::EnergyCalibration > *smartarg1 ;
Expand Down
Loading

0 comments on commit cbfc685

Please sign in to comment.