示例#1
0
namespace helper
{
typedef std::set<std::string> ExcludeSetType;

FWTEST_API bool compare(SPTR(::fwData::Object) objRef,
                        SPTR(::fwData::Object) objComp,
                         ExcludeSetType exclude = ExcludeSetType());

} // namespace helper
示例#2
0
static void testMoveToCV(size_t _w, size_t _h, std::uint8_t _numChannels)
{
    const std::vector<T> imageBuffer = genImageBuffer<T>(_w, _h, 0, _numChannels);

    ::arData::FrameTL::sptr frameTL;
    SPTR(::arData::FrameTL::BufferType) buffer;

    std::tie(frameTL, buffer) = genFrameTL<T>(_w, _h, _numChannels);
    auto eltBuffer = buffer->addElement(0);
    std::copy(imageBuffer.begin(), imageBuffer.end(), eltBuffer);

    {
        ::cv::Mat cvImage;
        ::cvIO::FrameTL::moveToCv(frameTL, eltBuffer, cvImage);

        // Since we share the same buffer, compare the pointers
        CPPUNIT_ASSERT_EQUAL(static_cast<void*>(eltBuffer), static_cast<void*>(cvImage.data));

        compareImages<T>(cvImage, eltBuffer, _w, _h, _numChannels);
    }
    {
        ::cv::Mat cvImage2;
        cvImage2 = ::cvIO::FrameTL::moveToCv(frameTL, eltBuffer);

        // Since we share the same buffer, compare the pointers
        CPPUNIT_ASSERT_EQUAL(static_cast<void*>(eltBuffer), static_cast<void*>(cvImage2.data));

        compareImages<T>(cvImage2, eltBuffer, _w, _h, _numChannels);
    }
}
示例#3
0
void RootManager::initializeRootObject()
{
    SLM_ASSERT("Sorry, the OSR is already initialized.", ! getDefault()->m_isRootInitialized );
    SLM_ASSERT("Sorry, configuration name parameter is not initialized.", getDefault()->m_rootObjectConfigurationName.first );
    SLM_ASSERT("Sorry, configuration file parameter is not initialized.", getDefault()->m_rootObjectConfigurationFile.first );

    // ToDo Correct this hack
    // Load another "pseudo" bundle
    ::boost::filesystem::path filePath ( getDefault()->m_rootObjectConfigurationFile.second );
    SPTR(::fwRuntime::Bundle) configBundle = ::fwRuntime::io::BundleDescriptorReader::createBundleFromXmlPlugin( filePath );
    ::fwRuntime::Runtime::getDefault()->addBundle( configBundle );
    configBundle->setEnable( true );

    // Validate bundle
    ::fwRuntime::Bundle::ExtensionConstIterator iter = configBundle->extensionsBegin();
    while( iter != configBundle->extensionsEnd() )
    {
        ::fwRuntime::Extension::Validity isValid = (*iter)->validate();
        OSLM_FATAL_IF("Sorry, extension " << (*iter)->getIdentifier() << " is not valid.", isValid == ::fwRuntime::Extension::Invalid );
        iter++;
    }

    // Register service config
    getDefault()->m_ctm = AppConfigManager::New();
    ::fwRuntime::ConfigurationElement::csptr config = ::fwServices::registry::AppConfig::getDefault()->getStandardConfig( getDefault()->m_rootObjectConfigurationName.second );
    getDefault()->m_ctm->setConfig( ::fwRuntime::ConfigurationElement::constCast( config ) );
    getDefault()->m_ctm->launch();
    getDefault()->m_isRootInitialized = true;
}
示例#4
0
void SCropVideoQuad::pushFrameInTimeline(::cv::Mat& imgIn,
                                         const ::cv::Rect& roi,
                                         ::arData::FrameTL::sptr& frameTL,
                                         ::fwCore::HiResClock::HiResClockType timestamp)
{
    const size_t width  = frameTL->getWidth();
    const size_t height = frameTL->getHeight();

    // Get the buffer of the timeline to fill
    SPTR(::arData::FrameTL::BufferType) bufferOut = frameTL->createBuffer(timestamp);
    std::uint8_t* frameBuffOut = bufferOut->addElement(0);

    // Create an openCV mat that aliases the buffer created from the output timeline
    ::cv::Mat imgOut(height, width, imgIn.type(), (void*)frameBuffOut, ::cv::Mat::AUTO_STEP);

    // Crop the full image to that image contained by the rectangle myROI
    // Note that this doesn't copy the data
    ::cv::Mat croppedImage = imgIn(roi);

    croppedImage.copyTo(imgOut);

    // push buffer and notify
    frameTL->pushObject(bufferOut);
    ::arData::TimeLine::ObjectPushedSignalType::sptr sig;
    sig = frameTL->signal< ::arData::TimeLine::ObjectPushedSignalType >(::arData::TimeLine::s_OBJECT_PUSHED_SIG );
    sig->asyncEmit(timestamp);
}
示例#5
0
template<class CLASSNAME > SPTR( CLASSNAME )  New()
{
    SPTR(CLASSNAME) srv = ::boost::make_shared< CLASSNAME >();
#ifdef COM_LOG
    srv->setID(srv->getID());
#endif
    return srv;
}
SPTR(std::ostream) MemoryWriteArchive::createFile(const ::boost::filesystem::path &path)
{
    SPTR(::boost::iostreams::stream<MemoryArchiveSink>) os;

    os = std::make_shared< ::boost::iostreams::stream<MemoryArchiveSink> >(m_archive, path);
    m_sinks.push_back(os);
    return os;
}
示例#7
0
void PatchLoader::loadPatches()
{
    SPTR(::fwAtomsPatch::VersionsManager) versionManager = ::fwAtomsPatch::VersionsManager::getDefault();
    versionManager->buildVersionTable("./share/arMDSemanticPatch-" ARMDSEMANTICPATCH_VER "/");
    versionManager->buildLinkTable("./share/arMDSemanticPatch-" ARMDSEMANTICPATCH_VER "/");

    ::fwMDSemanticPatch::PatchLoader::setCurrentVersion(s_currentVersion);
}
示例#8
0
void FwIDTest::conccurentAccessOnFwIDMapTest()
{
    const unsigned int nbThreads = 10;
    std::vector< SPTR(::fwTest::helper::Thread) > threads;
    for (int i=0 ; i<nbThreads ; ++i)
    {
        SPTR(::fwTest::helper::Thread) thread;
        thread = ::boost::shared_ptr< ::fwTest::helper::Thread >(
                new ::fwTest::helper::Thread(::boost::bind(&FwIDTest::runFwIDCreation, this)));
        threads.push_back(thread);
    }

    for (int i=0 ; i<nbThreads ; ++i)
    {
        std::stringstream str;
        str << "thread " << i;
        CPPUNIT_ASSERT_MESSAGE(str.str(), threads[i]->timedJoin(1000));
    }

}
void ActivitySeriesBuilderTest::setUp()
{
    // Set up context before running a test.
    ::boost::filesystem::path plugin = "share/tu_exec_fwActivities-0.0/tu_builder";
    m_bundle                         = ::fwRuntime::io::BundleDescriptorReader::createBundle(plugin);

    m_activities = ::fwActivities::registry::Activities::New();

    ::fwRuntime::Bundle::ExtensionContainer extensionsSet( m_bundle->extensionsBegin(), m_bundle->extensionsEnd());
    std::vector< SPTR( ::fwRuntime::Extension ) > extensions(extensionsSet.begin(), extensionsSet.end());
    m_activities->parseBundleInformation(extensions);

    CPPUNIT_ASSERT_EQUAL( size_t(1), extensions.size());
}
示例#10
0
void ZipTest::commentTest()
{
    const std::string writerComment = "Example of comment";

    const ::boost::filesystem::path dirPath = ::fwTools::System::getTemporaryFolder() / "fwZipTest";
    ::boost::filesystem::create_directories( dirPath );
    const ::boost::filesystem::path path        = dirPath / "jambon.zip";
    const ::boost::filesystem::path sourceFile  = ::fwTest::Data::dir() / "fw4spl/image/jpg/makao01.jpg";
    const ::boost::filesystem::path archiveFile = "makao.jpg";

    CPPUNIT_ASSERT_MESSAGE("The file '" + sourceFile.string() + "' does not exist",
                           ::boost::filesystem::exists(sourceFile));

    SPTR(WriteZipArchive) writer = std::make_shared<WriteZipArchive>(path, writerComment);
    writer->putFile(sourceFile, archiveFile);

    SPTR(ReadZipArchive) reader = std::make_shared<ReadZipArchive>(path);
    std::string readerComment = reader->getComment();

    ::boost::filesystem::remove_all( path );

    CPPUNIT_ASSERT_EQUAL(writerComment, readerComment);

}
示例#11
0
文件: tox.c 项目: Boerde/uTox
static void call_notify(FRIEND *f, uint8_t status)
{
    STRING *str;

    switch(status) {
    case CALL_INVITED:
    case CALL_INVITED_VIDEO:
        str = SPTR(CALL_INVITED);
        break;
    case CALL_RINGING:
    case CALL_RINGING_VIDEO:
        str = SPTR(CALL_RINGING); break;
    case CALL_OK:
    case CALL_OK_VIDEO:
        str = SPTR(CALL_STARTED);
        break;
    case CALL_NONE:
    default: //render unknown status as "call cancelled"
        str = SPTR(CALL_CANCELLED); break;
    }

    friend_notify(f, str->str, str->length, (uint8_t*)"", 0);
    friend_addmessage_notify(f, str->str, str->length);
}
示例#12
0
void MemoryWriteArchive::putFile(const ::boost::filesystem::path& sourceFile,
                                 const ::boost::filesystem::path& archiveFile)
{
    SPTR(std::ostream)  os;
    std::ifstream is(sourceFile.string().c_str(), std::ios::binary);

    if (is.is_open())
    {
        os = this->createFile(archiveFile);
        *os << is.rdbuf();
        is.close();
    }
    else
    {
        throw fwZip::exception::Write("Cannot open file : " + sourceFile.string());
    }
}
示例#13
0
static void testCopyFromCV(size_t _w, size_t _h, std::uint8_t _numChannels)
{
    const std::vector<T> imageBuffer = genImageBuffer<T>(_w, _h, 0, _numChannels);
    const ::cv::Mat cvImage          = genCvImage<T>(imageBuffer, _w, _h, 0, _numChannels);

    ::arData::FrameTL::sptr frameTL;
    SPTR(::arData::FrameTL::BufferType) buffer;

    std::tie(frameTL, buffer) = genFrameTL<T>(_w, _h, _numChannels);
    auto eltBuffer = buffer->addElement(0);

    ::cvIO::FrameTL::copyFromCv(frameTL, eltBuffer, cvImage);

    // Since we copy the buffer, ensure the pointers are different
    CPPUNIT_ASSERT(static_cast<void*>(eltBuffer) != static_cast<void*>(cvImage.data));

    compareImages<T>(cvImage, eltBuffer, _w, _h, _numChannels);
}
示例#14
0
    static SPTR(DATATYPE) getAttribute( xmlNodePtr source, const std::string & name , bool isMandatory = true )
    {
        SPTR(DATATYPE) castedData;
        xmlNodePtr fatherNode = XMLParser::findChildNamed( source, name );
        if ( fatherNode )
        {
            OSLM_ASSERT("Sorry, node '"<< name <<"' not instanced", fatherNode);
            xmlNodePtr node = ::fwXML::XMLParser::getChildrenXMLElement( fatherNode );
            OSLM_ASSERT("Sorry, child node of '"<< name <<"' node not instanced", node);
            ::fwData::Object::sptr obj;
            obj = Serializer().ObjectsFromXml( node );

            castedData = ::boost::dynamic_pointer_cast<DATATYPE>( obj );
            OSLM_ASSERT("DynamicCast "<< ::fwCore::TypeDemangler<DATATYPE>().getFullClassname()<<" failed", castedData);
        }
        else if ( isMandatory )
        {
            FW_RAISE("Sorry, attribute " << name << " is mandatory.");
        }
        return castedData;
    }
