<commit_before>#include "uptane/uptanerepository.h"

#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/make_shared.hpp>

#include "boost/algorithm/hex.hpp"

#include "crypto.h"
#include "logger.h"
#include "openssl_compat.h"
#include "ostree.h"
#include "utils.h"

namespace Uptane {

Repository::Repository(const Config &config_in)
    : config(config_in),
      director("director", config.uptane.director_server, config),
      image("repo", config.uptane.repo_server, config),
      http(),
      manifests(Json::arrayValue),
      transport(&secondaries) {
  std::vector<Uptane::SecondaryConfig>::iterator it;
  for (it = config.uptane.secondaries.begin(); it != config.uptane.secondaries.end(); ++it) {
    Secondary s(*it, this);
    addSecondary(it->ecu_serial, it->ecu_hardware_id);
    secondaries.push_back(s);
  }
}

void Repository::updateRoot(Version version) {
  director.updateRoot(version);
  image.updateRoot(version);
}

void Repository::putManifest() { putManifest(Json::nullValue); }

void Repository::putManifest(const Json::Value &custom) {
  Json::Value version_manifest;
  version_manifest["primary_ecu_serial"] = config.uptane.primary_ecu_serial;
  version_manifest["ecu_version_manifest"] = transport.getManifests();

  Json::Value unsigned_ecu_version =
      OstreePackage::getEcu(config.uptane.primary_ecu_serial, config.ostree.sysroot).toEcuVersion(custom);
  Json::Value ecu_version_signed =
      Crypto::signTuf(config.uptane.private_key_path, config.uptane.public_key_path, unsigned_ecu_version);
  version_manifest["ecu_version_manifest"].append(ecu_version_signed);
  Json::Value tuf_signed =
      Crypto::signTuf(config.uptane.private_key_path, config.uptane.public_key_path, version_manifest);
  http.put(config.uptane.director_server + "/manifest", tuf_signed);
}

void Repository::refresh() {
  director.updateRoot(Version());
  image.updateRoot(Version());
  image.fetchAndCheckRole(Role::Snapshot());
  image.fetchAndCheckRole(Role::Timestamp());
}

std::vector<Uptane::Target> Repository::getNewTargets() {
  refresh();

  std::vector<Uptane::Target> director_targets = director.fetchTargets();
  std::vector<Uptane::Target> image_targets = image.fetchTargets();
  std::vector<Uptane::Target> primary_targets;
  std::vector<Uptane::Target> secondary_targets;

  if (!director_targets.empty()) {
    OstreePackage installed_package = OstreePackage::getEcu(config.uptane.primary_ecu_serial, config.ostree.sysroot);
    for (std::vector<Uptane::Target>::iterator it = director_targets.begin(); it != director_targets.end(); ++it) {
      if (it->ecu_identifier() == config.uptane.primary_ecu_serial) {
        if (it->MatchWith(Hash(Hash::kSha256, installed_package.ref_name))) {
          LOGGER_LOG(LVL_debug, "Ostree package with hash " << installed_package.ref_name
                                                            << " already installed, skipping.");
          continue;
        }
      }
      std::vector<Uptane::Target>::iterator image_target_it;
      image_target_it = std::find(image_targets.begin(), image_targets.end(), *it);
      if (image_target_it != image_targets.end()) {
        image.saveTarget(*image_target_it);
        if (it->ecu_identifier() == config.uptane.primary_ecu_serial) {
          primary_targets.push_back(*it);
        } else {
          secondary_targets.push_back(*it);
        }
      } else {
        throw MissMatchTarget("director and image");
      }
    }
    transport.sendTargets(secondary_targets);
  }
  return primary_targets;
}

bool Repository::deviceRegister() {
  std::string bootstrap_pkey_pem = (config.device.certificates_directory / "bootstrap_pkey.pem").string();
  std::string bootstrap_cert_pem = (config.device.certificates_directory / "bootstrap_cert.pem").string();
  std::string bootstrap_ca_pem = (config.device.certificates_directory / "bootstrap_ca.pem").string();

  FILE *reg_p12 = fopen((config.device.certificates_directory / config.provision.p12_path).c_str(), "rb");
  if (!reg_p12) {
    LOGGER_LOG(LVL_error, "Could not open " << config.device.certificates_directory / config.provision.p12_path);
    return false;
  }

  if (!Crypto::parseP12(reg_p12, config.provision.p12_password, bootstrap_pkey_pem, bootstrap_cert_pem,
                        bootstrap_ca_pem)) {
    fclose(reg_p12);
    return false;
  }
  fclose(reg_p12);

  http.setCerts(bootstrap_ca_pem, bootstrap_cert_pem, bootstrap_pkey_pem);

  Json::Value data;
  data["deviceId"] = config.uptane.device_id;
  data["ttl"] = config.provision.expiry_days;
  HttpResponse response = http.post(config.tls.server + "/devices", data);
  if (!response.isOk()) {
    LOGGER_LOG(LVL_error, "error tls registering device, response: " << response.body);
    return false;
  }

  FILE *device_p12 = fmemopen(const_cast<char *>(response.body.c_str()), response.body.size(), "rb");
  if (!Crypto::parseP12(device_p12, "", (config.device.certificates_directory / config.tls.pkey_file).string(),
                        (config.device.certificates_directory / config.tls.client_certificate).string(),
                        (config.device.certificates_directory / config.tls.ca_file).string())) {
    return false;
  }
  fclose(device_p12);
  return true;
}

bool Repository::authenticate() {
  return http.authenticate((config.device.certificates_directory / config.tls.client_certificate).string(),
                           (config.device.certificates_directory / config.tls.ca_file).string(),
                           (config.device.certificates_directory / config.tls.pkey_file).string());
}

bool Repository::ecuRegister() {
  if (!Crypto::generateRSAKeyPair(config.uptane.public_key_path, config.uptane.private_key_path)) {
    LOGGER_LOG(LVL_error, "Could not generate rsa keys for primary.");
    return false;
  }

  Json::Value all_ecus;
  all_ecus["primary_ecu_serial"] = config.uptane.primary_ecu_serial;
  all_ecus["ecus"] = Json::Value(Json::arrayValue);

  PublicKey primary_pub_key(config.uptane.public_key_path);
  Json::Value primary_ecu;
  primary_ecu["hardware_identifier"] = config.uptane.primary_ecu_hardware_id;
  primary_ecu["ecu_serial"] = config.uptane.primary_ecu_serial;
  primary_ecu["clientKey"]["keytype"] = "RSA";
  primary_ecu["clientKey"]["keyval"]["public"] = primary_pub_key.value;
  all_ecus["ecus"].append(primary_ecu);
  std::vector<SecondaryConfig>::iterator it;
  for (it = registered_secondaries.begin(); it != registered_secondaries.end(); ++it) {
    std::string pub_path = (config.device.certificates_directory / (it->ecu_serial + ".pub")).string();
    std::string priv_path = (config.device.certificates_directory / (it->ecu_serial + ".priv")).string();
    Crypto::generateRSAKeyPair(pub_path, priv_path);
    transport.sendPrivateKey(it->ecu_serial, Utils::readFile(priv_path));
    Json::Value ecu;
    ecu["hardware_identifier"] = it->ecu_hardware_id;
    ecu["ecu_serial"] = it->ecu_serial;
    ecu["clientKey"]["keytype"] = "RSA";
    ecu["clientKey"]["keyval"]["public"] = Utils::readFile(pub_path);
    all_ecus["ecus"].append(ecu);
  }

  authenticate();
  HttpResponse response = http.post(config.tls.server + "/director/ecus", all_ecus);
  if (!response.isOk()) {
    LOGGER_LOG(LVL_error, "Error registering device on Uptane, response: " << response.body);
    return false;
  }
  return true;
}

void Repository::addSecondary(const std::string &ecu_serial, const std::string &hardware_identifier) {
  SecondaryConfig c;
  c.ecu_serial = ecu_serial;
  c.ecu_hardware_id = hardware_identifier;
  registered_secondaries.push_back(c);
}
};
<commit_msg>use hash instead of refname<commit_after>#include "uptane/uptanerepository.h"

#include <openssl/bio.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/make_shared.hpp>

#include "boost/algorithm/hex.hpp"

#include "crypto.h"
#include "logger.h"
#include "openssl_compat.h"
#include "ostree.h"
#include "utils.h"

