本文整理汇总了C++中SLM_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ SLM_ASSERT函数的具体用法?C++ SLM_ASSERT怎么用?C++ SLM_ASSERT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SLM_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SLM_TRACE_FUNC
void Histogram::updateCurrentPoint( ::scene2D::data::Event::sptr _event )
{
SLM_TRACE_FUNC();
SLM_ASSERT("m_histogramPointUID must be defined in order to update the related ::fwData::Point data.",
!m_histogramPointUID.empty());
::fwData::Histogram::sptr histogram = this->getObject< ::fwData::Histogram>();
::fwData::Histogram::fwHistogramValues values = histogram->getValues();
const float histogramMinValue = histogram->getMinValue();
const float histogramBinsWidth = histogram->getBinsWidth();
// Event coordinates in scene
::scene2D::data::Coord sceneCoord = this->getScene2DRender()->mapToScene( _event->getCoord() );
const int histIndex = (int) sceneCoord.getX();
const int index = histIndex - histogramMinValue;
const int nbValues = (int)values.size() * histogramBinsWidth;
if(index >= 0 && index < nbValues)
{
::fwData::Point::sptr point =
::fwData::Point::dynamicCast( ::fwTools::fwID::getObject( m_histogramPointUID ) );
SLM_ASSERT("m_histogramPointUID can't be null here.", point);
point->getRefCoord()[0] = sceneCoord.getX();
point->getRefCoord()[1] = values.at( index / histogramBinsWidth ) * m_scale;
}
}
示例2: SLM_ASSERT
void Instantiator::ClassInitialize()
{
vtkInstantiator::RegisterInstantiator("fwVtkBoxRepresentation", vtkInstantiatorfwVtkBoxRepresentationNew);
vtkInstantiator::RegisterInstantiator("fwVtkPicker", vtkInstantiatorfwVtkPickerNew);
vtkInstantiator::RegisterInstantiator("fwVtkCellPicker", vtkInstantiatorfwVtkCellPickerNew);
vtkInstantiator::RegisterInstantiator("InteractorStyle2DForNegato", vtkInstantiatorInteractorStyle2DForNegatoNew);
vtkInstantiator::RegisterInstantiator("InteractorStyle3DForNegato", vtkInstantiatorInteractorStyle3DForNegatoNew);
#ifdef DEBUG
vtkObject *o = vtkInstantiator::CreateInstance("fwVtkBoxRepresentation");
SLM_ASSERT("Unable to instantiate a fwVtkBoxRepresentation",o);
o->Delete();
o = vtkInstantiator::CreateInstance("fwVtkPicker");
SLM_ASSERT("Unable to instantiate a fwVtkPicker",o);
o->Delete();
o = vtkInstantiator::CreateInstance("fwVtkCellPicker");
SLM_ASSERT("Unable to instantiate a fwVtkCellPicker",o);
o->Delete();
o = vtkInstantiator::CreateInstance("InteractorStyle2DForNegato");
SLM_ASSERT("Unable to instantiate a InteractorStyle2DForNegato",o);
o->Delete();
o = vtkInstantiator::CreateInstance("InteractorStyle3DForNegato");
SLM_ASSERT("Unable to instantiate a InteractorStyle3DForNegato",o);
o->Delete();
#endif
}
示例3: throw
void Native::setBundle( const Bundle * bundle ) throw()
{
// Pre-condition
SLM_ASSERT("bundle already initialized", m_bundle == 0 );
m_bundle = bundle;
// Post-condition
SLM_ASSERT("bundle not correctly attached", m_bundle == bundle );
}
示例4: Execute
virtual void Execute( vtkObject *caller, unsigned long eventId, void *)
{
assert(m_priority>=0);
SLM_ASSERT("m_adaptor not instanced", m_adaptor);
SLM_ASSERT("m_picker not instanced", m_picker);
this->process(vtkRenderWindowInteractor::SafeDownCast(caller), eventId);
}
示例5: SLM_ASSERT
void ContainerBuilder::destroyContainer()
{
SLM_ASSERT("Sorry, Container not initialized", m_container);
SLM_ASSERT("Sorry, the parent container is not a QtContainer", m_parent);
m_container->destroyContainer();
m_parent->clean();
}
示例6: SLM_ASSERT
bool App::OnInit()
{
::fwWX::LoggerInitializer::initialize();
m_profile = ::fwRuntime::profile::getCurrentProfile();
SLM_ASSERT("Profile is not initialized", m_profile);
#ifndef TDVPM_COMPLIANT
m_locale = new wxLocale();
::boost::filesystem::path pathLauncher;
pathLauncher = ::boost::filesystem::current_path() / "share" / "launcher_0-1" / "locale" ;
wxLocale::AddCatalogLookupPathPrefix( ::fwWX::std2wx( pathLauncher.string() ));
m_locale->Init(GetUILanguage());
m_locale->AddCatalog(_T("launcher"));
m_locale->AddCatalog(_T("runtime"));
// Set the locale to C for all number of all application
setlocale(LC_NUMERIC,"C");
#else
setlocale(LC_ALL,"C");
#endif
wxApp::OnInit();
std::string appName = m_profile->getName();
#ifndef TDVPM_COMPLIANT
m_locale->AddCatalog(::fwWX::std2wx(appName), wxLANGUAGE_FRENCH, _T("utf-8"));
#endif
SetAppName( ::fwWX::std2wx(appName) );
std::string checkerPath = ::fwTools::os::getUserDataDir("IRCAD", appName, true);
if (checkerPath.empty())
{
checkerPath = ::fwTools::os::getUserDataDir("IRCAD", "", true);
}
if (checkerPath.empty())
{
checkerPath = ::fwTools::os::getUserDataDir("", "", true);
}
SLM_ASSERT("Unable to find user's data dir.", !checkerPath.empty());
m_checker = new wxSingleInstanceChecker();
if (m_profile->getCheckSingleInstance())
{
m_checker->Create( ::fwWX::std2wx(appName) + _(".pid"), ::fwWX::std2wx(checkerPath));
if ( m_checker->IsAnotherRunning() )
{
wxLogError(_("Another " + ::fwWX::std2wx(appName) + _(" instance is already running, aborting.")));
return false;
}
}
// Initialize root object : root object, views, ...
//::fwServices::RootManager::initializeRootObject();
return TRUE;
}
示例7: imLock
void SImageCenter::updating()
{
::fwData::Image::csptr image = this->getInput< ::fwData::Image >(s_IMAGE_IN);
::fwData::mt::ObjectReadLock imLock(image);
SLM_ASSERT("Missing image '"+ s_IMAGE_IN + "'", image);
const bool imageValidity = ::fwDataTools::fieldHelper::MedicalImageHelpers::checkImageValidity(image);
if(!imageValidity)
{
SLM_WARN("Can not compute center of a invalid image.");
return;
}
::fwData::TransformationMatrix3D::sptr matrix =
this->getInOut< ::fwData::TransformationMatrix3D >(s_TRANSFORM_INOUT);
SLM_ASSERT("Missing matrix '"+ s_TRANSFORM_INOUT +"'", matrix);
::fwData::mt::ObjectWriteLock matLock(matrix);
::fwDataTools::TransformationMatrix3D::identity(matrix);
//compute the center
const ::fwData::Image::SizeType size = image->getSize();
const ::fwData::Image::SpacingType spacing = image->getSpacing();
const ::fwData::Image::OriginType origin = image->getOrigin();
SLM_ASSERT("Image should be in 3 Dimensions", size.size() == 3);
std::vector<double> center(3, 0.);
center[0] = (static_cast<double>(size[0]) * spacing[0]) / 2.;
center[1] = (static_cast<double>(size[1]) * spacing[1]) / 2.;
center[2] = (static_cast<double>(size[2]) * spacing[2]) / 2.;
//compute origin -center
center[0] += origin[0];
center[1] += origin[1];
center[2] += origin[2];
matrix->setCoefficient(0, 3, center[0]);
matrix->setCoefficient(1, 3, center[1]);
matrix->setCoefficient(2, 3, center[2]);
// output the translation matrix
auto sig = matrix->signal< ::fwData::TransformationMatrix3D::ModifiedSignalType >
(::fwData::TransformationMatrix3D::s_MODIFIED_SIG);
sig->asyncEmit();
m_sigComputed->asyncEmit();
}
示例8: SLM_ASSERT
void IFrameSrv::initialize()
{
// find gui configuration
std::vector < ConfigurationType > vectGui = m_configuration->find("gui");
std::vector < ConfigurationType > vectWindow = m_configuration->find("window");
if(!vectGui.empty())
{
// find LayoutManager configuration
std::vector < ConfigurationType > vectLayoutMng = vectGui.at(0)->find("frame");
SLM_ASSERT("<frame> xml element must exist", !vectLayoutMng.empty());
m_frameConfig = vectLayoutMng.at(0);
this->initializeLayoutManager(m_frameConfig);
// find menuBarBuilder configuration
std::vector < ConfigurationType > vectMBBuilder = vectGui.at(0)->find("menuBar");
if(!vectMBBuilder.empty())
{
m_menuBarConfig = vectMBBuilder.at(0);
this->initializeMenuBarBuilder(m_menuBarConfig);
m_hasMenuBar = true;
}
// find toolBarBuilder configuration
std::vector < ConfigurationType > vectTBBuilder = vectGui.at(0)->find("toolBar");
if(!vectTBBuilder.empty())
{
m_toolBarConfig = vectTBBuilder.at(0);
this->initializeToolBarBuilder(m_toolBarConfig);
m_hasToolBar = true;
}
}
if(!vectWindow.empty())
{
ConfigurationType window = vectWindow.at(0);
std::string onclose = window->getAttributeValue("onclose");
if ( !onclose.empty() )
{
m_closePolicy = onclose;
}
SLM_ASSERT("Invalid onclose value : " << m_closePolicy << ". Should be 'exit', 'notify' or 'message'",
m_closePolicy == CLOSE_POLICY_NOTIFY || m_closePolicy == CLOSE_POLICY_EXIT
|| m_closePolicy == CLOSE_POLICY_MESSAGE);
}
m_viewRegistrar = ::fwGui::registrar::ViewRegistrar::New(this->getID());
// find ViewRegistryManager configuration
std::vector < ConfigurationType > vectRegistrar = m_configuration->find("registry");
if(!vectRegistrar.empty())
{
m_registrarConfig = vectRegistrar.at(0);
m_viewRegistrar->initialize(m_registrarConfig);
}
}
示例9: throw
void SWriter::configuring() throw(::fwTools::Failed)
{
::io::IWriter::configuring();
typedef SPTR(::fwRuntime::ConfigurationElement) ConfigurationElement;
typedef std::vector < ConfigurationElement > ConfigurationElementContainer;
m_customExts.clear();
m_allowedExtLabels.clear();
ConfigurationElementContainer customExtsList = m_configuration->find("archive");
BOOST_FOREACH(ConfigurationElement archive, customExtsList)
{
const std::string& backend = archive->getAttributeValue("backend");
SLM_ASSERT("No backend attribute given in archive tag", backend != "");
SLM_ASSERT("Unsupported backend '" + backend + "'",
SReader::s_EXTENSIONS.find("." + backend) != SReader::s_EXTENSIONS.end());
ConfigurationElementContainer exts = archive->find("extension");
BOOST_FOREACH(ConfigurationElement ext, exts)
{
const std::string& extension = ext->getValue();
SLM_ASSERT("No extension given for backend '" + backend + "'", !extension.empty());
SLM_ASSERT("Extension must begin with '.'", extension[0] == '.');
m_customExts[extension] = backend;
m_allowedExtLabels[extension] = ext->getAttributeValue("label");
}
}
ConfigurationElementContainer extensionsList = m_configuration->find("extensions");
SLM_ASSERT("The <extensions> element can be set at most once.", extensionsList.size() <= 1);
if(extensionsList.size() == 1)
{
m_allowedExts.clear();
ConfigurationElementContainer extensions = extensionsList.at(0)->find("extension");
BOOST_FOREACH(ConfigurationElement extension, extensions)
{
const std::string& ext = extension->getValue();
// The extension must be found either in custom extensions list or in known extensions
FileExtension2NameType::const_iterator itKnown = SReader::s_EXTENSIONS.find(ext);
FileExtension2NameType::const_iterator itCustom = m_customExts.find(ext);
const bool extIsKnown = (itKnown != SReader::s_EXTENSIONS.end() || itCustom != m_customExts.end());
OSLM_ASSERT("Extension '" << ext << "' is not allowed in configuration", extIsKnown);
if(extIsKnown)
{
m_allowedExts.insert(m_allowedExts.end(), ext);
m_allowedExtLabels[ext] = extension->getAttributeValue("label");
}
}
}
示例10: SLM_ASSERT
bool MedicalImageHelpers::checkImageSliceIndex( ::fwData::Image::sptr _pImg )
{
SLM_ASSERT("_pImg pointer null", _pImg);
bool fieldIsModified = false;
const ::fwData::Image::SizeType &imageSize = _pImg->getSize();
::fwData::Integer::sptr axialIdx = _pImg->getField< ::fwData::Integer >( ::fwComEd::Dictionary::m_axialSliceIndexId );
::fwData::Integer::sptr frontalIdx = _pImg->getField< ::fwData::Integer >( ::fwComEd::Dictionary::m_frontalSliceIndexId);
::fwData::Integer::sptr sagittalIdx = _pImg->getField< ::fwData::Integer >( ::fwComEd::Dictionary::m_sagittalSliceIndexId );
// Manage image landmarks
if ( ! (axialIdx && frontalIdx && sagittalIdx) )
{
// Set value
axialIdx = ::fwData::Integer::New(-1);
_pImg->setField( ::fwComEd::Dictionary::m_axialSliceIndexId, axialIdx );
frontalIdx = ::fwData::Integer::New(-1);
_pImg->setField( ::fwComEd::Dictionary::m_frontalSliceIndexId, frontalIdx );
sagittalIdx = ::fwData::Integer::New(-1);
_pImg->setField( ::fwComEd::Dictionary::m_sagittalSliceIndexId, sagittalIdx );
fieldIsModified = true;
}
SLM_ASSERT (
"Information on image slice index is not correct, miss one of these fields : m_axialSliceIndexId, m_frontalSliceIndexId, m_sagittalSliceIndexId.",
axialIdx && frontalIdx && sagittalIdx
);
// Get value
if( axialIdx->value() < 0 || imageSize[2] < axialIdx->value() )
{
axialIdx->value() = static_cast< ::fwData::Integer::ValueType >(imageSize[2] / 2);
fieldIsModified = true;
}
if( frontalIdx->value() < 0 || imageSize[1] < frontalIdx->value() )
{
frontalIdx->value() = static_cast< ::fwData::Integer::ValueType >(imageSize[1] / 2);
fieldIsModified = true;
}
if( sagittalIdx->value() < 0 || imageSize[0] < sagittalIdx->value() )
{
sagittalIdx->value() = static_cast< ::fwData::Integer::ValueType >(imageSize[0] / 2);
fieldIsModified = true;
}
return fieldIsModified;
}
示例11: getSubstitutions
void XMLSubstitute::substitute( xmlNodePtr original, xmlNodePtr substitutionRules, std::map< std::string, std::string> &dictionary)
{
std::list< ::fwRuntime::io::Substitute > substitutions = getSubstitutions( substitutionRules );
for ( std::list< ::fwRuntime::io::Substitute >::iterator iter = substitutions.begin(); iter != substitutions.end(); ++iter )
{
std::string xpath = iter->xpath;
std::string dictEntry = iter->dictEntry;
std::string status = iter->status;
bool entryInDictionary = dictionary.find(dictEntry) != dictionary.end();
if ( status=="required" && !entryInDictionary )
{
OSLM_FATAL("XML substitution required dictEntry [" << dictEntry << "] missing for xpath " << xpath );
}
// optional and not in dictionary
if ( status=="optional" && !entryInDictionary )
{
OSLM_INFO("XML substitution optional dictEntry [" << dictEntry << "] not modified for xpath " << xpath );
continue;
}
OSLM_INFO("XML substitution dictEntry [" << dictEntry << "] modified with xpath " << xpath << " with the value : " << dictionary[dictEntry] );
// create the context for xpath
xmlXPathContextPtr xpathCtx;
xpathCtx = xmlXPathNewContext(original->doc);
SLM_ASSERT("xpathCtx not instanced", xpathCtx);
// search
xmlChar *xpathExpr= BAD_CAST xpath.c_str();
xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
SLM_ASSERT("xpathObj not instanced", xpathObj);
int NbNodesFound = xpathObj->nodesetval->nodeNr;
for (int i=NbNodesFound-1; i >= 0; --i )
{
xmlNodePtr node = xpathObj->nodesetval->nodeTab[i];
// substitution
if (node->type == XML_ATTRIBUTE_NODE )
{
xmlSetProp( node->parent, node->name, BAD_CAST dictionary[dictEntry].c_str() );
}
if (node->type == XML_ELEMENT_NODE )
{
xmlNodeSetName( node , BAD_CAST dictionary[dictEntry].c_str() );
}
if (node->type == XML_TEXT_NODE )
{
xmlNodeSetContent( node , BAD_CAST dictionary[dictEntry].c_str() );
}
}
xmlXPathFreeObject(xpathObj );
}
}
示例12: SLM_ASSERT
void SMesh::updateCellColors()
{
::fwData::Mesh::csptr mesh = this->getInput < ::fwData::Mesh >(s_MESH_INPUT);
SLM_ASSERT("Missing mesh", mesh);
SLM_ASSERT("m_polyData not instanced", m_polyData);
::fwData::mt::ObjectReadLock lock(mesh);
::fwVtkIO::helper::Mesh::updatePolyDataCellColor(m_polyData, mesh);
this->setVtkPipelineModified();
this->requestRender();
}
示例13: SLM_ASSERT
void ISlideViewBuilder::initialize( ::fwRuntime::ConfigurationElement::sptr configuration)
{
SLM_ASSERT("Bad configuration name " + configuration->getName() + ", must be 'slideView'",
configuration->getName() == "slideView");
if (configuration->hasAttribute("align"))
{
std::string aligment = configuration->getExistingAttributeValue("align");
if (aligment == "top")
{
m_aligment = TOP;
}
else if (aligment == "bottom")
{
m_aligment = BOTTOM;
}
else if (aligment == "right")
{
m_aligment = RIGHT;
}
else if (aligment == "left")
{
m_aligment = LEFT;
}
else
{
SLM_FATAL("Wrong value '"+ aligment +"' for 'align' attribute (require top, bottom, right or left)");
}
}
if (configuration->hasAttribute("opacity"))
{
std::string opacity = configuration->getExistingAttributeValue("opacity");
m_opacity = std::stod(opacity);
SLM_ASSERT("Opacity must be in [0 - 1]; actual: " + opacity, m_opacity >= 0. && m_opacity <= 1.);
}
if (configuration->hasAttribute("size"))
{
std::string size = configuration->getExistingAttributeValue("size");
m_size = std::stoi(size);
SLM_ASSERT("Size must not be negative", m_size >= 0.);
}
::fwRuntime::ConfigurationElement::csptr styleCfg = configuration->findConfigurationElement("styleSheet");
if (styleCfg)
{
m_styleSheet = styleCfg->getValue();
}
}
示例14: operator
void operator()(Parameters& params)
{
typedef typename ::itk::Image< PIXELTYPE, 3 > ImageType;
const typename ImageType::Pointer itkImage = ::fwItkIO::itkImageFactory< ImageType >(params.i_image);
typename ::itk::ResampleImageFilter<ImageType, ImageType>::Pointer resampler =
::itk::ResampleImageFilter<ImageType, ImageType>::New();
typename ::itk::MinimumMaximumImageCalculator< ImageType >::Pointer minCalculator =
::itk::MinimumMaximumImageCalculator< ImageType >::New();
minCalculator->SetImage(itkImage);
minCalculator->ComputeMinimum();
resampler->SetDefaultPixelValue(minCalculator->GetMinimum());
resampler->SetTransform(params.i_trf.GetPointer());
resampler->SetInput(itkImage);
typename ImageType::SizeType size = itkImage->GetLargestPossibleRegion().GetSize();
typename ImageType::PointType origin = itkImage->GetOrigin();
typename ImageType::SpacingType spacing = itkImage->GetSpacing();
typename ImageType::DirectionType direction = itkImage->GetDirection();
SLM_ASSERT("Input spacing can't be null along any axis", spacing[0] > 0 && spacing[1] > 0 && spacing[2] > 0);
if(params.i_targetImage)
{
for(std::uint8_t i = 0; i < 3; ++i)
{
// ITK uses unsigned long to store sizes.
size[i] = static_cast<typename ImageType::SizeType::SizeValueType>(params.i_targetImage->getSize()[i]);
origin[i] = params.i_targetImage->getOrigin()[i];
spacing[i] = params.i_targetImage->getSpacing()[i];
SLM_ASSERT("Output spacing can't be null along any axis.", spacing[i] > 0);
}
}
resampler->SetSize(size);
resampler->SetOutputOrigin(origin);
resampler->SetOutputDirection(direction);
resampler->SetOutputSpacing(spacing);
resampler->Update();
typename ImageType::Pointer outputImage = resampler->GetOutput();
::fwItkIO::itkImageToFwDataImage(outputImage, params.o_image);
}
示例15: stopSlicing
void stopSlicing()
{
SLM_TRACE("vtkEvent: MiddleButtonReleaseEvent");
SLM_ASSERT("m_adaptor not instanced", m_adaptor);
SLM_ASSERT("m_picker not instanced", m_picker);
SLM_ASSERT("Slicing doesn't begun", m_mouseMoveObserved);
m_adaptor->getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, this);
m_mouseMoveObserved = false;
m_adaptor->stopSlicing();
m_localPicker->Delete();
m_localPicker = nullptr;
m_pickedProp = nullptr;
}