Пример #1
0
void clique::create_grid(void) {
    clique::data_info info;
    get_data_info(info);

    const std::size_t dimension = m_data_ptr->at(0).size();
    const std::size_t amount_blocks = static_cast<std::size_t>(std::pow(m_intervals, dimension));

    m_result_ptr->blocks().reserve(amount_blocks);
    auto iterator = coordinate_iterator(dimension, m_intervals);

    std::vector<bool> point_availability(m_data_ptr->size(), true);

    for (std::size_t i = 0; i < amount_blocks; ++i) {
        clique_block_location logical_location = iterator.get_coordinate();
        ++iterator;

        clique_spatial_block spatial_block;
        get_spatial_location(logical_location, info, spatial_block);

        clique_block cell(logical_location, std::move(spatial_block));
        cell.capture_points(*m_data_ptr, point_availability);

        m_result_ptr->blocks().push_back(std::move(cell));

        m_cells_map.insert({ location_to_key(m_result_ptr->blocks().back().get_logical_location()), &(m_result_ptr->blocks().back()) });
    }
}
Пример #2
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_get_byte_order
@INPUT      : afp - i/o stream
@OUTPUT     : (none)
@RETURNS    : Byte ordering of stream
@DESCRIPTION: Allows one to get the byte ordering for an i/o stream.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : January 29, 1997 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
Acr_byte_order acr_get_byte_order(Acr_File *afp)
{
   Data_Info data_info;

   /* Get data info pointer */
   data_info = get_data_info(afp);

   /* Return the byte ordering */
   return data_info->byte_order;
}
Пример #3
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_ignore_protocol_errors
@INPUT      : afp - i/o stream
@OUTPUT     : (none)
@RETURNS    : TRUE if stream is set to ignore nonfatal protocol errors
@DESCRIPTION: Allows one to get the ignore errors flag for a stream
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : April 28, 2000 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
int acr_ignore_protocol_errors(Acr_File *afp)
{
   Data_Info data_info;

   /* Get data info pointer */
   data_info = get_data_info(afp);

   /* Return the VR encoding */
   return data_info->ignore_nonfatal_protocol_errors;

}
Пример #4
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_get_vr_encoding
@INPUT      : afp - i/o stream
@OUTPUT     : (none)
@RETURNS    : VR encoding of stream
@DESCRIPTION: Allows one to get the vr encoding for an i/o stream
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : January 29, 1997 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
Acr_VR_encoding_type acr_get_vr_encoding(Acr_File *afp)
{
   Data_Info data_info;

   /* Get data info pointer */
   data_info = get_data_info(afp);

   /* Return the VR encoding */
   return data_info->vr_encoding;

}
Пример #5
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_set_vr_encoding
@INPUT      : afp - i/o stream
              vr_encoding - ACR_EXPLICIT_VR or ACR_IMPLICIT_VR
@OUTPUT     : (none)
@RETURNS    : (nothing)
@DESCRIPTION: Allows a user to set the vr encoding type for an i/o stream.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : January 29, 1997 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
void acr_set_vr_encoding(Acr_File *afp, Acr_VR_encoding_type vr_encoding)
{
   Data_Info data_info;

   /* Get data info pointer */
   data_info = get_data_info(afp);

   /* Set the VR encoding */
   data_info->vr_encoding = vr_encoding;

}
Пример #6
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_set_byte_order
@INPUT      : afp - i/o stream
              byte_order - ACR_LITTLE_ENDIAN or ACR_BIG_ENDIAN.
@OUTPUT     : (none)
@RETURNS    : (nothing)
@DESCRIPTION: Allows a user to set the byte ordering for an i/o stream.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : January 29, 1997 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
void acr_set_byte_order(Acr_File *afp, Acr_byte_order byte_order)
{
   Data_Info data_info;

   /* Get data info pointer */
   data_info = get_data_info(afp);

   /* Set the byte ordering */
   data_info->byte_order = byte_order;

}
Пример #7
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : acr_set_ignore_errors
@INPUT      : afp - i/o stream
              ignore_nonfatal_protocol_errors - if TRUE then non-fatal
                 protocol errors will be ignored
@OUTPUT     : (none)
@RETURNS    : (nothing)
@DESCRIPTION: Allows a user to indicate whether to ignore protocol errors
              that can be ignored.