namespace Uptane {

Repository::Repository(const Config &config_in)
    : config(config_in),
      director("director", config.uptane.director_server, config),
      image("repo", config.uptane.repo_server, config),
      http(),
      manifests(Json::arrayValue),
      transport(&secondaries) {
  std::vector<Uptane::SecondaryConfig>::iterator it;
  for (it = config.uptane.secondaries.begin(); it != config.uptane.secondaries.end(); ++it) {
    Secondary s(*it, this);
    addSecondary(it->ecu_serial, it->ecu_hardware_id);
    secondaries.push_back(s);
  }
}

void Repository::updateRoot(Version version) {
  director.updateRoot(version);
  image.updateRoot(version);
}

void Repository::putManifest() { putManifest(Json::nullValue); }

void Repository::putManifest(const Json::Value &custom) {
  Json::Value version_manifest;
  version_manifest["primary_ecu_serial"] = config.uptane.primary_ecu_serial;
  version_manifest["ecu_version_manifest"] = transport.getManifests();

  Json::Value unsigned_ecu_version =
      OstreePackage::getEcu(config.uptane.primary_ecu_serial, config.ostree.sysroot).toEcuVersion(custom);
  Json::Value ecu_version_signed =
      Crypto::signTuf(config.uptane.private_key_path, config.uptane.public_key_path, unsigned_ecu_version);
  version_manifest["ecu_version_manifest"].append(ecu_version_signed);
  Json::Value tuf_signed =
      Crypto::signTuf(config.uptane.private_key_path, config.uptane.public_key_path, version_manifest);
  http.put(config.uptane.director_server + "/manifest", tuf_signed);
}

void Repository::refresh() {
  director.updateRoot(Version());
  image.updateRoot(Version());
  image.fetchAndCheckRole(Role::Snapshot());
  image.fetchAndCheckRole(Role::Timestamp());
}

std::vector<Uptane::Target> Repository::getNewTargets() {
  refresh();

  std::vector<Uptane::Target> director_targets = director.fetchTargets();
  std::vector<Uptane::Target> image_targets = image.fetchTargets();
  std::vector<Uptane::Target> primary_targets;
  std::vector<Uptane::Target> secondary_targets;

  if (!director_targets.empty()) {
    OstreePackage installed_package = OstreePackage::getEcu(config.uptane.primary_ecu_serial, config.ostree.sysroot);
    for (std::vector<Uptane::Target>::iterator it = director_targets.begin(); it != director_targets.end(); ++it) {
      if (it->ecu_identifier() == config.uptane.primary_ecu_serial) {
        if (it->MatchWith(Hash(Hash::kSha256, installed_package.refhash))) {
          LOGGER_LOG(LVL_debug, "Ostree package with hash " << installed_package.ref_name
                                                            << " already installed, skipping.");
          continue;
        }
      }
      std::vector<Uptane::Target>::iterator image_target_it;
      image_target_it = std::find(image_targets.begin(), image_targets.end(), *it);
      if (image_target_it != image_targets.end()) {
        image.saveTarget(*image_target_it);
        if (it->ecu_identifier() == config.uptane.primary_ecu_serial) {
          primary_targets.push_back(*it);
        } else {
          secondary_targets.push_back(*it);
        }
      } else {
        throw MissMatchTarget("director and image");
      }
    }
    transport.sendTargets(secondary_targets);
  }
  return primary_targets;
}

bool Repository::deviceRegister() {
  std::string bootstrap_pkey_pem = (config.device.certificates_directory / "bootstrap_pkey.pem").string();
  std::string bootstrap_cert_pem = (config.device.certificates_directory / "bootstrap_cert.pem").string();
  std::string bootstrap_ca_pem = (config.device.certificates_directory / "bootstrap_ca.pem").string();

  FILE *reg_p12 = fopen((config.device.certificates_directory / config.provision.p12_path).c_str(), "rb");
  if (!reg_p12) {
    LOGGER_LOG(LVL_error, "Could not open " << config.device.certificates_directory / config.provision.p12_path);
    return false;
  }

  if (!Crypto::parseP12(reg_p12, config.provision.p12_password, bootstrap_pkey_pem, bootstrap_cert_pem,
                        bootstrap_ca_pem)) {
    fclose(reg_p12);
    return false;
  }
  fclose(reg_p12);

  http.setCerts(bootstrap_ca_pem, bootstrap_cert_pem, bootstrap_pkey_pem);

  Json::Value data;
  data["deviceId"] = config.uptane.device_id;
  data["ttl"] = config.provision.expiry_days;
  HttpResponse response = http.post(config.tls.server + "/devices", data);
  if (!response.isOk()) {
    LOGGER_LOG(LVL_error, "error tls registering device, response: " << response.body);
    return false;
  }

  FILE *device_p12 = fmemopen(const_cast<char *>(response.body.c_str()), response.body.size(), "rb");
  if (!Crypto::parseP12(device_p12, "", (config.device.certificates_directory / config.tls.pkey_file).string(),
                        (config.device.certificates_directory / config.tls.client_certificate).string(),
                        (config.device.certificates_directory / config.tls.ca_file).string())) {
    return false;
  }
  fclose(device_p12);
  return true;
}

bool Repository::authenticate() {
  return http.authenticate((config.device.certificates_directory / config.tls.client_certificate).string(),
                           (config.device.certificates_directory / config.tls.ca_file).string(),
                           (config.device.certificates_directory / config.tls.pkey_file).string());
}

bool Repository::ecuRegister() {
  if (!Crypto::generateRSAKeyPair(config.uptane.public_key_path, config.uptane.private_key_path)) {
    LOGGER_LOG(LVL_error, "Could not generate rsa keys for primary.");
    return false;
  }

  Json::Value all_ecus;
  all_ecus["primary_ecu_serial"] = config.uptane.primary_ecu_serial;
  all_ecus["ecus"] = Json::Value(Json::arrayValue);

  PublicKey primary_pub_key(config.uptane.public_key_path);
  Json::Value primary_ecu;
  primary_ecu["hardware_identifier"] = config.uptane.primary_ecu_hardware_id;
  primary_ecu["ecu_serial"] = config.uptane.primary_ecu_serial;
  primary_ecu["clientKey"]["keytype"] = "RSA";
  primary_ecu["clientKey"]["keyval"]["public"] = primary_pub_key.value;
  all_ecus["ecus"].append(primary_ecu);
  std::vector<SecondaryConfig>::iterator it;
  for (it = registered_secondaries.begin(); it != registered_secondaries.end(); ++it) {
    std::string pub_path = (config.device.certificates_directory / (it->ecu_serial + ".pub")).string();
    std::string priv_path = (config.device.certificates_directory / (it->ecu_serial + ".priv")).string();
    Crypto::generateRSAKeyPair(pub_path, priv_path);
    transport.sendPrivateKey(it->ecu_serial, Utils::readFile(priv_path));
    Json::Value ecu;
    ecu["hardware_identifier"] = it->ecu_hardware_id;
    ecu["ecu_serial"] = it->ecu_serial;
    ecu["clientKey"]["keytype"] = "RSA";
    ecu["clientKey"]["keyval"]["public"] = Utils::readFile(pub_path);
    all_ecus["ecus"].append(ecu);
  }

  authenticate();
  HttpResponse response = http.post(config.tls.server + "/director/ecus", all_ecus);
  if (!response.isOk()) {
    LOGGER_LOG(LVL_error, "Error registering device on Uptane, response: " << response.body);
    return false;
  }
  return true;
}

void Repository::addSecondary(const std::string &ecu_serial, const std::string &hardware_identifier) {
  SecondaryConfig c;
  c.ecu_serial = ecu_serial;
  c.ecu_hardware_id = hardware_identifier;
  registered_secondaries.push_back(c);
}
};
<|endoftext|>


<commit_before>#pragma once

#include <mbed.h>
#include <rtos.h>

#include "rtp.hpp"
#include "helper-funcs.hpp"
#include "rtos-mgmt/mail-helper.hpp"
#include "Console.hpp"
#include "CommPort.hpp"

#include <algorithm>
#include <vector>
#include <functional>
#include <memory>

#define COMM_MODULE_SIGNAL_START_THREAD 0x01

/* These define the function pointer type that's used for every callback
 * function type set through the CommModule class.
 */
typedef void(FunctionPtr_t)(rtp::packet*);
typedef CommPort<FunctionPtr_t> CommPort_t;
typedef CommPorts<FunctionPtr_t> CommPorts_t;

// forward declaration of the template is needed for the class
extern CommPort_t _tmpPort;

/**
 * The CommModule class provides the packet management routing
 * by distributing incoming packets to the correct area of the
 * firmware and distributing outgoing packets to the correct
 * hardware interface.
 */

/**
 * @brief      { A high-level firmware class for packet handling & routing }
 */
class CommModule {
private:
    static CommPorts_t _ports;

public:
    ~CommModule();

    // Class constants - set in CommModule.cpp
    static const size_t NBR_PORTS = 16;
    static const size_t TX_QUEUE_SIZE = 5;
    static const size_t RX_QUEUE_SIZE = 5;

    static void Init(void);

    // Set a TX callback function on an object
    template <typename B>
    static void TxHandler(B* obj, void (B::*mptr)(rtp::packet*),
                          uint8_t portNbr) {
        if (!_ports[portNbr].Exists()) {
            CommPort_t _tmpPort(portNbr);

            _tmpPort.TXCallback() = std::bind(mptr, obj, std::placeholders::_1);

            _ports += _tmpPort;

        } else {
            _ports[portNbr].TXCallback() =
                std::bind(mptr, obj, std::placeholders::_1);
        }

        ready();
    }

    // Set an RX callback function on an object
    template <typename B>
    static void RxHandler(B* obj, void (B::*mptr)(rtp::packet*),
                          uint8_t portNbr) {
        if (!_ports[portNbr].Exists()) {
            CommPort_t _tmpPort(portNbr);

            _tmpPort.RXCallback() = std::bind(mptr, obj, std::placeholders::_1);

            _ports += _tmpPort;

        } else {
            _ports[portNbr].RXCallback() =
                std::bind(mptr, obj, std::placeholders::_1);
        }

        ready();
    }

    // Set a normal RX callback function without an object
    static void RxHandler(void (*ptr)(rtp::packet*), uint8_t);
    static void TxHandler(void (*ptr)(rtp::packet*), uint8_t);

    // Open a socket connection for communicating.
    static bool openSocket(uint8_t);

    // Send a rtp::packet. The details of exactly how the packet will be sent
    // are determined from the rtp::packet's port and subclass values
    static void send(const rtp::packet&);
    static void receive(const rtp::packet&);

    static unsigned int NumRXPackets();
    static unsigned int NumTXPackets();

    static void PrintInfo(bool forceHeader = false);

    static void ResetCount(unsigned int portNbr);
    static void Close(unsigned int portNbr);
    static bool isReady(void);
    static int NumOpenSockets(void);

    static void txLED(DigitalInOut*);
    static void rxLED(DigitalInOut*);

protected:
    // NOP function for keeping a communication link active
    void nopFunc(void);

    /// Kill any threads and free the allocated stack.
    /// Always call in any derived class's deconstructors!
    void cleanup(void);

    // Memory Queue IDs
    osMailQId _txQueue;
    osMailQId _rxQueue;

    // Thread IDs
    static osThreadId _txID;
    static osThreadId _rxID;

    DigitalInOut* _rxLED;
    DigitalInOut* _txLED;

private:
    // Private constructor
    CommModule();

    static shared_ptr<CommModule>& Instance();

    // Used to help define the class's threads in the constructor
    friend void define_thread(osThreadDef_t&, void (*task)(void const* arg),
                              osPriority, uint32_t, unsigned char*);

    // The working threads for handeling rx and tx data queues
    static void txThread(void const*);
    static void rxThread(void const*);

    static void ready(void);

    static void PrintHeader(void);

    static std::shared_ptr<CommModule> instance;

    static bool _isReady;

    // Thread and Mail defintion data structures
    osThreadDef_t _txDef;
    osThreadDef_t _rxDef;
    osMailQDef_t _txQDef;
    osMailQDef_t _rxQDef;

    // Mail helper objects
    MailHelper<rtp::packet, TX_QUEUE_SIZE> _txQueueHelper;
    MailHelper<rtp::packet, RX_QUEUE_SIZE> _rxQueueHelper;
};
<commit_msg>minor refactor<commit_after>#pragma once

#include <mbed.h>
#include <rtos.h>

#include "rtp.hpp"
#include "helper-funcs.hpp"
#include "rtos-mgmt/mail-helper.hpp"
#include "Console.hpp"
#include "CommPort.hpp"

#include <algorithm>
#include <vector>
#include <functional>
#include <memory>

#define COMM_MODULE_SIGNAL_START_THREAD 0x01

/* These define the function pointer type that's used for every callback
 * function type set through the CommModule class.
 */
typedef void(FunctionPtr_t)(rtp::packet*);
typedef CommPort<FunctionPtr_t> CommPort_t;
typedef CommPorts<FunctionPtr_t> CommPorts_t;

// forward declaration of the template is needed for the class
extern CommPort_t _tmpPort;

/**
 * The CommModule class provides the packet management routing
 * by distributing incoming packets to the correct area of the
 * firmware and distributing outgoing packets to the correct
 * hardware interface.
 */

/**
 * @brief      { A high-level firmware class for packet handling & routing }
 */
class CommModule {
private:
    static CommPorts_t _ports;

public:
    ~CommModule();

    // Class constants - set in CommModule.cpp
    static const size_t NBR_PORTS = 16;
    static const size_t TX_QUEUE_SIZE = 5;
    static const size_t RX_QUEUE_SIZE = 5;

    static void Init(void);