const BundleDescriptorReader::BundleContainer BundleDescriptorReader::createBundles(const ::boost::filesystem::path& location) throw(RuntimeException)
{
    // Normalizes the path.
    ::boost::filesystem::path normalizedPath(location);
    normalizedPath.normalize();

    // Asserts that the repository is a valid directory path.
    if(::boost::filesystem::exists(normalizedPath) == false || ::boost::filesystem::is_directory(normalizedPath) == false)
    {
        throw RuntimeException("'" + normalizedPath.string() + "': not a directory.");
    }

    // Walk through the repository entries.
    BundleContainer bundles;
    ::boost::filesystem::directory_iterator   currentEntry(normalizedPath);
    ::boost::filesystem::directory_iterator   endEntry;
    for(; currentEntry != endEntry; ++currentEntry)
    {
        ::boost::filesystem::path entryPath = *currentEntry;

        if(::boost::filesystem::is_directory(entryPath))
        {
            try
            {
                SPTR( ::fwRuntime::Bundle ) bundle = BundleDescriptorReader::createBundle(entryPath);
                if(bundle)
                {
                    bundles.push_back( bundle );
                }
            }
            catch(const RuntimeException& runtimeException)
            {
                OSLM_INFO( "'"<< entryPath.string() << "': skipped. " << runtimeException.what() );
            }
        }
    }
    return bundles;
}
示例#16
0
文件: tox.c 项目: Boerde/uTox
static void file_notify(FRIEND *f, MSG_FILE *msg)
{
    STRING *str;

    switch(msg->status) {
    case FILE_PENDING:
        str = SPTR(TRANSFER_NEW); break;
    case FILE_OK:
        str = SPTR(TRANSFER_STARTED); break;
    case FILE_PAUSED:
        str = SPTR(TRANSFER___); break;
    case FILE_PAUSED_OTHER:
        str = SPTR(TRANSFER_PAUSED); break;
    case FILE_KILLED:
        str = SPTR(TRANSFER_CANCELLED); break;
    case FILE_DONE:
        str = SPTR(TRANSFER_COMPLETE); break;
    case FILE_BROKEN:
    default: //render unknown status as "transfer broken"
        str = SPTR(TRANSFER_BROKEN); break;
    }

    friend_notify(f, str->str, str->length, msg->name, msg->name_length);
}
示例#17
0
文件: ui.c 项目: draziw-/uTox
/* Draw add a friend window */
static void drawadd(int UNUSED(x), int UNUSED(y), int UNUSED(w), int height)
{
    setcolor(C_TITLE);
    setfont(FONT_SELF_NAME);
    drawstr(LIST_RIGHT + SCALE * 5, SCALE * 10, ADDFRIENDS);

    setcolor(C_TITLE);
    setfont(FONT_TEXT);
    drawstr(LIST_RIGHT + SCALE * 5, LIST_Y + SCALE * 5, TOXID);

    drawstr(LIST_RIGHT + SCALE * 5, LIST_Y + SCALE * 29, MESSAGE);

    if(addfriend_status) {
        setfont(FONT_MISC);
        setcolor(C_RED);

        STRING *str;
        switch(addfriend_status) {
        case ADDF_SENT:
            str = SPTR(REQ_SENT); break;
        case ADDF_DISCOVER:
            str = SPTR(REQ_RESOLVE); break;
        case ADDF_BADNAME:
            str = SPTR(REQ_INVALID_ID); break;
        case ADDF_NONAME:
            str = SPTR(REQ_EMPTY_ID); break;
        case ADDF_TOOLONG: //if message length is too long.
            str = SPTR(REQ_LONG_MSG); break;
        case ADDF_NOMESSAGE: //if no message (message length must be >= 1 byte).
            str = SPTR(REQ_NO_MSG); break;
        case ADDF_OWNKEY: //if user's own key.
            str = SPTR(REQ_SELF_ID); break;
        case ADDF_ALREADYSENT: //if friend request already sent or already a friend.
            str = SPTR(REQ_ALREADY_FRIENDS); break;
        case ADDF_BADCHECKSUM: //if bad checksum in address.
            str = SPTR(REQ_BAD_CHECKSUM); break;
        case ADDF_SETNEWNOSPAM: //if the friend was already there but the nospam was different.
            str = SPTR(REQ_BAD_NOSPAM); break;
        case ADDF_NOMEM: //if increasing the friend list size fails.
            str = SPTR(REQ_NO_MEMORY); break;
        case ADDF_UNKNOWN: //for unknown error.
        case ADDF_NONE: //this case must never be rendered, but if it does, assume it's an error
        default:
            str = SPTR(REQ_UNKNOWN); break;
        }

        drawtextmultiline(LIST_RIGHT + SCALE * 5, utox_window_width - BM_SBUTTON_WIDTH - 5 * SCALE, LIST_Y + SCALE * 83, 0, height, font_small_lineheight, str->str, str->length, 0xFFFF, 0, 1);
    }
}
     * @brief Implements configuring method.
     * configuration \<manageLockOn key="CompositeObjectKey" /\>
     * if configuration is empty, service locks all composite objects
     */
    CTRLMEMORY_API virtual void configuring()  throw ( ::fwTools::Failed );

    /// Updates dump locks when object are pushed removed or swaped in composite
    CTRLMEMORY_API virtual void receiving( CSPTR(::fwServices::ObjectMsg) _msg ) throw ( ::fwTools::Failed );