@METHOD     : 
@GLOBALS    : 
@CALLS      : 
@CREATED    : April 28, 2000 (Peter Neelin)
@MODIFIED   : 
---------------------------------------------------------------------------- */
void acr_set_ignore_errors(Acr_File *afp, int ignore_nonfatal_protocol_errors)
{
   Data_Info data_info;

   /* Get data info pointer */
   data_info = get_data_info(afp);

   /* Set the flag */
   data_info->ignore_nonfatal_protocol_errors = 
      ignore_nonfatal_protocol_errors;

}
Пример #8
0
S_LOCAL void _s_voice_load_data(SVoice *self, const SMap *dataConfig, s_erc *error)
{
	SIterator *itr;
	const char *data_name;
	const SObject *loaded;
	const SMap *dataObjectMap;
	s_data_info *data_info;
	const SObject *vcfgObject;
	char *voice_base_path;


	S_CLR_ERR(error);

	if (self == NULL)
	{
		S_CTX_ERR(error, S_ARGERROR,
				  "_s_voice_load_data",
				  "Argument \"self\" is NULL");
		return;
	}

	/* get voice base path */
	vcfgObject = SVoiceGetFeature(self, "config_file", error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_s_voice_load_data",
				  "Call to \"SVoiceGetFeature\" failed, failed to get voice config file"))
		return;

	voice_base_path = s_get_base_path(SObjectGetString(vcfgObject, error), error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_s_voice_load_data",
				  "Call to \"s_get_base_path/SObjectGetString\" failed"))
		return;

	/*
	 * now iterate through data config and load everything
	 */
	itr = S_ITERATOR_GET(dataConfig, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "_s_voice_load_data",
				  "Call to \"S_ITERATOR_GET\" failed"))
	{
		S_DELETE(itr, "_s_voice_load_data", error);
		S_FREE(voice_base_path);
		return;
	}

	while (itr)
	{
		char *combined_path;


		data_name = SIteratorKey(itr, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Call to \"SIteratorKey\" failed"))
		{
			S_DELETE(itr, "_s_voice_load_data", error);
			S_FREE(voice_base_path);
			return;
		}

		/*
		 * We have already checked this cast in
		 * _s_voice_load_dataConfig (_s_load_voice_data_config)
		 */
		dataObjectMap = (const SMap*)SMapGetObjectDef(dataConfig, data_name, NULL, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Call to \"SMapGetObjectDef\" for data '%s' failed",
					  data_name))
		{
			S_DELETE(itr, "_s_voice_load_data", error);
			S_FREE(voice_base_path);
			return;
		}

		if (dataObjectMap == NULL)
		{
			S_CTX_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Data object map for data '%s' in data config in NULL",
					  data_name);
			S_DELETE(itr, "_s_voice_load_data", error);
			S_FREE(voice_base_path);
			return;
		}

		data_info = get_data_info(dataObjectMap, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Call to \"get_data_info\" for data '%s' in data config failed",
					  data_name))
		{
			S_DELETE(itr, "_s_voice_load_data", error);
			S_FREE(voice_base_path);
			return;
		}

		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path = s_path_combine(voice_base_path, data_info->path,
									   error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Call to \"s_path_combine\" failed"))
		{
			S_DELETE(itr, "_s_voice_load_data", error);
			S_FREE(voice_base_path);
			return;
		}

		loaded = _s_vm_load_data(data_info->plugin, combined_path,
								 data_info->format, error);
		S_FREE(combined_path);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Call to \"_s_vm_load_data\" for data '%s' in data config failed",
					  data_name))
		{
			S_FREE(data_info);
			S_DELETE(itr, "_s_voice_load_data", error);
			S_FREE(voice_base_path);
			return;
		}

		S_FREE(data_info);

		SMapSetObject(self->data->dataObjects, data_name, loaded, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "_s_voice_load_data",
					  "Call to \"SMapSetObject\" for data '%s' in data config failed",
					  data_name))
		{
			s_erc local_err = S_SUCCESS;


			S_FREE(voice_base_path);
			S_DELETE(itr, "_s_voice_load_data", error);
			_s_vm_unload_data((SObject*)loaded, &local_err); /* error is already set */
			return;
		}

		itr = SIteratorNext(itr);
	}

	S_FREE(voice_base_path);
}