    // Set a TX callback function on an object
    template <typename B>
    static void TxHandler(B* obj, void (B::*mptr)(rtp::packet*),
                          uint8_t portNbr) {
        if (!_ports[portNbr].Exists()) {
            CommPort_t _tmpPort(portNbr);
            _ports += _tmpPort;
        }

        _ports[portNbr].TXCallback() =
            std::bind(mptr, obj, std::placeholders::_1);

        ready();
    }

    // Set an RX callback function on an object
    template <typename B>
    static void RxHandler(B* obj, void (B::*mptr)(rtp::packet*),
                          uint8_t portNbr) {
        if (!_ports[portNbr].Exists()) {
            CommPort_t _tmpPort(portNbr);
            _ports += _tmpPort;
        }

        _ports[portNbr].RXCallback() =
            std::bind(mptr, obj, std::placeholders::_1);

        ready();
    }

    // Set a normal RX callback function without an object
    static void RxHandler(void (*ptr)(rtp::packet*), uint8_t);
    static void TxHandler(void (*ptr)(rtp::packet*), uint8_t);

    // Open a socket connection for communicating.
    static bool openSocket(uint8_t);

    // Send a rtp::packet. The details of exactly how the packet will be sent
    // are determined from the rtp::packet's port and subclass values
    static void send(const rtp::packet&);
    static void receive(const rtp::packet&);

    static unsigned int NumRXPackets();
    static unsigned int NumTXPackets();

    static void PrintInfo(bool forceHeader = false);

    static void ResetCount(unsigned int portNbr);
    static void Close(unsigned int portNbr);
    static bool isReady(void);
    static int NumOpenSockets(void);

    static void txLED(DigitalInOut*);
    static void rxLED(DigitalInOut*);

protected:
    // NOP function for keeping a communication link active
    void nopFunc(void);

    /// Kill any threads and free the allocated stack.
    /// Always call in any derived class's deconstructors!
    void cleanup(void);

    // Memory Queue IDs
    osMailQId _txQueue;
    osMailQId _rxQueue;

    // Thread IDs
    static osThreadId _txID;
    static osThreadId _rxID;

    DigitalInOut* _rxLED;
    DigitalInOut* _txLED;

private:
    // Private constructor
    CommModule();

    static shared_ptr<CommModule>& Instance();

    // Used to help define the class's threads in the constructor
    friend void define_thread(osThreadDef_t&, void (*task)(void const* arg),
                              osPriority, uint32_t, unsigned char*);

    // The working threads for handeling rx and tx data queues
    static void txThread(void const*);
    static void rxThread(void const*);

    static void ready(void);

    static void PrintHeader(void);

    static std::shared_ptr<CommModule> instance;

    static bool _isReady;

    // Thread and Mail defintion data structures
    osThreadDef_t _txDef;
    osThreadDef_t _rxDef;
    osMailQDef_t _txQDef;
    osMailQDef_t _rxQDef;

    // Mail helper objects
    MailHelper<rtp::packet, TX_QUEUE_SIZE> _txQueueHelper;
    MailHelper<rtp::packet, RX_QUEUE_SIZE> _rxQueueHelper;
};
<|endoftext|>


<commit_before>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkGenericContourFilter.cxx

  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.

=========================================================================*/
#include "vtkGenericContourFilter.h"
#include "vtkCell.h"
#include "vtkLine.h"
#include "vtkCellArray.h"
#include "vtkMergePoints.h"
#include "vtkContourValues.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkTimerLog.h"
#include "vtkUnstructuredGrid.h"
#include "vtkContourGrid.h"
#include "vtkDoubleArray.h"
#include "vtkPointData.h"
#include "vtkGenericCellIterator.h"
#include "vtkCellData.h"
#include "vtkGenericAdaptorCell.h"
#include "vtkPolyData.h"
#include "vtkGenericDataSet.h"
#include "vtkGenericAttributeCollection.h"
#include "vtkGenericAttribute.h"
#include "vtkGenericCellTessellator.h"
#include "vtkIncrementalPointLocator.h"

vtkStandardNewMacro(vtkGenericContourFilter);

vtkCxxSetObjectMacro(vtkGenericContourFilter,Locator,vtkIncrementalPointLocator);

// Construct object with initial range (0,1) and single contour value
// of 0.0.
vtkGenericContourFilter::vtkGenericContourFilter()
{
  this->ContourValues = vtkContourValues::New();

  this->ComputeNormals = 1;
  this->ComputeGradients = 0;
  this->ComputeScalars = 1;

  this->Locator = NULL;

  this->InputScalarsSelection = NULL;

  this->InternalPD = vtkPointData::New();
  this->SecondaryPD = vtkPointData::New();
  this->SecondaryCD = vtkCellData::New();
}

//-----------------------------------------------------------------------------
vtkGenericContourFilter::~vtkGenericContourFilter()
{
  this->ContourValues->Delete();
  if ( this->Locator )
    {
    this->Locator->UnRegister(this);
    this->Locator = NULL;
    }
  this->SetInputScalarsSelection(NULL);
  this->InternalPD->Delete();
  this->SecondaryPD->Delete();
  this->SecondaryCD->Delete();
}

//-----------------------------------------------------------------------------
// Overload standard modified time function. If contour values are modified,
// then this object is modified as well.
unsigned long vtkGenericContourFilter::GetMTime()
{
  unsigned long mTime = this->Superclass::GetMTime();
  unsigned long time;

  if (this->ContourValues)
    {
    time = this->ContourValues->GetMTime();
    mTime = ( time > mTime ? time : mTime );
    }
  if (this->Locator)
    {
    time = this->Locator->GetMTime();
    mTime = ( time > mTime ? time : mTime );
    }

  // mTime should also take into account the fact that tesselator is view
  // dependant

  return mTime;
}

//-----------------------------------------------------------------------------
// General contouring filter.  Handles arbitrary input.
int vtkGenericContourFilter::RequestData(
  vtkInformation *vtkNotUsed(request),
  vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
{
  // get the info objects
  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and output
  vtkGenericDataSet *input = vtkGenericDataSet::SafeDownCast(
    inInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *output = vtkPolyData::SafeDownCast(
    outInfo->Get(vtkDataObject::DATA_OBJECT()));

  vtkDebugMacro(<< "Executing contour filter");

  if(!input)
    {
    vtkErrorMacro("No input specified");
    return 1;
    }
  vtkPointData *outPd = output->GetPointData();
  vtkCellData *outCd = output->GetCellData();

  // Create objects to hold output of contour operation. First estimate
  // allocation size.
  vtkIdType numCells=input->GetNumberOfCells();
  vtkIdType estimatedSize=input->GetEstimatedSize();
  estimatedSize = estimatedSize / 1024 * 1024; //multiple of 1024
  if (estimatedSize < 1024)
    {
    estimatedSize = 1024;
    }

  vtkPoints *newPts = vtkPoints::New();
  newPts->Allocate(estimatedSize,estimatedSize);
  vtkCellArray *newVerts = vtkCellArray::New();
  newVerts->Allocate(estimatedSize,estimatedSize);
  vtkCellArray *newLines = vtkCellArray::New();
  newLines->Allocate(estimatedSize,estimatedSize);
  vtkCellArray *newPolys = vtkCellArray::New();
  newPolys->Allocate(estimatedSize,estimatedSize);

  output->Allocate(numCells);

  // locator used to merge potentially duplicate points
  if(this->Locator==0)
    {
    this->CreateDefaultLocator();
    }
  this->Locator->InitPointInsertion(newPts,input->GetBounds(),estimatedSize);

  // prepare the output attributes
  vtkGenericAttributeCollection *attributes=input->GetAttributes();
  vtkGenericAttribute *attribute;
  vtkDataArray *attributeArray;

  int c = attributes->GetNumberOfAttributes();
  vtkDataSetAttributes *secondaryAttributes;

  int attributeType;

  for(vtkIdType i = 0; i<c; ++i)
    {
    attribute=attributes->GetAttribute(i);
    attributeType=attribute->GetType();
    if(attribute->GetCentering()==vtkPointCentered)
      {
      secondaryAttributes = this->SecondaryPD;

      attributeArray = vtkDataArray::CreateDataArray(attribute->GetComponentType());
      attributeArray->SetNumberOfComponents(attribute->GetNumberOfComponents());
      attributeArray->SetName(attribute->GetName());
      this->InternalPD->AddArray(attributeArray);
      attributeArray->Delete();
      if(this->InternalPD->GetAttribute(attributeType))
        {
        this->InternalPD->SetActiveAttribute(
          this->InternalPD->GetNumberOfArrays()-1,attributeType);
        }
      }
    else // vtkCellCentered
      {
      secondaryAttributes = this->SecondaryCD;
      }

    attributeArray=vtkDataArray::CreateDataArray(attribute->GetComponentType());
    attributeArray->SetNumberOfComponents(attribute->GetNumberOfComponents());
    attributeArray->SetName(attribute->GetName());
    secondaryAttributes->AddArray(attributeArray);
    attributeArray->Delete();

    if(secondaryAttributes->GetAttribute(attributeType)==0)
      {
      secondaryAttributes->SetActiveAttribute(secondaryAttributes->GetNumberOfArrays()-1,
                                              attributeType);
      }
    }

  outPd->InterpolateAllocate(this->SecondaryPD,estimatedSize,estimatedSize);
  outCd->CopyAllocate(this->SecondaryCD,estimatedSize,estimatedSize);

  vtkGenericAdaptorCell *cell;

  //----------- Begin of contouring algorithm --------------------//
  vtkGenericCellIterator *cellIt = input->NewCellIterator();

  if(this->InputScalarsSelection)
    {
    int attrib =
      input->GetAttributes()->FindAttribute(this->InputScalarsSelection);
    if(attrib != -1)
      {
      vtkGenericAttribute *a = input->GetAttributes()->GetAttribute(attrib);
      if(a->GetNumberOfComponents() == 1)
        {
        input->GetAttributes()->SetActiveAttribute(attrib,0);
        }
      }
    }

  vtkIdType updateCount = numCells/20 + 1;  // update roughly every 5%
  vtkIdType count = 0;
  int abortExecute = 0;

  input->GetTessellator()->InitErrorMetrics(input);

  for(cellIt->Begin(); !cellIt->IsAtEnd() && !abortExecute; cellIt->Next())
    {
    if ( !(count % updateCount) )
      {
      this->UpdateProgress(static_cast<double>(count) / numCells);
      abortExecute = this->GetAbortExecute();
      }

    cell = cellIt->GetCell();
    cell->Contour(this->ContourValues, NULL, input->GetAttributes(),
                  input->GetTessellator(),
                  this->Locator, newVerts, newLines, newPolys, outPd, outCd,
                  this->InternalPD,this->SecondaryPD,this->SecondaryCD);
    ++count;
    } // for each cell
  cellIt->Delete();

  vtkDebugMacro(<<"Created: "
                << newPts->GetNumberOfPoints() << " points, "
                << newVerts->GetNumberOfCells() << " verts, "
                << newLines->GetNumberOfCells() << " lines, "
                << newPolys->GetNumberOfCells() << " triangles");

  //----------- End of contouring algorithm ----------------------//

  // Update ourselves.  Because we don't know up front how many verts, lines,
  // polys we've created, take care to reclaim memory.
  //
  output->SetPoints(newPts);
  newPts->Delete();

  if (newVerts->GetNumberOfCells()>0)
    {
    output->SetVerts(newVerts);
    }
  newVerts->Delete();

  if (newLines->GetNumberOfCells()>0)
    {
    output->SetLines(newLines);
    }
  newLines->Delete();

  if (newPolys->GetNumberOfCells()>0)
    {
    output->SetPolys(newPolys);
    }
  newPolys->Delete();

  this->Locator->Initialize();//releases leftover memory
  output->Squeeze();
  return 1;
}

//-----------------------------------------------------------------------------
// Specify a spatial locator for merging points. By default,
// an instance of vtkMergePoints is used.
void vtkGenericContourFilter::CreateDefaultLocator()
{
  if ( this->Locator == NULL )
    {
    this->Locator = vtkMergePoints::New();
    this->Locator->Register(this);
    this->Locator->Delete();
    }
}

//-----------------------------------------------------------------------------
void vtkGenericContourFilter::SelectInputScalars(const char *fieldName)
{
  this->SetInputScalarsSelection(fieldName);
}

//-----------------------------------------------------------------------------
void vtkGenericContourFilter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os,indent);

  if (this->InputScalarsSelection)
    {
    os << indent << "InputScalarsSelection: "
       << this->InputScalarsSelection << endl;
    }

  os << indent << "Compute Gradients: "
     << (this->ComputeGradients ? "On\n" : "Off\n");
  os << indent << "Compute Normals: "
     << (this->ComputeNormals ? "On\n" : "Off\n");
  os << indent << "Compute Scalars: "
     << (this->ComputeScalars ? "On\n" : "Off\n");

  this->ContourValues->PrintSelf(os,indent.GetNextIndent());

  if ( this->Locator )
    {
    os << indent << "Locator: " << this->Locator << "\n";
    }
  else
    {
    os << indent << "Locator: (none)\n";
    }
}