private :

    typedef std::string CompositeKeyType;

    typedef std::map< CompositeKeyType, ::fwData::ObjectLock > LockMapType;

    /// Add or remove lock ( _isLocked parameter ) on composite objects
    void setDumpLockOnImages(LockMapType &lockMap, SPTR(::fwData::Composite) _composite, bool _isLocked );

    /// Composite keys managed by this service
    std::vector< std::string > m_managedKeys;

    /// Container to manages dump lock on composite sub object
    LockMapType m_lockedObjects;
};

} // manager
} // ctrlMemory

#endif // __CTRLMEMORY_MANAGER_LOCKDUMPMANAGERSRV_HPP__

示例#19
0
void CompareObjects::visit(const camp::Function& function)
{
    SLM_TRACE_FUNC();
}

//-----------------------------------------------------------------------------

std::string CompareObjects::getPath(const std::string& property) const
{
    return m_prefix + (!m_prefix.empty() ? "." : "") + property;
}

//-----------------------------------------------------------------------------

void CompareObjects::compare(SPTR(::fwData::Object) objRef, SPTR(::fwData::Object) objComp)
    throw (::fwCore::Exception)
{
    if(objRef->getClassname() != objComp->getClassname())
    {
        std::stringstream ss;
        ss << "Classnames mismatch : '" << objRef->getClassname() << "' (reference object) vs. '"
            << objComp->getClassname() << "' (compared object)";
        throw ::fwCore::Exception(ss.str());
    }

    m_objRef = objRef;
    m_objComp = objComp;

    SLM_ASSERT("Reference object not defined", m_objRef);
    m_campObj = ::camp::UserObject(m_objRef.get());
示例#20
0
 * @brief TemplateID base class used to write templates
 */
template< class DATATYPE >
class GDCMIO_CLASS_API TemplateID
{

public:
    /**
     * @brief Constructor
     * @param[in] dicomSeries DicomSeries used to access computed tag values.
     * @param[in] reader GDCM reader that must be used to read series.
     * @param[in] instance DICOM instance used to share informations between modules
     * @param[in] object FW4SPL data object
     */
    GDCMIO_API TemplateID(
        SPTR(::fwDicomData::DicomSeries) dicomSeries,
        SPTR(::gdcm::Reader) reader,
        SPTR(::gdcmIO::container::DicomInstance) instance,
        SPTR(DATATYPE) object);

    /// Destructor
    GDCMIO_API virtual ~TemplateID();

protected:

    /// Dicom Series
    SPTR(::fwDicomData::DicomSeries) m_dicomSeries;

    /// GDCM Reader
    SPTR(::gdcm::Reader) m_reader;
示例#21
0
{
    if(m_description->text().trimmed().toStdString() == s_INSERT_NEW_SERIES_TEXT)
    {
        m_palette.setColor(QPalette::Base, QColor(Qt::red));
    }
    else
    {
        m_palette.setColor(QPalette::Base, QColor(Qt::white));
    }

    m_description->setPalette(m_palette);
}

//-----------------------------------------------------------------------------

void SeriesEditor::setSeries(SPTR(::fwMedData::Series)series)
{
    SLM_ASSERT("Given series is null", series);
    m_series = series;

    m_modality->setText(QString::fromStdString(m_series->getModality()).trimmed());
    m_description->setText(QString::fromStdString(m_series->getDescription()).trimmed());
    m_date->setText(QString::fromStdString(series->getDate()).trimmed());
    m_time->setText(QString::fromStdString(series->getTime()).trimmed());

    // force signal (manage empty text case)
    this->onTimeChanged(m_time->text());
    this->onDateChanged(m_date->text());

    m_physicians->getListWidget()->clear();
    for(::fwMedData::DicomValueType value :  m_series->getPerformingPhysiciansName())
示例#22
0
        {
            ::fwAtomConversion::mapper::registry::get()->addFactory(
                    functorKey,
                    &::fwAtomConversion::mapper::factory::New<T>
                    );
        }
    };

    virtual ~Base(){};

    /**
     * @brief Convert a ::fwData::Object to a ::fwAtoms::Object.
     * @param object data to convert
     * @param cache  cache to register the data already converted, used when a data is referenced multiple times.
     */
    FWATOMCONVERSION_API virtual SPTR(::fwAtoms::Object) convert(SPTR(::fwData::Object) object,
                                                                 DataVisitor::AtomCacheType & cache) = 0;

    /**
     * @brief Convert a ::fwAtoms::Object to a ::fwData::Object.
     * @param atom atom to convert
     * @param cache  cache to register the atoms already converted, used when an atom is referenced multiple times.
     * @param uuidPolicy AtomVisitor's policy
     */
    FWATOMCONVERSION_API virtual SPTR(::fwData::Object) convert(SPTR(::fwAtoms::Object) atom,
                                                                AtomVisitor::DataCacheType & cache,
                                                                const AtomVisitor::IReadPolicy &uuidPolicy
                                                                ) = 0;

};
示例#23
0
    VISUVTKADAPTOR_API void updateOptionsMode();

protected:

   VISUVTKADAPTOR_API void doStart    () throw(fwTools::Failed);
   VISUVTKADAPTOR_API void configuring() throw(fwTools::Failed);
   VISUVTKADAPTOR_API void doStop     () throw(fwTools::Failed);
   VISUVTKADAPTOR_API void doSwap   () throw(fwTools::Failed);
   VISUVTKADAPTOR_API void doUpdate   () throw(fwTools::Failed);
   VISUVTKADAPTOR_API void doReceive   (::fwServices::ObjectMsg::csptr msg) throw(fwTools::Failed);


    vtkActor *newActor();
    void buildPipeline();

    void updateMesh ( SPTR(::fwData::Mesh) mesh );

    void setServiceOnMaterial(
        ::fwRenderVTK::IVtkAdaptorService::sptr &srv,
        SPTR(::fwData::Material) material
        );

    void removePlaneCollectionShifterCommand();
    void removeServicesStarterCommand();
    void createServicesStarterCommand();

    void createTransformService();
    void createNormalsService();
    void removeNormalsService();

    bool   m_showClippedPart;
示例#24
0
void LoggerInitializer::initialize()
{
    WPTR(LoggerInitializer) reg = SPTR(LoggerInitializer)(new LoggerInitializer) ;
}
示例#25
0
namespace helper
{

void roundSpacing( SPTR(::fwData::Image) image);

} //namespace helper
示例#26
0
int main()
{
  int res = 0;
  int i;
  int x;
  int *xp;
  struct s * sp;

  PTR(B)[0] = 1;
  PTR(B)[1] = 2;
  PTR(B)[2] = 3;
  PTR(B)[3] = 4;
  SPTR(C)->f1 = 5;
  SPTR(D)->f2 = 6;
#ifdef DEBUG
  printf("Address of a: %p\n",&a);
  printf("Address of b: %p\n",&b[0]);
  printf("Address of c: %p\n",&s.c);
  printf("Address of d: %p\n",&s.d);
#endif
  /* store (non-volatile) to absolute address */
  *PTR(A) = 17;
  /* load (non-volatile) from absolute address */
  x = *PTR(A);
  res += EXPECT(17, x);

  /* store (volatile) to absolute address */
  *VPTR(A) = 23;
  /* load (non-volatile) from absolute address */
  x = *PTR(A);
  res += EXPECT(23, x);

  /* pointer arithmetic */
  xp = PTR(B);
  for(i = 0; i < 3; i++) {
    if(*(PTR(B)+i) == 3) xp=PTR(B)+i;
  }
  x = *xp;
  res += EXPECT(3,x);


  /* Structs, larger base offset */
  res += EXPECT(11, SPTR(C)->f1 + SPTR(D)->f2);

  /* Moving around in a larger memory area */
  x  = 0;
  sp = SPTR(C);
  i  = 0;

  while(sp <= SPTR(D))
  {
#ifdef DEBUG
      printf("Writing at %p\n",sp);
#endif
      sp->f1 = 0xafe;
      sp += STEP;
      if(i++ > 32) break;
  }
  i = 0;
  while(sp >= SPTR(C) + STEP)
  {
#ifdef DEBUG
      printf("Reading at %p\n",sp);
#endif
      sp -= STEP;
      x += sp->f1;
      if(i++ > 32) break;
  }
  dbg = i;
  res += EXPECT(5*0xafe, x);

  return res; /* expecting: 0 */
}
示例#27
0
    VISUVTKADAPTOR_API void configuring() override;
    VISUVTKADAPTOR_API void starting() override;
    VISUVTKADAPTOR_API void updating() override;
    VISUVTKADAPTOR_API void stopping() override;

    /**
     * @brief Returns proposals to connect service slots to associated object signals,
     * this method is used for obj/srv auto connection
     *
     * Connect Image::s_MODIFIED_SIG to this::s_UPDATE_SLOT
     * Connect Image::s_BUFFER_MODIFIED_SIG to this::s_UPDATE_SLOT
     */
    VISUVTKADAPTOR_API virtual KeyConnectionsMap getAutoConnections() const override;

    /// Slot called when a texture must be applied on a material.
    void applyTexture( SPTR(::fwData::Material) _material);

    /// Contains all mesh adaptors that currently have this texture applied. Needed when image is updated.
    std::set< SPTR(::fwData::Material) > m_materialSet;

    /// How to filter this texture
    std::string m_filtering;

    /// How to wrap the texture
    std::string m_wrapping;

    /// enable or not the lighting (default true)
    bool m_lighting;
};

} //namespace visuVTKAdaptor
示例#28
0
文件: tox.c 项目: Boerde/uTox
static void tox_thread_message(Tox *tox, ToxAv *av, uint64_t time, uint8_t msg, uint16_t param1, uint16_t param2, void *data)
{
    switch(msg) {
    case TOX_SETNAME: {
        /* param1: name length
         * data: name
         */
        tox_set_name(tox, data, param1);
        break;
    }

    case TOX_SETSTATUSMSG: {
        /* param1: status length
         * data: status message
         */
        tox_set_status_message(tox, data, param1);
        break;
    }

    case TOX_SETSTATUS: {
        /* param1: status
         */
        tox_set_user_status(tox, param1);
        break;
    }

    case TOX_ADDFRIEND: {
        /* param1: length of message
         * data: friend id + message
         */
        int r;

        if(!param1) {
            STRING* default_add_msg = SPTR(DEFAULT_FRIEND_REQUEST_MESSAGE);
            r = tox_add_friend(tox, data, default_add_msg->str, default_add_msg->length);
        } else {
            r = tox_add_friend(tox, data, data + TOX_FRIEND_ADDRESS_SIZE, param1);
        }

        if(r < 0) {
            uint8_t addf_error;
            switch(r) {
            case TOX_FAERR_TOOLONG:
                addf_error = ADDF_TOOLONG; break;
            case TOX_FAERR_NOMESSAGE:
                addf_error = ADDF_NOMESSAGE; break;
            case TOX_FAERR_OWNKEY:
                addf_error = ADDF_OWNKEY; break;
            case TOX_FAERR_ALREADYSENT:
                addf_error = ADDF_ALREADYSENT; break;
            case TOX_FAERR_BADCHECKSUM:
                addf_error = ADDF_BADCHECKSUM; break;
            case TOX_FAERR_SETNEWNOSPAM:
                addf_error = ADDF_SETNEWNOSPAM; break;
            case TOX_FAERR_NOMEM:
                addf_error = ADDF_NOMEM; break;
            case TOX_FAERR_UNKNOWN:
            default:
                addf_error = ADDF_UNKNOWN; break;
            }
            postmessage(FRIEND_ADD, 1, addf_error, data);
        } else {
            postmessage(FRIEND_ADD, 0, r, data);
        }
        break;
    }

    case TOX_DELFRIEND: {
        /* param1: friend #
         */
        tox_del_friend(tox, param1);
        postmessage(FRIEND_DEL, 0, 0, data);
        break;
    }

    case TOX_ACCEPTFRIEND: {
        /* data: FRIENDREQ
         */
        FRIENDREQ *req = data;
        int r = tox_add_friend_norequest(tox, req->id);
        postmessage(FRIEND_ACCEPT, (r < 0), (r < 0) ? 0 : r, req);
        break;
    }

    case TOX_SENDMESSAGE: {
        /* param1: friend #
         * param2: message length
         * data: message
         */
        log_write(tox, param1, data, param2, 1, LOG_FILE_MSG_TYPE_TEXT);

        void *p = data;
        while(param2 > TOX_MAX_MESSAGE_LENGTH) {
            uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen(p + TOX_MAX_MESSAGE_LENGTH);
            tox_send_message(tox, param1, p, len);
            param2 -= len;
            p += len;
        }

        tox_send_message(tox, param1, p, param2);
        free(data);
        break;
    }

    case TOX_SENDACTION: {
        /* param1: friend #
         * param2: message length
         * data: message
         */

        log_write(tox, param1, data, param2, 1, LOG_FILE_MSG_TYPE_ACTION);

        void *p = data;
        while(param2 > TOX_MAX_MESSAGE_LENGTH) {
            uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen(p + TOX_MAX_MESSAGE_LENGTH);
            tox_send_action(tox, param1, p, len);
            param2 -= len;
            p += len;
        }

        tox_send_action(tox, param1, p, param2);
        free(data);
        break;
    }

    case TOX_SENDMESSAGEGROUP: {
        /* param1: group #
         * param2: message length
         * data: message
         */
        tox_group_message_send(tox, param1, data, param2);
        free(data);
        break;
    }

    case TOX_SENDACTIONGROUP: {
        /* param1: group #
         * param2: message length
         * data: message
         */
        tox_group_action_send(tox, param1, data, param2);
        free(data);
    }

    case TOX_SET_TYPING: {
        /* param1: friend #
         */

        // Check if user has switched to another friend window chat.
        // Take care not to react on obsolete data from old Tox instance.
        _Bool need_resetting = (typing_state.tox == tox) &&
            (typing_state.friendnumber != param1) &&
            (typing_state.sent_value);

        if(need_resetting) {
            // Tell previous friend that he's betrayed.
            tox_set_user_is_typing(tox, typing_state.friendnumber, 0);
            // Mark that new friend doesn't know that we're typing yet.
            typing_state.sent_value = 0;
        }

        // Mark us as typing to this friend at the moment.
        // utox_thread_work_for_typing_notifications() will
        // send a notification if it deems necessary.
        typing_state.tox = tox;
        typing_state.friendnumber = param1;
        typing_state.time = time;

        //debug("Set typing state for friend (%d): %d\n", typing_state.friendnumber, typing_state.sent_value);
        break;
    }

    case TOX_CALL: {
        /* param1: friend #
         */
        int32_t id;
        toxav_call(av, &id, param1, &av_DefaultSettings, 10);

        postmessage(FRIEND_CALL_STATUS, param1, id, (void*)CALL_RINGING);
        break;
    }

    case TOX_CALL_VIDEO: {
        /* param1: friend #
         */
        ToxAvCSettings settings = av_DefaultSettings;
        settings.call_type = av_TypeVideo;
        settings.max_video_width = max_video_width;
        settings.max_video_height = max_video_height;

        int32_t id;
        toxav_call(av, &id, param1, &settings, 10);

        postmessage(FRIEND_CALL_STATUS, param1, id, (void*)CALL_RINGING_VIDEO);
        break;
    }

    case TOX_CALL_VIDEO_ON: {
        /* param1: friend #
         * param2: call #
         */
        ToxAvCSettings settings = av_DefaultSettings;
        settings.call_type = av_TypeVideo;
        settings.max_video_width = max_video_width;
        settings.max_video_height = max_video_height;

        toxav_change_settings(av, param2, &settings);
        postmessage(FRIEND_CALL_START_VIDEO, param1, param2, NULL);
        break;
    }

    case TOX_CALL_VIDEO_OFF: {
        /* param1: friend #
         * param2: call #
         */
        toxav_change_settings(av, param2, &av_DefaultSettings);
        postmessage(FRIEND_CALL_STOP_VIDEO, param1, param2, NULL);
        break;
    }

    case TOX_ACCEPTCALL: {
        /* param1: call #
         */
        ToxAvCSettings settings = av_DefaultSettings;
        if(param2) {
            settings.call_type = av_TypeVideo;
            settings.max_video_width = max_video_width;
            settings.max_video_height = max_video_height;
        }

        toxav_answer(av, param1, &settings);
        break;
    }

    case TOX_HANGUP: {
        /* param1: call #
         */
        toxav_hangup(av, param1);
        break;
    }

    case TOX_NEWGROUP: {
        /*
         */
        int g = -1;
        if (param1) {
            g = toxav_add_av_groupchat(tox, &callback_av_group_audio, NULL);
        } else {
            g = tox_add_groupchat(tox);
        }
        if(g != -1) {
            postmessage(GROUP_ADD, g, 0, tox);
        }

        break;
    }

    case TOX_LEAVEGROUP: {
        /* param1: group #
         */
        tox_del_groupchat(tox, param1);
        break;
    }

    case TOX_GROUPINVITE: {
        /* param1: group #
         * param2: friend #
         */
        tox_invite_friend(tox, param2, param1);
        break;
    }

    case TOX_GROUPCHANGETOPIC: {
        /* param1: group #
         * param2: topic length
         * data: topic
         */
        tox_group_set_title(tox, param1, data, param2);
        postmessage(GROUP_TITLE, param1, param2, data);
        break;
    }

    case TOX_GROUP_AUDIO_START:{
        /* param1: group #
         */
        postmessage(GROUP_AUDIO_START, param1, 0, NULL);
        break;
    }

    case TOX_GROUP_AUDIO_END:{
        /* param1: group #
         */
        postmessage(GROUP_AUDIO_END, param1, 0, NULL);
        break;
    }

    case TOX_SENDFILES: {
        /* param1: friend #
         * param2: offset of first file name in data
         * data: file names
         */

        if(param2 == 0xFFFF) {
            //paths with line breaks
            uint8_t *name = data, *p = data, *s = name;
            while(*p) {
                _Bool end = 1;
                while(*p) {
                    if(*p == '\n') {
                        *p = 0;
                        end = 0;
                        break;
                    }

                    if(*p == '/' || *p == '\\') {
                        s = p + 1;
                    }
                    p++;
                }

                if(strcmp2(name, "file://") == 0) {
                    name += 7;
                }

                utox_transfer_start_file(tox, param1, name, s, p - s);
                p++;
                s = name = p;

                if(end) {
                    break;
                }
            }
        } else {
            //windows path list
            uint8_t *name = data;
            _Bool multifile = (name[param2 - 1] == 0);
            if(!multifile) {
                utox_transfer_start_file(tox, param1, data, data + param2, strlen(data) - param2);
            } else {
                uint8_t *p = name + param2;
                name += param2 - 1;
                if(*(name - 1) != '\\') {
                    *name++ = '\\';
                }
                while(*p) {
                    int len = strlen((char*)p) + 1;
                    memmove(name, p, len);
                    p += len;
                    utox_transfer_start_file(tox, param1, data, name, len - 1);
                }
            }
        }

        free(data);

        break;
    }

    case TOX_SEND_INLINE: {
        /* param1: friend id
           data: pointer to a TOX_SEND_INLINE_MSG struct
         */
        struct TOX_SEND_INLINE_MSG *tsim = data;
        utox_transfer_start_memory(tox, param1, tsim->image->png_data, tsim->image_size);
        free(tsim);

        break;
    }

    case TOX_ACCEPTFILE: {
        /* param1: friend #
         * param2: file #
         * data: path to write file
         */
        FILE_T *ft = &friend[param1].incoming[param2];
        ft->data = fopen(data, "wb");
        if(!ft->data) {
            free(data);
            break;
        }

        ft->path = data;
        ft->status = FT_SEND;

        tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_ACCEPT, NULL, 0);

        postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_OK);
        break;
    }

    case TOX_FILE_IN_CANCEL:
    {
        /* param1: friend #
         * param2: file #
         */
        FILE_T *ft = &friend[param1].incoming[param2];
        if(ft->data) {
            if(ft->inline_png) {
                free(ft->data);
            } else {
                fclose(ft->data);
                free(ft->path);
            }
        }

        ft->status = FT_NONE;
        tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_KILL, NULL, 0);
        postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_KILLED);
        break;
    }

    case TOX_FILE_OUT_CANCEL:
    {
        /* param1: friend #
         * param2: file #
         */
        FILE_T *ft = &friend[param1].outgoing[param2];
        ft->status = FT_KILL;
        tox_file_send_control(tox, param1, 0, param2, TOX_FILECONTROL_KILL, NULL, 0);
        postmessage(FRIEND_FILE_OUT_STATUS, param1, param2, (void*)FILE_KILLED);
        break;
    }

    case TOX_FILE_IN_PAUSE:
    {
        /* param1: friend #
         * param2: file #
         */
        tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_PAUSE, NULL, 0);
        postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_PAUSED);
        break;
    }

    case TOX_FILE_OUT_PAUSE:
    {
        /* param1: friend #
         * param2: file #
         */
        FILE_T *ft = &friend[param1].outgoing[param2];
        ft->status = FT_PAUSE;
        tox_file_send_control(tox, param1, 0, param2, TOX_FILECONTROL_PAUSE, NULL, 0);
        postmessage(FRIEND_FILE_OUT_STATUS, param1, param2, (void*)FILE_PAUSED);
        break;
    }

    case TOX_FILE_IN_RESUME:
    {
        /* param1: friend #
         * param2: file #
         */
        tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_ACCEPT, NULL, 0);
        postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_OK);
        break;
    }

    case TOX_FILE_OUT_RESUME:
    {
        /* param1: friend #
         * param2: file #
         */
        FILE_T *ft = &friend[param1].outgoing[param2];
        ft->status = FT_SEND;
        tox_file_send_control(tox, param1, 0, param2, TOX_FILECONTROL_ACCEPT, NULL, 0);
        postmessage(FRIEND_FILE_OUT_STATUS, param1, param2, (void*)FILE_OK);
        break;
    }

    }
}
示例#29
0
 * @class TemplateID
 * @brief TemplateID base class used to write templates
 */