//-----------------------------------------------------------------------------
// Description:
// Set a particular contour value at contour number i. The index i ranges
// between 0<=i<NumberOfContours.
void vtkGenericContourFilter::SetValue(int i, float value)
{
  this->ContourValues->SetValue(i,value);
}

//----------------------------------------------------------------------------
// Description:
// Get the ith contour value.
double vtkGenericContourFilter::GetValue(int i)
{
  return this->ContourValues->GetValue(i);
}

//----------------------------------------------------------------------------
// Description:
// Get a pointer to an array of contour values. There will be
// GetNumberOfContours() values in the list.
double *vtkGenericContourFilter::GetValues()
{
  return this->ContourValues->GetValues();
}

//----------------------------------------------------------------------------
// Description:
// Fill a supplied list with contour values. There will be
// GetNumberOfContours() values in the list. Make sure you allocate
// enough memory to hold the list.
void vtkGenericContourFilter::GetValues(double *contourValues)
{
  this->ContourValues->GetValues(contourValues);
}

//----------------------------------------------------------------------------
// Description:
// Set the number of contours to place into the list. You only really
// need to use this method to reduce list size. The method SetValue()
// will automatically increase list size as needed.
void vtkGenericContourFilter::SetNumberOfContours(int number)
{
  this->ContourValues->SetNumberOfContours(number);
}

//----------------------------------------------------------------------------
// Description:
// Get the number of contours in the list of contour values.
int vtkGenericContourFilter::GetNumberOfContours()
{
  return this->ContourValues->GetNumberOfContours();
}

//----------------------------------------------------------------------------
// Description:
// Generate numContours equally spaced contour values between specified
// range. Contour values will include min/max range values.
void vtkGenericContourFilter::GenerateValues(int numContours, double range[2])
{
  this->ContourValues->GenerateValues(numContours, range);
}

//----------------------------------------------------------------------------
// Description:
// Generate numContours equally spaced contour values between specified
// range. Contour values will include min/max range values.
void vtkGenericContourFilter::GenerateValues(int numContours, double
                                             rangeStart, double rangeEnd)
{
  this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);
}

//----------------------------------------------------------------------------
int vtkGenericContourFilter::FillInputPortInformation(int port,
                                                      vtkInformation* info)
{
  if(!this->Superclass::FillInputPortInformation(port, info))
    {
    return 0;
    }
  info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkGenericDataSet");
  return 1;
}
<commit_msg>Fix misspellings in VTK/GenericFiltering<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkGenericContourFilter.cxx

  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.

=========================================================================*/
#include "vtkGenericContourFilter.h"
#include "vtkCell.h"
#include "vtkLine.h"
#include "vtkCellArray.h"
#include "vtkMergePoints.h"
#include "vtkContourValues.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkTimerLog.h"
#include "vtkUnstructuredGrid.h"
#include "vtkContourGrid.h"
#include "vtkDoubleArray.h"
#include "vtkPointData.h"
#include "vtkGenericCellIterator.h"
#include "vtkCellData.h"
#include "vtkGenericAdaptorCell.h"
#include "vtkPolyData.h"
#include "vtkGenericDataSet.h"
#include "vtkGenericAttributeCollection.h"
#include "vtkGenericAttribute.h"
#include "vtkGenericCellTessellator.h"
#include "vtkIncrementalPointLocator.h"

vtkStandardNewMacro(vtkGenericContourFilter);

vtkCxxSetObjectMacro(vtkGenericContourFilter,Locator,vtkIncrementalPointLocator);

// Construct object with initial range (0,1) and single contour value
// of 0.0.
vtkGenericContourFilter::vtkGenericContourFilter()
{
  this->ContourValues = vtkContourValues::New();

  this->ComputeNormals = 1;
  this->ComputeGradients = 0;
  this->ComputeScalars = 1;

  this->Locator = NULL;

  this->InputScalarsSelection = NULL;

  this->InternalPD = vtkPointData::New();
  this->SecondaryPD = vtkPointData::New();
  this->SecondaryCD = vtkCellData::New();
}

//-----------------------------------------------------------------------------
vtkGenericContourFilter::~vtkGenericContourFilter()
{
  this->ContourValues->Delete();
  if ( this->Locator )
    {
    this->Locator->UnRegister(this);
    this->Locator = NULL;
    }
  this->SetInputScalarsSelection(NULL);
  this->InternalPD->Delete();
  this->SecondaryPD->Delete();
  this->SecondaryCD->Delete();
}

//-----------------------------------------------------------------------------
// Overload standard modified time function. If contour values are modified,
// then this object is modified as well.
unsigned long vtkGenericContourFilter::GetMTime()
{
  unsigned long mTime = this->Superclass::GetMTime();
  unsigned long time;

  if (this->ContourValues)
    {
    time = this->ContourValues->GetMTime();
    mTime = ( time > mTime ? time : mTime );
    }
  if (this->Locator)
    {
    time = this->Locator->GetMTime();
    mTime = ( time > mTime ? time : mTime );
    }

  // mTime should also take into account the fact that tesselator is view
  // dependent

  return mTime;
}

//-----------------------------------------------------------------------------
// General contouring filter.  Handles arbitrary input.
int vtkGenericContourFilter::RequestData(
  vtkInformation *vtkNotUsed(request),
  vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
{
  // get the info objects
  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and output
  vtkGenericDataSet *input = vtkGenericDataSet::SafeDownCast(
    inInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *output = vtkPolyData::SafeDownCast(
    outInfo->Get(vtkDataObject::DATA_OBJECT()));

  vtkDebugMacro(<< "Executing contour filter");

  if(!input)
    {
    vtkErrorMacro("No input specified");
    return 1;
    }
  vtkPointData *outPd = output->GetPointData();
  vtkCellData *outCd = output->GetCellData();

  // Create objects to hold output of contour operation. First estimate
  // allocation size.
  vtkIdType numCells=input->GetNumberOfCells();
  vtkIdType estimatedSize=input->GetEstimatedSize();
  estimatedSize = estimatedSize / 1024 * 1024; //multiple of 1024
  if (estimatedSize < 1024)
    {
    estimatedSize = 1024;
    }

  vtkPoints *newPts = vtkPoints::New();
  newPts->Allocate(estimatedSize,estimatedSize);
  vtkCellArray *newVerts = vtkCellArray::New();
  newVerts->Allocate(estimatedSize,estimatedSize);
  vtkCellArray *newLines = vtkCellArray::New();
  newLines->Allocate(estimatedSize,estimatedSize);
  vtkCellArray *newPolys = vtkCellArray::New();
  newPolys->Allocate(estimatedSize,estimatedSize);

  output->Allocate(numCells);

  // locator used to merge potentially duplicate points
  if(this->Locator==0)
    {
    this->CreateDefaultLocator();
    }
  this->Locator->InitPointInsertion(newPts,input->GetBounds(),estimatedSize);

  // prepare the output attributes
  vtkGenericAttributeCollection *attributes=input->GetAttributes();
  vtkGenericAttribute *attribute;
  vtkDataArray *attributeArray;

  int c = attributes->GetNumberOfAttributes();
  vtkDataSetAttributes *secondaryAttributes;

  int attributeType;

  for(vtkIdType i = 0; i<c; ++i)
    {
    attribute=attributes->GetAttribute(i);
    attributeType=attribute->GetType();
    if(attribute->GetCentering()==vtkPointCentered)
      {
      secondaryAttributes = this->SecondaryPD;

      attributeArray = vtkDataArray::CreateDataArray(attribute->GetComponentType());
      attributeArray->SetNumberOfComponents(attribute->GetNumberOfComponents());
      attributeArray->SetName(attribute->GetName());
      this->InternalPD->AddArray(attributeArray);
      attributeArray->Delete();
      if(this->InternalPD->GetAttribute(attributeType))
        {
        this->InternalPD->SetActiveAttribute(
          this->InternalPD->GetNumberOfArrays()-1,attributeType);
        }
      }
    else // vtkCellCentered
      {
      secondaryAttributes = this->SecondaryCD;
      }

    attributeArray=vtkDataArray::CreateDataArray(attribute->GetComponentType());
    attributeArray->SetNumberOfComponents(attribute->GetNumberOfComponents());
    attributeArray->SetName(attribute->GetName());
    secondaryAttributes->AddArray(attributeArray);
    attributeArray->Delete();

    if(secondaryAttributes->GetAttribute(attributeType)==0)
      {
      secondaryAttributes->SetActiveAttribute(secondaryAttributes->GetNumberOfArrays()-1,
                                              attributeType);
      }
    }

  outPd->InterpolateAllocate(this->SecondaryPD,estimatedSize,estimatedSize);
  outCd->CopyAllocate(this->SecondaryCD,estimatedSize,estimatedSize);

  vtkGenericAdaptorCell *cell;

  //----------- Begin of contouring algorithm --------------------//
  vtkGenericCellIterator *cellIt = input->NewCellIterator();

  if(this->InputScalarsSelection)
    {
    int attrib =
      input->GetAttributes()->FindAttribute(this->InputScalarsSelection);
    if(attrib != -1)
      {
      vtkGenericAttribute *a = input->GetAttributes()->GetAttribute(attrib);
      if(a->GetNumberOfComponents() == 1)
        {
        input->GetAttributes()->SetActiveAttribute(attrib,0);
        }
      }
    }

  vtkIdType updateCount = numCells/20 + 1;  // update roughly every 5%
  vtkIdType count = 0;
  int abortExecute = 0;

  input->GetTessellator()->InitErrorMetrics(input);

  for(cellIt->Begin(); !cellIt->IsAtEnd() && !abortExecute; cellIt->Next())
    {
    if ( !(count % updateCount) )
      {
      this->UpdateProgress(static_cast<double>(count) / numCells);
      abortExecute = this->GetAbortExecute();
      }

    cell = cellIt->GetCell();
    cell->Contour(this->ContourValues, NULL, input->GetAttributes(),
                  input->GetTessellator(),
                  this->Locator, newVerts, newLines, newPolys, outPd, outCd,
                  this->InternalPD,this->SecondaryPD,this->SecondaryCD);
    ++count;
    } // for each cell
  cellIt->Delete();

  vtkDebugMacro(<<"Created: "
                << newPts->GetNumberOfPoints() << " points, "
                << newVerts->GetNumberOfCells() << " verts, "
                << newLines->GetNumberOfCells() << " lines, "
                << newPolys->GetNumberOfCells() << " triangles");

  //----------- End of contouring algorithm ----------------------//

  // Update ourselves.  Because we don't know up front how many verts, lines,
  // polys we've created, take care to reclaim memory.
  //
  output->SetPoints(newPts);
  newPts->Delete();

  if (newVerts->GetNumberOfCells()>0)
    {
    output->SetVerts(newVerts);
    }
  newVerts->Delete();

  if (newLines->GetNumberOfCells()>0)
    {
    output->SetLines(newLines);
    }
  newLines->Delete();

  if (newPolys->GetNumberOfCells()>0)
    {
    output->SetPolys(newPolys);
    }
  newPolys->Delete();

  this->Locator->Initialize();//releases leftover memory
  output->Squeeze();
  return 1;
}

//-----------------------------------------------------------------------------
// Specify a spatial locator for merging points. By default,
// an instance of vtkMergePoints is used.
void vtkGenericContourFilter::CreateDefaultLocator()
{
  if ( this->Locator == NULL )
    {
    this->Locator = vtkMergePoints::New();
    this->Locator->Register(this);
    this->Locator->Delete();
    }
}

//-----------------------------------------------------------------------------
void vtkGenericContourFilter::SelectInputScalars(const char *fieldName)
{
  this->SetInputScalarsSelection(fieldName);
}

//-----------------------------------------------------------------------------
void vtkGenericContourFilter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os,indent);

  if (this->InputScalarsSelection)
    {
    os << indent << "InputScalarsSelection: "
       << this->InputScalarsSelection << endl;
    }

  os << indent << "Compute Gradients: "
     << (this->ComputeGradients ? "On\n" : "Off\n");
  os << indent << "Compute Normals: "
     << (this->ComputeNormals ? "On\n" : "Off\n");
  os << indent << "Compute Scalars: "
     << (this->ComputeScalars ? "On\n" : "Off\n");

  this->ContourValues->PrintSelf(os,indent.GetNextIndent());

  if ( this->Locator )
    {
    os << indent << "Locator: " << this->Locator << "\n";
    }
  else
    {
    os << indent << "Locator: (none)\n";
    }
}

//-----------------------------------------------------------------------------
// Description:
// Set a particular contour value at contour number i. The index i ranges
// between 0<=i<NumberOfContours.
void vtkGenericContourFilter::SetValue(int i, float value)
{
  this->ContourValues->SetValue(i,value);
}

//----------------------------------------------------------------------------
// Description:
// Get the ith contour value.
double vtkGenericContourFilter::GetValue(int i)
{
  return this->ContourValues->GetValue(i);
}

//----------------------------------------------------------------------------
// Description:
// Get a pointer to an array of contour values. There will be
// GetNumberOfContours() values in the list.
double *vtkGenericContourFilter::GetValues()
{
  return this->ContourValues->GetValues();
}

//----------------------------------------------------------------------------
// Description:
// Fill a supplied list with contour values. There will be
// GetNumberOfContours() values in the list. Make sure you allocate
// enough memory to hold the list.
void vtkGenericContourFilter::GetValues(double *contourValues)
{
  this->ContourValues->GetValues(contourValues);
}

//----------------------------------------------------------------------------
// Description:
// Set the number of contours to place into the list. You only really
// need to use this method to reduce list size. The method SetValue()
// will automatically increase list size as needed.
void vtkGenericContourFilter::SetNumberOfContours(int number)
{
  this->ContourValues->SetNumberOfContours(number);
}

//----------------------------------------------------------------------------
// Description:
// Get the number of contours in the list of contour values.
int vtkGenericContourFilter::GetNumberOfContours()
{
  return this->ContourValues->GetNumberOfContours();
}

//----------------------------------------------------------------------------
// Description:
// Generate numContours equally spaced contour values between specified
// range. Contour values will include min/max range values.
void vtkGenericContourFilter::GenerateValues(int numContours, double range[2])
{
  this->ContourValues->GenerateValues(numContours, range);
}

//----------------------------------------------------------------------------
// Description:
// Generate numContours equally spaced contour values between specified
// range. Contour values will include min/max range values.
void vtkGenericContourFilter::GenerateValues(int numContours, double
                                             rangeStart, double rangeEnd)
{
  this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);
}

//----------------------------------------------------------------------------
int vtkGenericContourFilter::FillInputPortInformation(int port,
                                                      vtkInformation* info)
{
  if(!this->Superclass::FillInputPortInformation(port, info))
    {
    return 0;
    }
  info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkGenericDataSet");
  return 1;
}
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2012 Google Inc. All rights reserved.
 *
 * 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.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * 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
 * OWNER 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.
 */

#include "config.h"
#include "platform/fonts/harfbuzz/HarfBuzzFace.h"

#include "platform/fonts/FontPlatformData.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/fonts/harfbuzz/HarfBuzzShaper.h"

#include <ApplicationServices/ApplicationServices.h>
#include "hb.h"

namespace blink {

static hb_position_t floatToHarfBuzzPosition(CGFloat value)
{
    return static_cast<hb_position_t>(value * (1 << 16));
}

static hb_bool_t getGlyph(hb_font_t* hbFont, void* fontData, hb_codepoint_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* userData)
{
    CTFontRef ctFont = reinterpret_cast<FontPlatformData*>(fontData)->ctFont();
    UniChar characters[4];
    CGGlyph cgGlyphs[4];
    size_t length = 0;
    U16_APPEND_UNSAFE(characters, length, unicode);
    if (!CTFontGetGlyphsForCharacters(ctFont, characters, cgGlyphs, length))
        return false;
    *glyph = cgGlyphs[0];
    return true;
}

static hb_position_t getGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData)
{
    CTFontRef ctFont = reinterpret_cast<FontPlatformData*>(fontData)->ctFont();
    CGGlyph cgGlyph = glyph;
    CGFloat advance = CTFontGetAdvancesForGlyphs(ctFont, kCTFontHorizontalOrientation, &cgGlyph, 0, 1);
    return floatToHarfBuzzPosition(advance);
}

static hb_bool_t getGlyphHorizontalOrigin(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData)
{
    return true;
}

static hb_bool_t getGlyphExtents(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void* userData)
{
    CTFontRef ctFont = reinterpret_cast<FontPlatformData*>(fontData)->ctFont();
    CGRect cgRect;
    CGGlyph cgGlyph = glyph;
    if (CTFontGetBoundingRectsForGlyphs(ctFont, kCTFontDefaultOrientation, &cgGlyph, &cgRect, 1) == CGRectNull)
        return false;
    extents->x_bearing = floatToHarfBuzzPosition(cgRect.origin.x);
    extents->y_bearing = -floatToHarfBuzzPosition(cgRect.origin.y);
    extents->width = floatToHarfBuzzPosition(cgRect.size.width);
    extents->height = floatToHarfBuzzPosition(cgRect.size.height);
    return true;
}

static hb_font_funcs_t* harfBuzzCoreTextGetFontFuncs()
{
    static hb_font_funcs_t* harfBuzzCoreTextFontFuncs = 0;

    if (!harfBuzzCoreTextFontFuncs) {
        harfBuzzCoreTextFontFuncs = hb_font_funcs_create();
        hb_font_funcs_set_glyph_func(harfBuzzCoreTextFontFuncs, getGlyph, 0, 0);
        hb_font_funcs_set_glyph_h_advance_func(harfBuzzCoreTextFontFuncs, getGlyphHorizontalAdvance, 0, 0);
        hb_font_funcs_set_glyph_h_origin_func(harfBuzzCoreTextFontFuncs, getGlyphHorizontalOrigin, 0, 0);
        hb_font_funcs_set_glyph_extents_func(harfBuzzCoreTextFontFuncs, getGlyphExtents, 0, 0);
        hb_font_funcs_make_immutable(harfBuzzCoreTextFontFuncs);
    }
    return harfBuzzCoreTextFontFuncs;
}

static void releaseTableData(void* userData)
{
    CFDataRef cfData = reinterpret_cast<CFDataRef>(userData);
    CFRelease(cfData);
}

static hb_blob_t* harfBuzzCoreTextGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
{
    CGFontRef cgFont = reinterpret_cast<CGFontRef>(userData);
    CFDataRef cfData = CGFontCopyTableForTag(cgFont, tag);
    if (!cfData)
        return 0;

    const char* data = reinterpret_cast<const char*>(CFDataGetBytePtr(cfData));
    const size_t length = CFDataGetLength(cfData);
    if (!data || !length)
        return 0;
    return hb_blob_create(data, length, HB_MEMORY_MODE_READONLY, reinterpret_cast<void*>(const_cast<__CFData*>(cfData)), releaseTableData);
}

hb_face_t* HarfBuzzFace::createFace()
{
    // It seems that CTFontCopyTable of MacOSX10.5 sdk doesn't work for
    // OpenType layout tables(GDEF, GSUB, GPOS). Use CGFontCopyTableForTag instead.
    hb_face_t* face = hb_face_create_for_tables(harfBuzzCoreTextGetTable, m_platformData->cgFont(), 0);
    ASSERT(face);
    return face;
}

hb_font_t* HarfBuzzFace::createFont()
{
    hb_font_t* font = hb_font_create(m_face);
    hb_font_set_funcs(font, harfBuzzCoreTextGetFontFuncs(), m_platformData, 0);
    const float size = m_platformData->m_textSize;
    hb_font_set_ppem(font, size, size);
    const int scale = (1 << 16) * static_cast<int>(size);
    hb_font_set_scale(font, scale, scale);
    hb_font_make_immutable(font);
    return font;
}

} // namespace blink
<commit_msg>Avoid null cgFont crash in harfBuzzCoreTextGetTable<commit_after>/*
 * Copyright (c) 2012 Google Inc. All rights reserved.
 *
 * 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.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * 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
 * OWNER 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.
 */