template< class DATATYPE >
class GDCMIO_CLASS_API TemplateID
{

public:
    /**
     * @brief Constructor
     * @param[in] writer GDCM writer that must be enriched
     * @param[in] instance DICOM instance used to share informations between modules
     * @param[in] object FW4SPL data object
     */
    GDCMIO_API TemplateID(
            SPTR(::gdcm::Writer) writer,
            SPTR(::gdcmIO::container::DicomInstance) instance,
            SPTR(DATATYPE) object);

    /// Destructor
    GDCMIO_API virtual ~TemplateID();

protected:

    /// GDCM Writer
    SPTR(::gdcm::Writer) m_writer;

    /// DICOM Instance
    SPTR(::gdcmIO::container::DicomInstance) m_instance;

    /// FW4SPL Object
示例#30
0
void SpatialFiducialsIOD::read(::fwMedData::Series::sptr series) throw (::fwGdcmIO::exception::Failed)
{
    // Retrieve images
    ::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
    SLM_ASSERT("ImageSeries should not be null.", imageSeries);
    ::fwData::Image::sptr image = imageSeries->getImage();
    SLM_ASSERT("::fwData::Image not instanced", image);

    // Create GDCM Reader
    SPTR(::gdcm::Reader) reader = std::shared_ptr< ::gdcm::Reader >( new ::gdcm::Reader );

    // Read the first file
    ::fwMedData::DicomSeries::DicomContainerType dicomContainer = m_dicomSeries->getDicomContainer();

    if(dicomContainer.size() > 1)
    {
        m_logger->warning("More than one Spatial Fiducials item have been found in the series. "
                          "Only the first one will be read.");
    }

    const ::fwMemory::BufferObject::sptr bufferObj         = dicomContainer.begin()->second;
    const ::fwMemory::BufferManager::StreamInfo streamInfo = bufferObj->getStreamInfo();
    SPTR(std::istream) is = streamInfo.stream;
    reader->SetStream(*is);

    const bool success = reader->Read();
    FW_RAISE_EXCEPTION_IF(::fwGdcmIO::exception::Failed("Unable to read the DICOM instance \""+
                                                        bufferObj->getStreamInfo().fsFile.string()+
                                                        "\" using the GDCM Reader."), !success);

    // Create Information Entity helpers
    ::fwGdcmIO::reader::ie::SpatialFiducials spatialFiducialsIE(
        m_dicomSeries, reader, m_instance, imageSeries->getImage(),
        m_logger, m_progressCallback, m_cancelRequestedCallback);

    // Retrieve dataset
    const ::gdcm::DataSet& datasetRoot = reader->GetFile().GetDataSet();

    // Retrieve Fiducial Set Sequence
    const ::gdcm::DataElement& fiducialSetSequenceDataElement =
        datasetRoot.GetDataElement( ::gdcm::Tag(0x0070, 0x031C) );
    const ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > fiducialSetSequence =
        fiducialSetSequenceDataElement.GetValueAsSQ();

    for(unsigned int i = 1; i <= fiducialSetSequence->GetNumberOfItems(); ++i)
    {
        ::gdcm::Item sequenceSetItem = fiducialSetSequence->GetItem(i);
        const ::gdcm::DataSet& sequenceSetDataset = sequenceSetItem.GetNestedDataSet();

        const ::gdcm::DataElement& fiducialSequenceDataElement =
            sequenceSetDataset.GetDataElement( ::gdcm::Tag(0x0070, 0x031E) );
        const ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > fiducialSequence =
            fiducialSequenceDataElement.GetValueAsSQ();

        for(unsigned int j = 1; j <= fiducialSequence->GetNumberOfItems(); ++j)
        {
            ::gdcm::Item fiducialItem = fiducialSequence->GetItem(j);
            const ::gdcm::DataSet& fiducialDataset = fiducialItem.GetNestedDataSet();
            const std::string shapeType            =
                ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0070, 0x0306>(fiducialDataset);

            if(shapeType == "POINT")
            {
                spatialFiducialsIE.readLandmark(fiducialDataset);
            }
            else
            {
                m_logger->warning("Fiducial shape type not supported: \"" + shapeType + "\"");
            }
        }

    }
}