#include "config.h"
#include "platform/fonts/harfbuzz/HarfBuzzFace.h"

#include "platform/fonts/FontPlatformData.h"
#include "platform/fonts/SimpleFontData.h"
#include "platform/fonts/harfbuzz/HarfBuzzShaper.h"

#include <ApplicationServices/ApplicationServices.h>
#include "hb.h"

namespace blink {

static hb_position_t floatToHarfBuzzPosition(CGFloat value)
{
    return static_cast<hb_position_t>(value * (1 << 16));
}

static hb_bool_t getGlyph(hb_font_t* hbFont, void* fontData, hb_codepoint_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* userData)
{
    CTFontRef ctFont = reinterpret_cast<FontPlatformData*>(fontData)->ctFont();
    UniChar characters[4];
    CGGlyph cgGlyphs[4];
    size_t length = 0;
    U16_APPEND_UNSAFE(characters, length, unicode);
    if (!CTFontGetGlyphsForCharacters(ctFont, characters, cgGlyphs, length))
        return false;
    *glyph = cgGlyphs[0];
    return true;
}

static hb_position_t getGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData)
{
    CTFontRef ctFont = reinterpret_cast<FontPlatformData*>(fontData)->ctFont();
    CGGlyph cgGlyph = glyph;
    CGFloat advance = CTFontGetAdvancesForGlyphs(ctFont, kCTFontHorizontalOrientation, &cgGlyph, 0, 1);
    return floatToHarfBuzzPosition(advance);
}

static hb_bool_t getGlyphHorizontalOrigin(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData)
{
    return true;
}

static hb_bool_t getGlyphExtents(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void* userData)
{
    CTFontRef ctFont = reinterpret_cast<FontPlatformData*>(fontData)->ctFont();
    CGRect cgRect;
    CGGlyph cgGlyph = glyph;
    if (CTFontGetBoundingRectsForGlyphs(ctFont, kCTFontDefaultOrientation, &cgGlyph, &cgRect, 1) == CGRectNull)
        return false;
    extents->x_bearing = floatToHarfBuzzPosition(cgRect.origin.x);
    extents->y_bearing = -floatToHarfBuzzPosition(cgRect.origin.y);
    extents->width = floatToHarfBuzzPosition(cgRect.size.width);
    extents->height = floatToHarfBuzzPosition(cgRect.size.height);
    return true;
}

static hb_font_funcs_t* harfBuzzCoreTextGetFontFuncs()
{
    static hb_font_funcs_t* harfBuzzCoreTextFontFuncs = 0;

    if (!harfBuzzCoreTextFontFuncs) {
        harfBuzzCoreTextFontFuncs = hb_font_funcs_create();
        hb_font_funcs_set_glyph_func(harfBuzzCoreTextFontFuncs, getGlyph, 0, 0);
        hb_font_funcs_set_glyph_h_advance_func(harfBuzzCoreTextFontFuncs, getGlyphHorizontalAdvance, 0, 0);
        hb_font_funcs_set_glyph_h_origin_func(harfBuzzCoreTextFontFuncs, getGlyphHorizontalOrigin, 0, 0);
        hb_font_funcs_set_glyph_extents_func(harfBuzzCoreTextFontFuncs, getGlyphExtents, 0, 0);
        hb_font_funcs_make_immutable(harfBuzzCoreTextFontFuncs);
    }
    return harfBuzzCoreTextFontFuncs;
}

static void releaseTableData(void* userData)
{
    CFDataRef cfData = reinterpret_cast<CFDataRef>(userData);
    CFRelease(cfData);
}

static hb_blob_t* harfBuzzCoreTextGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
{
    CGFontRef cgFont = reinterpret_cast<CGFontRef>(userData);
    if (!cgFont)
        return 0;
    CFDataRef cfData = CGFontCopyTableForTag(cgFont, tag);
    if (!cfData)
        return 0;

    const char* data = reinterpret_cast<const char*>(CFDataGetBytePtr(cfData));
    const size_t length = CFDataGetLength(cfData);
    if (!data || !length)
        return 0;
    return hb_blob_create(data, length, HB_MEMORY_MODE_READONLY, reinterpret_cast<void*>(const_cast<__CFData*>(cfData)), releaseTableData);
}

hb_face_t* HarfBuzzFace::createFace()
{
    // It seems that CTFontCopyTable of MacOSX10.5 sdk doesn't work for
    // OpenType layout tables(GDEF, GSUB, GPOS). Use CGFontCopyTableForTag instead.
    hb_face_t* face = hb_face_create_for_tables(harfBuzzCoreTextGetTable, m_platformData->cgFont(), 0);
    ASSERT(face);
    return face;
}

hb_font_t* HarfBuzzFace::createFont()
{
    hb_font_t* font = hb_font_create(m_face);
    hb_font_set_funcs(font, harfBuzzCoreTextGetFontFuncs(), m_platformData, 0);
    const float size = m_platformData->m_textSize;
    hb_font_set_ppem(font, size, size);
    const int scale = (1 << 16) * static_cast<int>(size);
    hb_font_set_scale(font, scale, scale);
    hb_font_make_immutable(font);
    return font;
}

} // namespace blink
<|endoftext|>


<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:
  Language:  C++
  Date:
  Version:

Copyright (c) 2000 National Library of Medicine
All rights reserved.

See COPYRIGHT.txt for copyright details.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#include <iostream>
// This file has been generated by BuildHeaderTest.tcl
// Test to include each header file for Insight

#include "itkAcosImageFilter.h"
#include "itkAdaptImageFilter.h"
#include "itkAddImageFilter.h"
#include "itkAnisotropicDiffusionFunction.h"
#include "itkAnisotropicDiffusionImageFilter.h"
#include "itkAsinImageFilter.h"
#include "itkAtan2ImageFilter.h"
#include "itkAtanImageFilter.h"
#include "itkBSplineCenteredL2ResampleImageFilterBase.txx"
#include "itkBSplineCenteredResampleImageFilterBase.txx"
#include "itkBSplineDecompositionImageFilter.txx"
#include "itkBSplineDownsampleImageFilter.txx"
#include "itkBSplineInterpolateImageFunction.txx"
#include "itkBSplineL2ResampleImageFilterBase.txx"
#include "itkBSplineResampleImageFilterBase.txx"
#include "itkBSplineResampleImageFunction.h"
#include "itkBSplineUpsampleImageFilter.txx"
#include "itkBilateralImageFilter.txx"
#include "itkBinaryDilateImageFilter.txx"
#include "itkBinaryErodeImageFilter.txx"
#include "itkBinaryFunctorImageFilter.txx"
#include "itkBinaryMagnitudeImageFilter.h"
#include "itkBinaryMedianImageFilter.txx"
#include "itkBinaryThresholdImageFilter.txx"
#include "itkBinomialBlurImageFilter.txx"
#include "itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter.txx"
#include "itkBloxBoundaryPointToCoreAtomImageFilter.txx"
#include "itkCannyEdgeDetectionImageFilter.txx"
#include "itkCastImageFilter.h"
#include "itkChangeInformationImageFilter.txx"
#include "itkConfidenceConnectedImageFilter.txx"
#include "itkConnectedThresholdImageFilter.txx"
#include "itkConstantPadImageFilter.txx"
#include "itkCosImageFilter.h"
#include "itkCropImageFilter.txx"
#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkCurvatureNDAnisotropicDiffusionFunction.txx"
#include "itkDanielssonDistanceMapImageFilter.txx"
#include "itkDerivativeImageFilter.txx"
#include "itkDifferenceOfGaussiansGradientImageFilter.txx"
#include "itkDilateObjectMorphologyImageFilter.txx"
#include "itkDirectedHausdorffDistanceImageFilter.txx"
#include "itkDiscreteGaussianImageFilter.txx"
#include "itkDivideImageFilter.h"
#include "itkEdgePotentialImageFilter.h"
#include "itkEigenAnalysis2DImageFilter.txx"
#include "itkErodeObjectMorphologyImageFilter.txx"
#include "itkExpImageFilter.h"
#include "itkExpNegativeImageFilter.h"
#include "itkExpandImageFilter.txx"
#include "itkExtractImageFilter.txx"
#include "itkExtractImageFilterRegionCopier.h"
#include "itkFlipImageFilter.txx"
#include "itkGaussianImageSource.txx"
#include "itkGradientAnisotropicDiffusionImageFilter.h"
#include "itkGradientImageFilter.txx"
#include "itkGradientImageToBloxBoundaryPointImageFilter.txx"
#include "itkGradientMagnitudeImageFilter.txx"
#include "itkGradientMagnitudeRecursiveGaussianImageFilter.txx"
#include "itkGradientNDAnisotropicDiffusionFunction.txx"
#include "itkGradientRecursiveGaussianImageFilter.txx"
#include "itkGradientToMagnitudeImageFilter.h"
#include "itkGrayscaleDilateImageFilter.txx"
#include "itkGrayscaleErodeImageFilter.txx"
#include "itkGrayscaleFunctionDilateImageFilter.txx"
#include "itkGrayscaleFunctionErodeImageFilter.txx"
#include "itkHardConnectedComponentImageFilter.txx"
#include "itkHausdorffDistanceImageFilter.txx"
#include "itkImageToMeshFilter.txx"
#include "itkImageToParametricSpaceFilter.txx"
#include "itkImportImageFilter.txx"
#include "itkInteriorExteriorMeshFilter.txx"
#include "itkInterpolateImageFilter.txx"
#include "itkInterpolateImagePointsFilter.txx"
#include "itkIsolatedConnectedImageFilter.txx"
#include "itkJoinImageFilter.h"
#include "itkLaplacianImageFilter.txx"
#include "itkLog10ImageFilter.h"
#include "itkLogImageFilter.h"
#include "itkMaskImageFilter.h"
#include "itkMaximumImageFilter.h"
#include "itkMeanImageFilter.txx"
#include "itkMedianImageFilter.txx"
#include "itkMinimumImageFilter.h"
#include "itkMinimumMaximumImageCalculator.txx"
#include "itkMinimumMaximumImageFilter.txx"
#include "itkMirrorPadImageFilter.txx"
#include "itkMorphologyImageFilter.txx"
#include "itkMultiplyImageFilter.h"
#include "itkNaryAddImageFilter.h"
#include "itkNaryFunctorImageFilter.txx"
#include "itkNeighborhoodConnectedImageFilter.txx"
#include "itkNeighborhoodOperatorImageFilter.txx"
#include "itkNonThreadedShrinkImageFilter.txx"
#include "itkNormalizeImageFilter.txx"
#include "itkObjectMorphologyImageFilter.txx"
#include "itkPadImageFilter.txx"
#include "itkParametricSpaceToImageSpaceMeshFilter.txx"
#include "itkPermuteAxesImageFilter.txx"
#include "itkPlaheImageFilter.txx"
#include "itkRandomImageSource.txx"
#include "itkRecursiveGaussianImageFilter.txx"
#include "itkRecursiveSeparableImageFilter.txx"
#include "itkReflectImageFilter.txx"
#include "itkReflectiveImageRegionConstIterator.txx"
#include "itkReflectiveImageRegionIterator.txx"
#include "itkResampleImageFilter.txx"
#include "itkRescaleIntensityImageFilter.txx"
#include "itkScalarAnisotropicDiffusionFunction.txx"
#include "itkScalarToArrayCastImageFilter.h"
#include "itkShiftScaleImageFilter.txx"
#include "itkShrinkImageFilter.txx"
#include "itkSimilarityIndexImageFilter.txx"
#include "itkSinImageFilter.h"
#include "itkSobelEdgeDetectionImageFilter.txx"
#include "itkSparseFieldLayer.txx"
#include "itkSparseFieldLevelSetImageFilter.txx"
#include "itkSpatialFunctionImageEvaluatorFilter.txx"
#include "itkSqrtImageFilter.h"
#include "itkSquaredDifferenceImageFilter.h"
#include "itkStatisticsImageFilter.txx"
#include "itkStreamingImageFilter.txx"
#include "itkSubtractImageFilter.h"
#include "itkTanImageFilter.h"
#include "itkTernaryAddImageFilter.h"
#include "itkTernaryFunctorImageFilter.txx"
#include "itkTernaryMagnitudeImageFilter.h"
#include "itkTernaryMagnitudeSquaredImageFilter.h"
#include "itkThresholdImageFilter.txx"
#include "itkTobogganImageFilter.txx"
#include "itkTransformMeshFilter.txx"
#include "itkTwoOutputExampleImageFilter.txx"
#include "itkUnaryFunctorImageFilter.txx"
#include "itkVTKImageExport.txx"
#include "itkVTKImageExportBase.h"
#include "itkVTKImageImport.txx"
#include "itkVectorAnisotropicDiffusionFunction.txx"
#include "itkVectorCastImageFilter.h"
#include "itkVectorCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkVectorCurvatureNDAnisotropicDiffusionFunction.txx"
#include "itkVectorExpandImageFilter.txx"
#include "itkVectorGradientAnisotropicDiffusionImageFilter.h"
#include "itkVectorGradientNDAnisotropicDiffusionFunction.txx"
#include "itkVectorIndexSelectionCastImageFilter.h"
#include "itkVectorNeighborhoodOperatorImageFilter.txx"
#include "itkWarpImageFilter.txx"
#include "itkWrapPadImageFilter.txx"
#include "itkZeroCrossingBasedEdgeDetectionImageFilter.txx"
#include "itkZeroCrossingImageFilter.txx"

int main ( int , char*  )
{

  return 0;
}

<commit_msg>ENH: Updated to latest headers<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:
  Language:  C++
  Date:
  Version:

Copyright (c) 2000 National Library of Medicine
All rights reserved.

See COPYRIGHT.txt for copyright details.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#include <iostream>
// This file has been generated by BuildHeaderTest.tcl
// Test to include each header file for Insight

#include "itkAcosImageFilter.h"
#include "itkAdaptImageFilter.h"
#include "itkAddImageFilter.h"
#include "itkAnisotropicDiffusionFunction.h"
#include "itkAnisotropicDiffusionImageFilter.h"
#include "itkAsinImageFilter.h"
#include "itkAtan2ImageFilter.h"
#include "itkAtanImageFilter.h"
#include "itkBSplineCenteredL2ResampleImageFilterBase.txx"
#include "itkBSplineCenteredResampleImageFilterBase.txx"
#include "itkBSplineDecompositionImageFilter.txx"
#include "itkBSplineDownsampleImageFilter.txx"
#include "itkBSplineInterpolateImageFunction.txx"
#include "itkBSplineL2ResampleImageFilterBase.txx"
#include "itkBSplineResampleImageFilterBase.txx"
#include "itkBSplineResampleImageFunction.h"
#include "itkBSplineUpsampleImageFilter.txx"
#include "itkBilateralImageFilter.txx"
#include "itkBinaryDilateImageFilter.txx"
#include "itkBinaryErodeImageFilter.txx"
#include "itkBinaryFunctorImageFilter.txx"
#include "itkBinaryMagnitudeImageFilter.h"
#include "itkBinaryMedianImageFilter.txx"
#include "itkBinaryThresholdImageFilter.txx"
#include "itkBinomialBlurImageFilter.txx"
#include "itkBloxBoundaryPointImageToBloxBoundaryProfileImageFilter.txx"
#include "itkBloxBoundaryPointToCoreAtomImageFilter.txx"
#include "itkCannyEdgeDetectionImageFilter.txx"
#include "itkCastImageFilter.h"
#include "itkChangeInformationImageFilter.txx"
#include "itkConfidenceConnectedImageFilter.txx"
#include "itkConnectedThresholdImageFilter.txx"
#include "itkConstantPadImageFilter.txx"
#include "itkCosImageFilter.h"
#include "itkCropImageFilter.txx"
#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkCurvatureNDAnisotropicDiffusionFunction.txx"
#include "itkDanielssonDistanceMapImageFilter.txx"
#include "itkDerivativeImageFilter.txx"
#include "itkDifferenceOfGaussiansGradientImageFilter.txx"
#include "itkDilateObjectMorphologyImageFilter.txx"
#include "itkDirectedHausdorffDistanceImageFilter.txx"
#include "itkDiscreteGaussianImageFilter.txx"
#include "itkDivideImageFilter.h"
#include "itkEdgePotentialImageFilter.h"
#include "itkEigenAnalysis2DImageFilter.txx"
#include "itkErodeObjectMorphologyImageFilter.txx"
#include "itkExpImageFilter.h"
#include "itkExpNegativeImageFilter.h"
#include "itkExpandImageFilter.txx"
#include "itkExtractImageFilter.txx"
#include "itkExtractImageFilterRegionCopier.h"
#include "itkFlipImageFilter.txx"
#include "itkGaussianImageSource.txx"
#include "itkGradientAnisotropicDiffusionImageFilter.h"
#include "itkGradientImageFilter.txx"
#include "itkGradientImageToBloxBoundaryPointImageFilter.txx"
#include "itkGradientMagnitudeImageFilter.txx"
#include "itkGradientMagnitudeRecursiveGaussianImageFilter.txx"
#include "itkGradientNDAnisotropicDiffusionFunction.txx"
#include "itkGradientRecursiveGaussianImageFilter.txx"
#include "itkGradientToMagnitudeImageFilter.h"
#include "itkGrayscaleDilateImageFilter.txx"
#include "itkGrayscaleErodeImageFilter.txx"
#include "itkGrayscaleFunctionDilateImageFilter.txx"
#include "itkGrayscaleFunctionErodeImageFilter.txx"
#include "itkHardConnectedComponentImageFilter.txx"
#include "itkHausdorffDistanceImageFilter.txx"
#include "itkImageToMeshFilter.txx"
#include "itkImageToParametricSpaceFilter.txx"
#include "itkImportImageFilter.txx"
#include "itkInteriorExteriorMeshFilter.txx"
#include "itkInterpolateImageFilter.txx"
#include "itkInterpolateImagePointsFilter.txx"
#include "itkIsolatedConnectedImageFilter.txx"
#include "itkJoinImageFilter.h"
#include "itkLaplacianImageFilter.txx"
#include "itkLog10ImageFilter.h"
#include "itkLogImageFilter.h"
#include "itkMaskImageFilter.h"
#include "itkMaximumImageFilter.h"
#include "itkMeanImageFilter.txx"
#include "itkMedianImageFilter.txx"
#include "itkMinimumImageFilter.h"
#include "itkMinimumMaximumImageCalculator.txx"
#include "itkMinimumMaximumImageFilter.txx"
#include "itkMirrorPadImageFilter.txx"
#include "itkMorphologyImageFilter.txx"
#include "itkMultiplyImageFilter.h"
#include "itkNaryAddImageFilter.h"
#include "itkNaryFunctorImageFilter.txx"
#include "itkNeighborhoodConnectedImageFilter.txx"
#include "itkNeighborhoodOperatorImageFilter.txx"
#include "itkNonThreadedShrinkImageFilter.txx"
#include "itkNormalizeImageFilter.txx"
#include "itkObjectMorphologyImageFilter.txx"
#include "itkPadImageFilter.txx"
#include "itkParametricSpaceToImageSpaceMeshFilter.txx"
#include "itkPermuteAxesImageFilter.txx"
#include "itkPlaheImageFilter.txx"
#include "itkRandomImageSource.txx"
#include "itkRecursiveGaussianImageFilter.txx"
#include "itkRecursiveSeparableImageFilter.txx"
#include "itkReflectImageFilter.txx"
#include "itkReflectiveImageRegionConstIterator.txx"
#include "itkReflectiveImageRegionIterator.txx"
#include "itkResampleImageFilter.txx"
#include "itkRescaleIntensityImageFilter.txx"
#include "itkScalarAnisotropicDiffusionFunction.txx"
#include "itkScalarToArrayCastImageFilter.h"
#include "itkShiftScaleImageFilter.txx"
#include "itkShrinkImageFilter.txx"
#include "itkSigmoidImageFilter.h"
#include "itkSimilarityIndexImageFilter.txx"
#include "itkSinImageFilter.h"
#include "itkSobelEdgeDetectionImageFilter.txx"
#include "itkSparseFieldLayer.txx"
#include "itkSparseFieldLevelSetImageFilter.txx"
#include "itkSpatialFunctionImageEvaluatorFilter.txx"
#include "itkSqrtImageFilter.h"
#include "itkSquaredDifferenceImageFilter.h"
#include "itkStatisticsImageFilter.txx"
#include "itkStreamingImageFilter.txx"
#include "itkSubtractImageFilter.h"
#include "itkTanImageFilter.h"
#include "itkTernaryAddImageFilter.h"
#include "itkTernaryFunctorImageFilter.txx"
#include "itkTernaryMagnitudeImageFilter.h"
#include "itkTernaryMagnitudeSquaredImageFilter.h"
#include "itkThresholdImageFilter.txx"
#include "itkTobogganImageFilter.txx"
#include "itkTransformMeshFilter.txx"
#include "itkTwoOutputExampleImageFilter.txx"
#include "itkUnaryFunctorImageFilter.txx"
#include "itkVTKImageExport.txx"
#include "itkVTKImageExportBase.h"
#include "itkVTKImageImport.txx"
#include "itkVectorAnisotropicDiffusionFunction.txx"
#include "itkVectorCastImageFilter.h"
#include "itkVectorCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkVectorCurvatureNDAnisotropicDiffusionFunction.txx"
#include "itkVectorExpandImageFilter.txx"
#include "itkVectorGradientAnisotropicDiffusionImageFilter.h"
#include "itkVectorGradientNDAnisotropicDiffusionFunction.txx"
#include "itkVectorIndexSelectionCastImageFilter.h"
#include "itkVectorNeighborhoodOperatorImageFilter.txx"
#include "itkWarpImageFilter.txx"
#include "itkWrapPadImageFilter.txx"
#include "itkZeroCrossingBasedEdgeDetectionImageFilter.txx"
#include "itkZeroCrossingImageFilter.txx"

int main ( int , char*  )
{

  return 0;
}

<|endoftext|>


<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:
  Language:  C++
  Date:
  Version:

Copyright (c) 2000 National Library of Medicine
All rights reserved.

See COPYRIGHT.txt for copyright details.

=========================================================================*/
#include <iostream>
// This file has been generated by BuildHeaderTest.tcl
// Test to include each header file for Insight

#include "itkAcosImageFilter.h"
#include "itkAdaptImageFilter.h"
#include "itkAddImageFilter.h"
#include "itkAnisotropicDiffusionEquation.h"
#include "itkAnisotropicDiffusionImageFilter.h"
#include "itkAsinImageFilter.h"
#include "itkAtan2ImageFilter.h"
#include "itkAtanImageFilter.h"
#include "itkBinaryDilateImageFilter.h"
#include "itkBinaryErodeImageFilter.h"
#include "itkBinaryFunctorImageFilter.h"
#include "itkBinaryMagnitudeImageFilter.h"
#include "itkBinaryMorphologicalDialationFilter.h"
#include "itkBinaryMorphologicalErosionFilter.h"
#include "itkBinaryMorphologicalFilterBase.h"
#include "itkBinomialBlurImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkConstantPadImageFilter.h"
#include "itkCosImageFilter.h"
#include "itkCurvature2DAnisotropicDiffusionEquation.h"
#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkCurvatureNDAnisotropicDiffusionEquation.h"
#include "itkDanielssonDistanceMapImageFilter.h"
#include "itkDerivativeImageFilter.h"
#include "itkDifferenceOfGaussiansGradientImageFilter.h"
#include "itkDiscreteGaussianImageFilter.h"
#include "itkEigenAnalysis2DImageFilter.h"
#include "itkExpImageFilter.h"
#include "itkExpandImageFilter.h"
#include "itkExtractImageFilter.h"
#include "itkFileIOToImageFilter.h"
#include "itkFirstDerivativeRecursiveGaussianImageFilter.h"
#include "itkGradient2DAnisotropicDiffusionEquation.h"
#include "itkGradientAnisotropicDiffusionImageFilter.h"
#include "itkGradientMagnitudeImageFilter.h"
#include "itkGradientNDAnisotropicDiffusionEquation.h"
#include "itkGradientRecursiveGaussianImageFilter.h"
#include "itkGradientToMagnitudeImageFilter.h"
#include "itkGrayscaleDilateImageFilter.h"
#include "itkGrayscaleErodeImageFilter.h"
#include "itkGrayscaleFunctionDilateImageFilter.h"
#include "itkGrayscaleFunctionErodeImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageToMeshFilter.h"
#include "itkImageToParametricSpaceFilter.h"
#include "itkImageWriter.h"
#include "itkImportImageFilter.h"
#include "itkJoinImageFilter.h"
#include "itkLog10ImageFilter.h"
#include "itkLogImageFilter.h"
#include "itkMirrorPadImageFilter.h"
#include "itkMorphologyImageFilter.h"
#include "itkMultiplyImageFilter.h"
#include "itkNaryAddImageFilter.h"
#include "itkNaryFunctorImageFilter.h"
#include "itkNeighborhoodOperatorImageFilter.h"
#include "itkNonThreadedShrinkImageFilter.h"
#include "itkPadImageFilter.h"
#include "itkPlaheImageFilter.h"
#include "itkRandomImageSource.h"
#include "itkRawImageWriter.h"
#include "itkRecursiveGaussianImageFilter.h"
#include "itkRecursiveSeparableImageFilter.h"
#include "itkReflectiveImageRegionIterator.h"
#include "itkResampleImageFilter.h"
#include "itkScalarAnisotropicDiffusionEquation.h"
#include "itkSecondDerivativeRecursiveGaussianImageFilter.h"
#include "itkShrinkImageFilter.h"
#include "itkSinImageFilter.h"
#include "itkSpatialFunctionImageEvaluatorFilter.h"
#include "itkSqrtImageFilter.h"
#include "itkStreamingImageFilter.h"
#include "itkSubtractImageFilter.h"
#include "itkTanImageFilter.h"
#include "itkTernaryAddImageFilter.h"
#include "itkTernaryFunctorImageFilter.h"
#include "itkTernaryMagnitudeImageFilter.h"
#include "itkTernaryMagnitudeSquaredImageFilter.h"
#include "itkThresholdImageFilter.h"
#include "itkTransformMeshFilter.h"
#include "itkTwoOutputExampleImageFilter.h"
#include "itkUnaryFunctorImageFilter.h"
#include "itkVTKImageReader.h"
#include "itkVTKImageWriter.h"
#include "itkVectorAnisotropicDiffusionEquation.h"
#include "itkVectorCastImageFilter.h"
#include "itkVectorCurvature2DAnisotropicDiffusionEquation.h"
#include "itkVectorCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkVectorCurvatureNDAnisotropicDiffusionEquation.h"
#include "itkVectorExpandImageFilter.h"
#include "itkVectorGradient2DAnisotropicDiffusionEquation.h"
#include "itkVectorGradientAnisotropicDiffusionImageFilter.h"
#include "itkVectorGradientNDAnisotropicDiffusionEquation.h"
#include "itkVectorNeighborhoodOperatorImageFilter.h"
#include "itkWarpImageFilter.h"
#include "itkWrapPadImageFilter.h"
#include "itkWriter.h"

int main ( int argc, char* argv )
{

  return 0;
}

<commit_msg>ENH: Updated to latest headers<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:
  Language:  C++
  Date:
  Version:

Copyright (c) 2000 National Library of Medicine
All rights reserved.

See COPYRIGHT.txt for copyright details.

=========================================================================*/
#include <iostream>
// This file has been generated by BuildHeaderTest.tcl
// Test to include each header file for Insight

#include "itkAcosImageFilter.h"
#include "itkAdaptImageFilter.h"
#include "itkAddImageFilter.h"
#include "itkAnisotropicDiffusionEquation.h"
#include "itkAnisotropicDiffusionImageFilter.h"
#include "itkAsinImageFilter.h"
#include "itkAtan2ImageFilter.h"
#include "itkAtanImageFilter.h"
#include "itkBinaryDilateImageFilter.h"
#include "itkBinaryErodeImageFilter.h"
#include "itkBinaryFunctorImageFilter.h"
#include "itkBinaryMagnitudeImageFilter.h"
#include "itkBinaryMorphologicalDialationFilter.h"
#include "itkBinaryMorphologicalErosionFilter.h"
#include "itkBinaryMorphologicalFilterBase.h"
#include "itkBinomialBlurImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkConstantPadImageFilter.h"
#include "itkCosImageFilter.h"
#include "itkCurvature2DAnisotropicDiffusionEquation.h"
#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkCurvatureNDAnisotropicDiffusionEquation.h"
#include "itkDanielssonDistanceMapImageFilter.h"
#include "itkDerivativeImageFilter.h"
#include "itkDifferenceOfGaussiansGradientImageFilter.h"
#include "itkDiscreteGaussianImageFilter.h"
#include "itkEigenAnalysis2DImageFilter.h"
#include "itkExpImageFilter.h"
#include "itkExpandImageFilter.h"
#include "itkExtractImageFilter.h"
#include "itkFileIOToImageFilter.h"
#include "itkFirstDerivativeRecursiveGaussianImageFilter.h"
#include "itkGradient2DAnisotropicDiffusionEquation.h"
#include "itkGradientAnisotropicDiffusionImageFilter.h"
#include "itkGradientImageFilter.h"
#include "itkGradientMagnitudeImageFilter.h"
#include "itkGradientNDAnisotropicDiffusionEquation.h"
#include "itkGradientRecursiveGaussianImageFilter.h"
#include "itkGradientToMagnitudeImageFilter.h"
#include "itkGrayscaleDilateImageFilter.h"
#include "itkGrayscaleErodeImageFilter.h"
#include "itkGrayscaleFunctionDilateImageFilter.h"
#include "itkGrayscaleFunctionErodeImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageToMeshFilter.h"
#include "itkImageToParametricSpaceFilter.h"
#include "itkImageWriter.h"
#include "itkImportImageFilter.h"
#include "itkJoinImageFilter.h"
#include "itkLog10ImageFilter.h"
#include "itkLogImageFilter.h"
#include "itkMirrorPadImageFilter.h"
#include "itkMorphologyImageFilter.h"
#include "itkMultiplyImageFilter.h"
#include "itkNaryAddImageFilter.h"
#include "itkNaryFunctorImageFilter.h"
#include "itkNeighborhoodOperatorImageFilter.h"
#include "itkNonThreadedShrinkImageFilter.h"
#include "itkPadImageFilter.h"
#include "itkPlaheImageFilter.h"
#include "itkRandomImageSource.h"
#include "itkRawImageWriter.h"
#include "itkRecursiveGaussianImageFilter.h"
#include "itkRecursiveSeparableImageFilter.h"
#include "itkReflectiveImageRegionIterator.h"
#include "itkResampleImageFilter.h"
#include "itkScalarAnisotropicDiffusionEquation.h"
#include "itkSecondDerivativeRecursiveGaussianImageFilter.h"
#include "itkShrinkImageFilter.h"
#include "itkSinImageFilter.h"
#include "itkSpatialFunctionImageEvaluatorFilter.h"
#include "itkSqrtImageFilter.h"
#include "itkStreamingImageFilter.h"
#include "itkSubtractImageFilter.h"
#include "itkTanImageFilter.h"
#include "itkTernaryAddImageFilter.h"
#include "itkTernaryFunctorImageFilter.h"
#include "itkTernaryMagnitudeImageFilter.h"
#include "itkTernaryMagnitudeSquaredImageFilter.h"
#include "itkThresholdImageFilter.h"
#include "itkTransformMeshFilter.h"
#include "itkTwoOutputExampleImageFilter.h"
#include "itkUnaryFunctorImageFilter.h"
#include "itkVTKImageReader.h"
#include "itkVTKImageWriter.h"
#include "itkVectorAnisotropicDiffusionEquation.h"
#include "itkVectorCastImageFilter.h"
#include "itkVectorCurvature2DAnisotropicDiffusionEquation.h"
#include "itkVectorCurvatureAnisotropicDiffusionImageFilter.h"
#include "itkVectorCurvatureNDAnisotropicDiffusionEquation.h"
#include "itkVectorExpandImageFilter.h"
#include "itkVectorGradient2DAnisotropicDiffusionEquation.h"
#include "itkVectorGradientAnisotropicDiffusionImageFilter.h"
#include "itkVectorGradientNDAnisotropicDiffusionEquation.h"
#include "itkVectorNeighborhoodOperatorImageFilter.h"
#include "itkWarpImageFilter.h"
#include "itkWrapPadImageFilter.h"
#include "itkWriter.h"

int main ( int argc, char* argv )
{

  return 0;
}

<|endoftext|>