diff --git a/cloudreg/scripts/quantify_fluorescence_by_region.py b/cloudreg/scripts/quantify_fluorescence_by_region.py index 7327f53..0ce5425 100644 --- a/cloudreg/scripts/quantify_fluorescence_by_region.py +++ b/cloudreg/scripts/quantify_fluorescence_by_region.py @@ -63,33 +63,13 @@ def save_results_to_csv(fluorescence_dict, columns, out_path): df.to_csv(out_path) -def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - "data_s3_path", - help="full s3 path to data of interest as precomputed volume. must be of the form `s3://bucket-name/path/to/channel`", - ) - parser.add_argument( - "atlas_s3_path", - help="full s3 path to transfomed atlas. must have the same number of slices as native resolution data.", - ) - parser.add_argument("out_path", help="path to save output results") - parser.add_argument( - "--path_to_ontology", - help="path to save output results", - type=str, - default=os.path.expanduser("~/MBAC/scripts/ARA_stuff/ara_ontology.json"), - ) - parser.add_argument( - "--num_procs", help="number of processes to use", default=16, type=int - ) - args = parser.parse_args() - data_vol = CloudVolume(args.data_s3_path) - id2name = get_ara_dict(args.path_to_ontology) - experiment_name = "_".join(args.data_s3_path.split("/")[-2:]) +def quantify_fluorescence_by_region(data_s3_path,atlas_s3_path,path_to_ontology,outfile='./quantification.csv',num_procs=-1): + data_vol = CloudVolume(data_s3_path) + id2name = get_ara_dict(path_to_ontology) + experiment_name = "_".join(data_s3_path.split("/")[-2:]) - results = Parallel(args.num_procs)( - delayed(get_region_stats)(args.atlas_s3_path, args.data_s3_path, i) + results = Parallel(num_procs)( + delayed(get_region_stats)(atlas_s3_path, data_s3_path, i) for i in trange(data_vol.scales[0]["size"][-1]) ) total_fluorescence, total_volume = combine_results(results) @@ -101,7 +81,7 @@ def main(): } # density by roi columns = ["atlas id", "fluorescence density"] - outfile = f"{args.out_path}" + # outfile = f"{outfile}" fluorescence_density_roi = defaultdict(float) for i, j in fluorescence_density_sorted.items(): fluorescence_density_roi[id2name[i]] = [i, j] @@ -120,4 +100,35 @@ def main(): if __name__ == "__main__": - main() + parser = argparse.ArgumentParser() + parser.add_argument( + "data_s3_path", + help="full s3 path to data of interest as precomputed volume. must be of the form `s3://bucket-name/path/to/channel`", + ) + parser.add_argument( + "atlas_s3_path", + help="full s3 path to transfomed atlas. must have the same number of slices as native resolution data.", + ) + parser.add_argument("out_path", help="path to save output results") + parser.add_argument( + "--path_to_ontology", + help="path to save output results", + type=str, + default=os.path.expanduser("~/CloudReg/cloudreg/scripts/ARA_stuff/ara_ontology.json"), + ) + parser.add_argument( + "--num_procs", help="number of processes to use", default=16, type=int + ) + parser.add_argument( + "--outfile", help="path to CSV to store results. Example: /path/to/data/quantification.csv", + default='./quantification.csv', + type=str + ) + args = parser.parse_args() + quantify_fluorescence_by_region( + args.data_s3_path, + args.atlas_s3_path, + args.path_to_ontology, + args.outfile, + args.num_procs + ) diff --git a/cloudreg/scripts/transform_points.py b/cloudreg/scripts/transform_points.py new file mode 100644 index 0000000..a58d996 --- /dev/null +++ b/cloudreg/scripts/transform_points.py @@ -0,0 +1,342 @@ +# local imports +from .util import aws_cli +from .visualization import create_viz_link_from_json, get_neuroglancer_json + +import pathlib +import subprocess +import shlex +import requests as r +import numpy as np +import h5py +from cloudvolume import CloudVolume +from collections import defaultdict +import uuid +import argparse +from scipy.io import loadmat +import json + + +def loadmat_v73(mat_path): + arrays = {} + f = h5py.File(mat_path, "r") + for k, v in f.items(): + arrays[k] = np.array(v) + return arrays + + +class NGLink: + def __init__(self, json_link): + self.points = defaultdict(lambda: "") + self.json_link = json_link + self._set_json_from_link() + + def get_annotations(self, points): + annotations = [] + for i, j in points.items(): + x = { + "point": j.tolist(), + "type": "point", + "id": f"{uuid.uuid1().hex}", + "description": i, + } + annotations.append(x) + return annotations + + def get_points_in(self, coordinate_system): + if coordinate_system == "voxel": + return self.points + else: + return {i[0]: (i[1] * self.points_voxel_size) for i in self.points.items()} + + def _set_json_from_link(self): + self._json = r.get(self.json_link).json() + self._parse_voxel_size() + self.output_dim = [self._json["dimensions"][i] for i in self._json["dimensions"].keys()] + self.layers = [self._parse_layer(i) for i in self._json["layers"]] + + def _parse_layer(self, layer_data): + if layer_data["type"] == "image": + return self._parse_image_layer(layer_data) + elif layer_data["type"] == "annotation": + return self._parse_annotation_layer(layer_data) + else: + return + + def _parse_annotation_layer(self, layer_data): + # points in physical units + for i in layer_data["annotations"]: + if i["type"] != "point": + continue + if "description" in i.keys(): + self.points[i["description"].strip()] = i["point"] + else: + self.points[f"{i['id']}"] = i["point"] + return layer_data + + def _parse_image_layer(self, layer_data): + vol = CloudVolume(layer_data["source"]["url"].split("precomputed://")[-1]) + self.image_shape = np.array(vol.scales[0]["size"]) + # converting from nm to um + self.image_voxel_size = np.array(vol.scales[0]["resolution"]) / 1e3 + self.voxel_origin = self.image_shape / 2 + self.physical_origin = self.voxel_origin * self.image_voxel_size + return layer_data + + def _parse_voxel_size(self): + dims = self._json["dimensions"] + x_size_m, y_size_m, z_size_m = dims["x"][0], dims["y"][0], dims["z"][0] + # converting from m to um + self.points_voxel_size = np.array([x_size_m, y_size_m, z_size_m]) * 1e6 + + +class Fiducial: + def __init__(self, point, orientation, image_shape, voxel_size, description=""): + """ + point: 3D point in physical space of fiducial (array-like len 3) + image_size: size in physical units of native res image in each dim (array-like len 3) + """ + self.image_shape = np.asarray(image_shape) + self.voxel_size = np.asarray(voxel_size) + self._set_origin() + self.point = np.asarray(point) - self.origin + self.description = description + self.orientation = orientation + self.ng_point = np.asarray(point) + + def _set_origin(self): + self.origin = (self.image_shape - 1) * self.voxel_size / 2 + + def reorient_point(self, out_orient): + dimension = len(self.point) + in_orient = str(self.orientation).lower() + out_orient = str(out_orient).lower() + + inDirection = "" + outDirection = "" + orientToDirection = {"r": "r", "l": "r", "s": "s", "i": "s", "a": "a", "p": "a"} + for i in range(dimension): + try: + inDirection += orientToDirection[in_orient[i]] + except BaseException: + raise Exception("in_orient '{0}' is invalid.".format(in_orient)) + + try: + outDirection += orientToDirection[out_orient[i]] + except BaseException: + raise Exception("out_orient '{0}' is invalid.".format(out_orient)) + + if len(set(inDirection)) != dimension: + raise Exception("in_orient '{0}' is invalid.".format(in_orient)) + if len(set(outDirection)) != dimension: + raise Exception("out_orient '{0}' is invalid.".format(out_orient)) + + order = [] + flip = [] + for i in range(dimension): + j = inDirection.find(outDirection[i]) + order += [j] + flip += [in_orient[j] != out_orient[i]] + new_point = self._flip_point(self.point, axis=flip) + new_point = new_point[order] + # update self + self.point = new_point + self.orientation = out_orient + + return new_point + + def _reorient_point(self, out_orient): + dimension = len(self.point) + in_orient = str(self.orientation).lower() + out_orient = str(out_orient).lower() + + inDirection = "" + outDirection = "" + orientToDirection = {"r": "r", "l": "r", "s": "s", "i": "s", "a": "a", "p": "a"} + for i in range(dimension): + try: + inDirection += orientToDirection[in_orient[i]] + except BaseException: + raise Exception("in_orient '{0}' is invalid.".format(in_orient)) + + try: + outDirection += orientToDirection[out_orient[i]] + except BaseException: + raise Exception("out_orient '{0}' is invalid.".format(out_orient)) + + if len(set(inDirection)) != dimension: + raise Exception("in_orient '{0}' is invalid.".format(in_orient)) + if len(set(outDirection)) != dimension: + raise Exception("out_orient '{0}' is invalid.".format(out_orient)) + + order = [] + flip = [] + for i in range(dimension): + j = inDirection.find(outDirection[i]) + order += [j] + flip += [in_orient[j] != out_orient[i]] + new_point = self._flip_point(self.point, axis=flip) + new_point = new_point[order] + # update self + self.orientation = out_orient + self.point = new_point + + return new_point + + def _flip_point(self, point, axis=0): + tmp_point = point.copy() + tmp_point[axis] = -point[axis] + return tmp_point + + def __str__(self): + return f"{self.description}: [{self.point[0]}, {self.point[1]}, {self.point[2]} ]\norientation: {self.orientation}" + + +def transform_points( + target_viz_link, + atlas_viz_link, + affine_path, + velocity_path, + # voxel size of velocity field + velocity_field_vsize, + # transformation direction + # can be 'atlas' or 'target' + transformation_direction, +): + # get json link from viz link + target_viz = NGLink(target_viz_link.split("json_url=")[-1]) + atlas_viz = NGLink(atlas_viz_link.split("json_url=")[-1]) + + # get origin-centered fiducials from viz link + atlas_fiducials = [ + Fiducial( + j, + '', + atlas_viz.image_shape, + atlas_viz.image_voxel_size, + description=i, + ) + for i, j in atlas_viz.get_points_in("physical").items() + ] + target_fiducials = [ + Fiducial( + j, + '', + target_viz.image_shape, + target_viz.image_voxel_size, + description=i, + ) + for i, j in target_viz.get_points_in("physical").items() + ] + if transformation_direction == 'target': + fiducials = atlas_fiducials + other_fid = target_viz + viz = target_viz + else: + fiducials = target_fiducials + other_fid = atlas_viz + viz = atlas_viz + try: + dest_vox_size = other_fid.points_voxel_size + except: + dest_vox_size = other_fid.output_dim + + + # run matlab command to get transformed fiducials + if affine_path != "" and velocity_path != "": + points = [i.point for i in fiducials] + points_string = [", ".join(map(str, i)) for i in points] + points_string = "; ".join(points_string) + # velocity field voxel size + v_size = ", ".join(str(i) for i in velocity_field_vsize) + # get current file path and set path to transform_points + base_path = pathlib.Path(__file__).parent.parent.absolute() / 'registration' + # base_path = os.path.expanduser("~/CloudReg/registration") + transformed_points_path = "./transformed_points.mat" + + matlab_path = 'matlab' + matlab_command = f""" + {matlab_path} -nodisplay -nosplash -nodesktop -r \"addpath(\'{base_path}\');Aname=\'{affine_path}\';vname=\'{velocity_path}\';v_size=[{v_size}];points=[{points_string}];points_t = transform_points(points,Aname,vname,v_size,\'{transformation_direction}\');save(\'./transformed_points.mat\',\'points_t\');exit;\" + """ + subprocess.run(shlex.split(matlab_command),) + + # transformed_points.m created now + points_t = loadmat(transformed_points_path)["points_t"] + points_ng = {i.description: (j + other_fid.physical_origin)/dest_vox_size for i, j in zip(fiducials, points_t)} + points_ng_json = viz.get_annotations(points_ng) + with open('./transformed_points.json', 'w') as fp: + json.dump(points_ng_json, fp) + + ngl_json = atlas_viz._json + ngl_json['layers'].append( + { + "type": "annotation", + "annotations": points_ng_json, + "name": "transformed_points" + } + ) + viz_link = create_viz_link_from_json(ngl_json) + print(f"VIZ LINK WITH TRANSFORMED POINTS: {viz_link}") + + else: + raise Exception + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + "Transform points in Neuroglancer from one space to another given a transformation." + ) + parser.add_argument( + "-target_viz_link", help="Neuroglancer viz link to target with fiducials labelled.", type=str + ) + parser.add_argument( + "--atlas_viz_link", help="Neuroglancer viz link to atlas (optionally with fiducials labelled if transforming to input data space). Default is link to ARA.", + type=str, + default="https://ara.viz.neurodata.io/?json_url=https://json.neurodata.io/v1?NGStateID=ifm4oFKOl10eiA" + ) + parser.add_argument( + "--affine_path", + help="S3 path or local path to matlab transformation files. These will be downloaded to compute the fiducial accuracy", + type=str, + default="", + ) + parser.add_argument( + "--velocity_path", + help="S3 path ot local matlab transformation files. These will be downloaded to compute the fiducial accuracy", + type=str, + default="", + ) + parser.add_argument( + "--velocity_voxel_size", + help="Voxel size of velocity field in microns", + nargs="+", + type=float, + default=[100.0] * 3, + ) + parser.add_argument( + "--transformation_direction", help="viz link to atlas with fiducials labelled", + type=str, + default='atlas' + ) + # parser.add_argument('-ssh_key_path', help='path to identity file used to ssh into given instance') + # parser.add_argument('-instance_id', help='EC2 Instance ID of instance to run COLM pipeline on.') + # parser.add_argument('--instance_type', help='EC2 instance type to run pipeline on. minimum r5d.16xlarge', type=str, default='r5d.16xlarge') + + args = parser.parse_args() + + if args.affine_path.startswith("s3://") or args.affine_path.startswith("http"): + # download affine mat to local storage + aws_cli(shlex.split(f"s3 cp {args.affine_path} ./A.mat")) + args.affine_path = "./A.mat" + if args.velocity_path.startswith("s3://") or args.velocity_path.startswith("http"): + # download velocity mat to local storage + aws_cli(shlex.split(f"s3 cp {args.velocity_path} ./v.mat")) + args.velocity_path = "./v.mat" + + transform_points( + args.target_viz_link, + args.atlas_viz_link, + args.affine_path, + args.velocity_path, + args.velocity_voxel_size, + args.transformation_direction, + ) diff --git a/cloudreg/scripts/visualization.py b/cloudreg/scripts/visualization.py index 447d4df..9ec7063 100644 --- a/cloudreg/scripts/visualization.py +++ b/cloudreg/scripts/visualization.py @@ -82,6 +82,15 @@ def create_viz_link( viz_link = f"{neuroglancer_link}{json_url}" return viz_link +def create_viz_link_from_json( + ngl_json, + url="https://json.neurodata.io/v1", + neuroglancer_link="https://ara.viz.neurodata.io/?json_url=", +): + r = requests.post(url, json=ngl_json) + json_url = r.json()["uri"] + viz_link = f"{neuroglancer_link}{json_url}" + return viz_link def get_neuroglancer_json(s3_layer_paths, affine_matrices, output_resolution): """Generate Neuroglancer state json. diff --git a/cloudreg_env/bin/activate b/cloudreg_env/bin/activate deleted file mode 100644 index 811b459..0000000 --- a/cloudreg_env/bin/activate +++ /dev/null @@ -1,84 +0,0 @@ -# This file must be used with "source bin/activate" *from bash* -# you cannot run it directly - - -if [ "${BASH_SOURCE-}" = "$0" ]; then - echo "You must source this script: \$ source $0" >&2 - exit 33 -fi - -deactivate () { - unset -f pydoc >/dev/null 2>&1 - - # reset old environment variables - # ! [ -z ${VAR+_} ] returns true if VAR is declared at all - if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then - PATH="$_OLD_VIRTUAL_PATH" - export PATH - unset _OLD_VIRTUAL_PATH - fi - if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then - PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" - export PYTHONHOME - unset _OLD_VIRTUAL_PYTHONHOME - fi - - # This should detect bash and zsh, which have a hash command that must - # be called to get it to forget past commands. Without forgetting - # past commands the $PATH changes we made may not be respected - if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then - hash -r 2>/dev/null - fi - - if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then - PS1="$_OLD_VIRTUAL_PS1" - export PS1 - unset _OLD_VIRTUAL_PS1 - fi - - unset VIRTUAL_ENV - if [ ! "${1-}" = "nondestructive" ] ; then - # Self destruct! - unset -f deactivate - fi -} - -# unset irrelevant variables -deactivate nondestructive - -VIRTUAL_ENV="/Users/vikram/CloudReg/cloudreg_env" -export VIRTUAL_ENV - -_OLD_VIRTUAL_PATH="$PATH" -PATH="$VIRTUAL_ENV/bin:$PATH" -export PATH - -# unset PYTHONHOME if set -if ! [ -z "${PYTHONHOME+_}" ] ; then - _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" - unset PYTHONHOME -fi - -if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then - _OLD_VIRTUAL_PS1="${PS1-}" - if [ "x" != x ] ; then - PS1="${PS1-}" - else - PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}" - fi - export PS1 -fi - -# Make sure to unalias pydoc if it's already there -alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true - -pydoc () { - python -m pydoc "$@" -} - -# This should detect bash and zsh, which have a hash command that must -# be called to get it to forget past commands. Without forgetting -# past commands the $PATH changes we made may not be respected -if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then - hash -r 2>/dev/null -fi diff --git a/cloudreg_env/bin/activate.csh b/cloudreg_env/bin/activate.csh deleted file mode 100644 index 63c2bb5..0000000 --- a/cloudreg_env/bin/activate.csh +++ /dev/null @@ -1,55 +0,0 @@ -# This file must be used with "source bin/activate.csh" *from csh*. -# You cannot run it directly. -# Created by Davide Di Blasi . - -set newline='\ -' - -alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc' - -# Unset irrelevant variables. -deactivate nondestructive - -setenv VIRTUAL_ENV "/Users/vikram/CloudReg/cloudreg_env" - -set _OLD_VIRTUAL_PATH="$PATH:q" -setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q" - - - -if ("" != "") then - set env_name = "" -else - set env_name = '('"$VIRTUAL_ENV:t:q"') ' -endif - -if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then - if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then - set do_prompt = "1" - else - set do_prompt = "0" - endif -else - set do_prompt = "1" -endif - -if ( $do_prompt == "1" ) then - # Could be in a non-interactive environment, - # in which case, $prompt is undefined and we wouldn't - # care about the prompt anyway. - if ( $?prompt ) then - set _OLD_VIRTUAL_PROMPT="$prompt:q" - if ( "$prompt:q" =~ *"$newline:q"* ) then - : - else - set prompt = "$env_name:q$prompt:q" - endif - endif -endif - -unset env_name -unset do_prompt - -alias pydoc python -m pydoc - -rehash diff --git a/cloudreg_env/bin/activate.fish b/cloudreg_env/bin/activate.fish deleted file mode 100644 index c33ab6f..0000000 --- a/cloudreg_env/bin/activate.fish +++ /dev/null @@ -1,102 +0,0 @@ -# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*. -# Do not run it directly. - -function _bashify_path -d "Converts a fish path to something bash can recognize" - set fishy_path $argv - set bashy_path $fishy_path[1] - for path_part in $fishy_path[2..-1] - set bashy_path "$bashy_path:$path_part" - end - echo $bashy_path -end - -function _fishify_path -d "Converts a bash path to something fish can recognize" - echo $argv | tr ':' '\n' -end - -function deactivate -d 'Exit virtualenv mode and return to the normal environment.' - # reset old environment variables - if test -n "$_OLD_VIRTUAL_PATH" - # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling - if test (echo $FISH_VERSION | tr "." "\n")[1] -lt 3 - set -gx PATH (_fishify_path $_OLD_VIRTUAL_PATH) - else - set -gx PATH $_OLD_VIRTUAL_PATH - end - set -e _OLD_VIRTUAL_PATH - end - - if test -n "$_OLD_VIRTUAL_PYTHONHOME" - set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME - set -e _OLD_VIRTUAL_PYTHONHOME - end - - if test -n "$_OLD_FISH_PROMPT_OVERRIDE" - and functions -q _old_fish_prompt - # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`. - set -l fish_function_path - - # Erase virtualenv's `fish_prompt` and restore the original. - functions -e fish_prompt - functions -c _old_fish_prompt fish_prompt - functions -e _old_fish_prompt - set -e _OLD_FISH_PROMPT_OVERRIDE - end - - set -e VIRTUAL_ENV - - if test "$argv[1]" != 'nondestructive' - # Self-destruct! - functions -e pydoc - functions -e deactivate - functions -e _bashify_path - functions -e _fishify_path - end -end - -# Unset irrelevant variables. -deactivate nondestructive - -set -gx VIRTUAL_ENV "/Users/vikram/CloudReg/cloudreg_env" - -# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling -if test (echo $FISH_VERSION | tr "." "\n")[1] -lt 3 - set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH) -else - set -gx _OLD_VIRTUAL_PATH $PATH -end -set -gx PATH "$VIRTUAL_ENV/bin" $PATH - -# Unset `$PYTHONHOME` if set. -if set -q PYTHONHOME - set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME - set -e PYTHONHOME -end - -function pydoc - python -m pydoc $argv -end - -if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" - # Copy the current `fish_prompt` function as `_old_fish_prompt`. - functions -c fish_prompt _old_fish_prompt - - function fish_prompt - # Save the current $status, for fish_prompts that display it. - set -l old_status $status - - # Prompt override provided? - # If not, just prepend the environment name. - if test -n "" - printf '%s%s' "" (set_color normal) - else - printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV") - end - - # Restore the original $status - echo "exit $old_status" | source - _old_fish_prompt - end - - set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" -end diff --git a/cloudreg_env/bin/activate.ps1 b/cloudreg_env/bin/activate.ps1 deleted file mode 100644 index 95504d3..0000000 --- a/cloudreg_env/bin/activate.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -$script:THIS_PATH = $myinvocation.mycommand.path -$script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent - -function global:deactivate([switch] $NonDestructive) { - if (Test-Path variable:_OLD_VIRTUAL_PATH) { - $env:PATH = $variable:_OLD_VIRTUAL_PATH - Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global - } - - if (Test-Path function:_old_virtual_prompt) { - $function:prompt = $function:_old_virtual_prompt - Remove-Item function:\_old_virtual_prompt - } - - if ($env:VIRTUAL_ENV) { - Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue - } - - if (!$NonDestructive) { - # Self destruct! - Remove-Item function:deactivate - Remove-Item function:pydoc - } -} - -function global:pydoc { - python -m pydoc $args -} - -# unset irrelevant variables -deactivate -nondestructive - -$VIRTUAL_ENV = $BASE_DIR -$env:VIRTUAL_ENV = $VIRTUAL_ENV - -New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH - -$env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATH -if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) { - function global:_old_virtual_prompt { - "" - } - $function:_old_virtual_prompt = $function:prompt - - if ("" -ne "") { - function global:prompt { - # Add the custom prefix to the existing prompt - $previous_prompt_value = & $function:_old_virtual_prompt - ("" + $previous_prompt_value) - } - } - else { - function global:prompt { - # Add a prefix to the current prompt, but don't discard it. - $previous_prompt_value = & $function:_old_virtual_prompt - $new_prompt_value = "($( Split-Path $env:VIRTUAL_ENV -Leaf )) " - ($new_prompt_value + $previous_prompt_value) - } - } -} diff --git a/cloudreg_env/bin/activate.xsh b/cloudreg_env/bin/activate.xsh deleted file mode 100644 index 1ab8e71..0000000 --- a/cloudreg_env/bin/activate.xsh +++ /dev/null @@ -1,46 +0,0 @@ -"""Xonsh activate script for virtualenv""" -from xonsh.tools import get_sep as _get_sep - -def _deactivate(args): - if "pydoc" in aliases: - del aliases["pydoc"] - - if ${...}.get("_OLD_VIRTUAL_PATH", ""): - $PATH = $_OLD_VIRTUAL_PATH - del $_OLD_VIRTUAL_PATH - - if ${...}.get("_OLD_VIRTUAL_PYTHONHOME", ""): - $PYTHONHOME = $_OLD_VIRTUAL_PYTHONHOME - del $_OLD_VIRTUAL_PYTHONHOME - - if "VIRTUAL_ENV" in ${...}: - del $VIRTUAL_ENV - - if "VIRTUAL_ENV_PROMPT" in ${...}: - del $VIRTUAL_ENV_PROMPT - - if "nondestructive" not in args: - # Self destruct! - del aliases["deactivate"] - - -# unset irrelevant variables -_deactivate(["nondestructive"]) -aliases["deactivate"] = _deactivate - -$VIRTUAL_ENV = r"/Users/vikram/CloudReg/cloudreg_env" - -$_OLD_VIRTUAL_PATH = $PATH -$PATH = $PATH[:] -$PATH.add($VIRTUAL_ENV + _get_sep() + "bin", front=True, replace=True) - -if ${...}.get("PYTHONHOME", ""): - # unset PYTHONHOME if set - $_OLD_VIRTUAL_PYTHONHOME = $PYTHONHOME - del $PYTHONHOME - -$VIRTUAL_ENV_PROMPT = "" -if not $VIRTUAL_ENV_PROMPT: - del $VIRTUAL_ENV_PROMPT - -aliases["pydoc"] = ["python", "-m", "pydoc"] diff --git a/cloudreg_env/bin/activate_this.py b/cloudreg_env/bin/activate_this.py deleted file mode 100644 index aa96457..0000000 --- a/cloudreg_env/bin/activate_this.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Activate virtualenv for current interpreter: - -Use exec(open(this_file).read(), {'__file__': this_file}). - -This can be used when you must use an existing Python interpreter, not the virtualenv bin/python. -""" -import os -import site -import sys - -try: - __file__ -except NameError: - raise AssertionError("You must use exec(open(this_file).read(), {'__file__': this_file}))") - -# prepend bin to PATH (this file is inside the bin directory) -bin_dir = os.path.dirname(os.path.abspath(__file__)) -os.environ["PATH"] = os.pathsep.join([bin_dir] + os.environ.get("PATH", "").split(os.pathsep)) - -base = os.path.dirname(bin_dir) - -# virtual env is right above bin directory -os.environ["VIRTUAL_ENV"] = base - -# add the virtual environments site-package to the host python import mechanism -IS_PYPY = hasattr(sys, "pypy_version_info") -IS_JYTHON = sys.platform.startswith("java") -if IS_JYTHON: - site_packages = os.path.join(base, "Lib", "site-packages") -elif IS_PYPY: - site_packages = os.path.join(base, "site-packages") -else: - IS_WIN = sys.platform == "win32" - if IS_WIN: - site_packages = os.path.join(base, "Lib", "site-packages") - else: - site_packages = os.path.join(base, "lib", "python{}.{}".format(*sys.version_info), "site-packages") - -prev = set(sys.path) -site.addsitedir(site_packages) -sys.real_prefix = sys.prefix -sys.prefix = base - -# Move the added items to the front of the path, in place -new = list(sys.path) -sys.path[:] = [i for i in new if i not in prev] + [i for i in new if i in prev] diff --git a/cloudreg_env/bin/aws b/cloudreg_env/bin/aws deleted file mode 100755 index 496cef9..0000000 --- a/cloudreg_env/bin/aws +++ /dev/null @@ -1,27 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -# Licensed under the Apache License, Version 2.0 (the "License"). You -# may not use this file except in compliance with the License. A copy of -# the License is located at - -# http://aws.amazon.com/apache2.0/ - -# or in the "license" file accompanying this file. This file is -# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF -# ANY KIND, either express or implied. See the License for the specific -# language governing permissions and limitations under the License. -import sys -import os - -if os.environ.get('LC_CTYPE', '') == 'UTF-8': - os.environ['LC_CTYPE'] = 'en_US.UTF-8' -import awscli.clidriver - - -def main(): - return awscli.clidriver.main() - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/cloudreg_env/bin/aws.cmd b/cloudreg_env/bin/aws.cmd deleted file mode 100755 index 3f8caa7..0000000 --- a/cloudreg_env/bin/aws.cmd +++ /dev/null @@ -1,59 +0,0 @@ -@echo OFF -REM=""" -setlocal -set PythonExe="" -set PythonExeFlags= - -for %%i in (cmd bat exe) do ( - for %%j in (python.%%i) do ( - call :SetPythonExe "%%~$PATH:j" - ) -) -for /f "tokens=2 delims==" %%i in ('assoc .py') do ( - for /f "tokens=2 delims==" %%j in ('ftype %%i') do ( - for /f "tokens=1" %%k in ("%%j") do ( - call :SetPythonExe %%k - ) - ) -) -%PythonExe% -x %PythonExeFlags% "%~f0" %* -exit /B %ERRORLEVEL% -goto :EOF - -:SetPythonExe -if not ["%~1"]==[""] ( - if [%PythonExe%]==[""] ( - set PythonExe="%~1" - ) -) -goto :EOF -""" - -# =================================================== -# Python script starts here -# =================================================== - -#!/usr/bin/env python -# Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -# Licensed under the Apache License, Version 2.0 (the "License"). You -# may not use this file except in compliance with the License. A copy of -# the License is located at - -# http://aws.amazon.com/apache2.0/ - -# or in the "license" file accompanying this file. This file is -# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF -# ANY KIND, either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -import awscli.clidriver -import sys - - -def main(): - return awscli.clidriver.main() - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/cloudreg_env/bin/aws_bash_completer b/cloudreg_env/bin/aws_bash_completer deleted file mode 100755 index 32cd1dd..0000000 --- a/cloudreg_env/bin/aws_bash_completer +++ /dev/null @@ -1,6 +0,0 @@ -# Typically that would be added under one of the following paths: -# - /etc/bash_completion.d -# - /usr/local/etc/bash_completion.d -# - /usr/share/bash-completion/completions - -complete -C aws_completer aws diff --git a/cloudreg_env/bin/aws_completer b/cloudreg_env/bin/aws_completer deleted file mode 100755 index a91a2d2..0000000 --- a/cloudreg_env/bin/aws_completer +++ /dev/null @@ -1,29 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved. - -# Licensed under the Apache License, Version 2.0 (the "License"). You -# may not use this file except in compliance with the License. A copy of -# the License is located at - -# http://aws.amazon.com/apache2.0/ - -# or in the "license" file accompanying this file. This file is -# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF -# ANY KIND, either express or implied. See the License for the specific -# language governing permissions and limitations under the License. - -import os -if os.environ.get('LC_CTYPE', '') == 'UTF-8': - os.environ['LC_CTYPE'] = 'en_US.UTF-8' -import awscli.completer - -if __name__ == '__main__': - # bash exports COMP_LINE and COMP_POINT, tcsh COMMAND_LINE only - cline = os.environ.get('COMP_LINE') or os.environ.get('COMMAND_LINE') or '' - cpoint = int(os.environ.get('COMP_POINT') or len(cline)) - try: - awscli.completer.complete(cline, cpoint) - except KeyboardInterrupt: - # If the user hits Ctrl+C, we don't want to print - # a traceback to the user. - pass diff --git a/cloudreg_env/bin/aws_zsh_completer.sh b/cloudreg_env/bin/aws_zsh_completer.sh deleted file mode 100755 index a2ee80e..0000000 --- a/cloudreg_env/bin/aws_zsh_completer.sh +++ /dev/null @@ -1,60 +0,0 @@ -# Source this file to activate auto completion for zsh using the bash -# compatibility helper. Make sure to run `compinit` before, which should be -# given usually. -# -# % source /path/to/zsh_complete.sh -# -# Typically that would be called somewhere in your .zshrc. -# -# Note, the overwrite of _bash_complete() is to export COMP_LINE and COMP_POINT -# That is only required for zsh <= edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570 -# -# https://github.com/zsh-users/zsh/commit/edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570 -# -# zsh relases prior to that version do not export the required env variables! - -autoload -Uz bashcompinit -bashcompinit -i - -_bash_complete() { - local ret=1 - local -a suf matches - local -x COMP_POINT COMP_CWORD - local -a COMP_WORDS COMPREPLY BASH_VERSINFO - local -x COMP_LINE="$words" - local -A savejobstates savejobtexts - - (( COMP_POINT = 1 + ${#${(j. .)words[1,CURRENT]}} + $#QIPREFIX + $#IPREFIX + $#PREFIX )) - (( COMP_CWORD = CURRENT - 1)) - COMP_WORDS=( $words ) - BASH_VERSINFO=( 2 05b 0 1 release ) - - savejobstates=( ${(kv)jobstates} ) - savejobtexts=( ${(kv)jobtexts} ) - - [[ ${argv[${argv[(I)nospace]:-0}-1]} = -o ]] && suf=( -S '' ) - - matches=( ${(f)"$(compgen $@ -- ${words[CURRENT]})"} ) - - if [[ -n $matches ]]; then - if [[ ${argv[${argv[(I)filenames]:-0}-1]} = -o ]]; then - compset -P '*/' && matches=( ${matches##*/} ) - compset -S '/*' && matches=( ${matches%%/*} ) - compadd -Q -f "${suf[@]}" -a matches && ret=0 - else - compadd -Q "${suf[@]}" -a matches && ret=0 - fi - fi - - if (( ret )); then - if [[ ${argv[${argv[(I)default]:-0}-1]} = -o ]]; then - _default "${suf[@]}" && ret=0 - elif [[ ${argv[${argv[(I)dirnames]:-0}-1]} = -o ]]; then - _directories "${suf[@]}" && ret=0 - fi - fi - - return ret -} - -complete -C aws_completer aws diff --git a/cloudreg_env/bin/chardetect b/cloudreg_env/bin/chardetect deleted file mode 100755 index bbcb569..0000000 --- a/cloudreg_env/bin/chardetect +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from chardet.cli.chardetect import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/cloudfiles b/cloudreg_env/bin/cloudfiles deleted file mode 100755 index 89a6b17..0000000 --- a/cloudreg_env/bin/cloudfiles +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from cloudfiles_cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/draco_decoder b/cloudreg_env/bin/draco_decoder deleted file mode 100755 index eebe0e1..0000000 Binary files a/cloudreg_env/bin/draco_decoder and /dev/null differ diff --git a/cloudreg_env/bin/draco_encoder b/cloudreg_env/bin/draco_encoder deleted file mode 100755 index f02711a..0000000 Binary files a/cloudreg_env/bin/draco_encoder and /dev/null differ diff --git a/cloudreg_env/bin/easy_install b/cloudreg_env/bin/easy_install deleted file mode 100755 index d02a1e0..0000000 --- a/cloudreg_env/bin/easy_install +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from setuptools.command.easy_install import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/easy_install-3.8 b/cloudreg_env/bin/easy_install-3.8 deleted file mode 100755 index d02a1e0..0000000 --- a/cloudreg_env/bin/easy_install-3.8 +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from setuptools.command.easy_install import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/f2py b/cloudreg_env/bin/f2py deleted file mode 100755 index c21ff3d..0000000 --- a/cloudreg_env/bin/f2py +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from numpy.f2py.f2py2e import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/f2py3 b/cloudreg_env/bin/f2py3 deleted file mode 100755 index c21ff3d..0000000 --- a/cloudreg_env/bin/f2py3 +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from numpy.f2py.f2py2e import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/f2py3.8 b/cloudreg_env/bin/f2py3.8 deleted file mode 100755 index c21ff3d..0000000 --- a/cloudreg_env/bin/f2py3.8 +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from numpy.f2py.f2py2e import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/get_objgraph b/cloudreg_env/bin/get_objgraph deleted file mode 100755 index 525f725..0000000 --- a/cloudreg_env/bin/get_objgraph +++ /dev/null @@ -1,54 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) -# Copyright (c) 2008-2016 California Institute of Technology. -# Copyright (c) 2016-2020 The Uncertainty Quantification Foundation. -# License: 3-clause BSD. The full license text is available at: -# - https://github.com/uqfoundation/dill/blob/master/LICENSE -""" -display the reference paths for objects in ``dill.types`` or a .pkl file - -Notes: - the generated image is useful in showing the pointer references in - objects that are or can be pickled. Any object in ``dill.objects`` - listed in ``dill.load_types(picklable=True, unpicklable=True)`` works. - -Examples:: - - $ get_objgraph FrameType - Image generated as FrameType.png -""" - -import dill as pickle -#pickle.debug.trace(True) -#import pickle - -# get all objects for testing -from dill import load_types -load_types(pickleable=True,unpickleable=True) -from dill import objects - -if __name__ == "__main__": - import sys - if len(sys.argv) != 2: - print ("Please provide exactly one file or type name (e.g. 'IntType')") - msg = "\n" - for objtype in list(objects.keys())[:40]: - msg += objtype + ', ' - print (msg + "...") - else: - objtype = str(sys.argv[-1]) - try: - obj = objects[objtype] - except KeyError: - obj = pickle.load(open(objtype,'rb')) - import os - objtype = os.path.splitext(objtype)[0] - try: - import objgraph - objgraph.show_refs(obj, filename=objtype+'.png') - except ImportError: - print ("Please install 'objgraph' to view object graphs") - - -# EOF diff --git a/cloudreg_env/bin/imagecodecs b/cloudreg_env/bin/imagecodecs deleted file mode 100755 index cddec6b..0000000 --- a/cloudreg_env/bin/imagecodecs +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from imagecodecs.__main__ import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/jp.py b/cloudreg_env/bin/jp.py deleted file mode 100755 index 518295c..0000000 --- a/cloudreg_env/bin/jp.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -import sys -import json -import argparse -from pprint import pformat - -import jmespath -from jmespath import exceptions - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument('expression') - parser.add_argument('-f', '--filename', - help=('The filename containing the input data. ' - 'If a filename is not given then data is ' - 'read from stdin.')) - parser.add_argument('--ast', action='store_true', - help=('Pretty print the AST, do not search the data.')) - args = parser.parse_args() - expression = args.expression - if args.ast: - # Only print the AST - expression = jmespath.compile(args.expression) - sys.stdout.write(pformat(expression.parsed)) - sys.stdout.write('\n') - return 0 - if args.filename: - with open(args.filename, 'r') as f: - data = json.load(f) - else: - data = sys.stdin.read() - data = json.loads(data) - try: - sys.stdout.write(json.dumps( - jmespath.search(expression, data), indent=4, ensure_ascii=False)) - sys.stdout.write('\n') - except exceptions.ArityError as e: - sys.stderr.write("invalid-arity: %s\n" % e) - return 1 - except exceptions.JMESPathTypeError as e: - sys.stderr.write("invalid-type: %s\n" % e) - return 1 - except exceptions.UnknownFunctionError as e: - sys.stderr.write("unknown-function: %s\n" % e) - return 1 - except exceptions.ParseError as e: - sys.stderr.write("syntax-error: %s\n" % e) - return 1 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/cloudreg_env/bin/jsonschema b/cloudreg_env/bin/jsonschema deleted file mode 100755 index 9c38dac..0000000 --- a/cloudreg_env/bin/jsonschema +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from jsonschema.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/lsm2bin b/cloudreg_env/bin/lsm2bin deleted file mode 100755 index 3ba38b8..0000000 --- a/cloudreg_env/bin/lsm2bin +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from tifffile.lsm2bin import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/markdown_py b/cloudreg_env/bin/markdown_py deleted file mode 100755 index c13b78e..0000000 --- a/cloudreg_env/bin/markdown_py +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from markdown.__main__ import run -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(run()) diff --git a/cloudreg_env/bin/pathos_connect b/cloudreg_env/bin/pathos_connect deleted file mode 100755 index 31fc28c..0000000 --- a/cloudreg_env/bin/pathos_connect +++ /dev/null @@ -1,184 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) -# Copyright (c) 1997-2016 California Institute of Technology. -# Copyright (c) 2016-2020 The Uncertainty Quantification Foundation. -# License: 3-clause BSD. The full license text is available at: -# - https://github.com/uqfoundation/pathos/blob/master/LICENSE -""" -connect to the specified machine and start a 'server', 'tunnel', or both - -Notes: - Usage: pathos_connect [hostname] [server] [remoteport] [profile] - [hostname] - name of the host to connect to - [server] - name of RPC server (assumes is installed on host) or 'tunnel' - [remoteport] - remote port to use for communication or 'tunnel' - [profile] -- name of shell profile to source on remote environment - -Examples:: - - $ pathos_connect computer.college.edu ppserver tunnel - Usage: pathos_connect [hostname] [server] [remoteport] [profile] - [hostname] - name of the host to connect to - [server] - name of RPC server (assumes is installed on host) or 'tunnel' - [remoteport] - remote port to use for communication or 'tunnel' - [profile] -- name of shell profile to source on remote environment - defaults are: "localhost" "tunnel" "" "" - executing {ssh -N -L 22921:computer.college.edu:15058}' - - Server running at port=15058 with pid=4110 - Connected to localhost at port=22921 - Press to kill server -""" -## tunnel: pathos_connect college.edu tunnel -## server: pathos_connect college.edu ppserver 12345 .profile -## both: pathos_connect college.edu ppserver tunnel .profile - -from pathos.core import * -from pathos.hosts import get_profile, register_profiles - - -if __name__ == '__main__': - -##### CONFIGURATION & INPUT ######################## - # set the default remote host - rhost = 'localhost' - #rhost = 'foobar.internet.org' - #rhost = 'computer.college.edu' - - # set any 'special' profiles (those which don't use default_profie) - profiles = {} - #profiles = {'foobar.internet.org':'.profile', - # 'computer.college.edu':'.cshrc'} - - # set the default port - rport = '' - _rport = '98909' - - # set the default server command - server = 'tunnel' - #server = 'ppserver' #XXX: "ppserver -p %s" % rport - #server = 'classic_server' #XXX: "classic_server -p %s" % rport - #server = 'registry_server' #XXX: "registry_server -p %s" % rport - - print("""Usage: pathos_connect [hostname] [remoteport] [server] [profile] - Usage: pathos_connect [hostname] [server] [remoteport] [profile] - [hostname] - name of the host to connect to - [server] - name of RPC server (assumes is installed on host) or 'tunnel' - [remoteport] - remote port to use for communication or 'tunnel' - [profile] -- name of shell profile to source on remote environment - defaults are: "%s" "%s" "%s" "%s".""" % (rhost, server, rport, '')) - - # get remote hostname from user - import sys - if '--help' in sys.argv: - sys.exit(0) - try: - myinp = sys.argv[1] - except: myinp = None - if myinp: - rhost = myinp #XXX: should test rhost validity here... (how ?) - else: pass # use default - del myinp - - # get server to run from user - try: - myinp = sys.argv[2] - except: myinp = None - if myinp: - server = myinp #XXX: should test validity here... (filename) - else: pass # use default - del myinp - - # set the default 'port' - if server == 'tunnel': - tunnel = True - server = None - else: - tunnel = False - rport = rport if tunnel else _rport - - # get remote port to run server on from user - try: - myinp = sys.argv[3] - except: myinp = None - if myinp: - if tunnel: # tunnel doesn't take more inputs - msg = "port '%s' not valid for 'tunnel'" % myinp - raise ValueError(msg) - rport = myinp #XXX: should test validity here... (filename) - else: pass # use default - del myinp - - # is it a tunneled server? - tunnel = True if (tunnel or rport == 'tunnel') else False - rport = '' if rport == 'tunnel' else rport - - # get remote profile (this should go away soon) - try: - myinp = sys.argv[4] - except: myinp = None - if myinp: - rprof = myinp #XXX: should test validity here... (filename) - profiles = {rhost:rprof} - else: pass # use default - del myinp - - # my remote environment (should be auto-detected) - register_profiles(profiles) - profile = get_profile(rhost) - -##### CONFIGURATION & INPUT ######################## -## tunnel: pathos_connect foo.college.edu tunnel -## server: pathos_connect foo.college.edu ppserver 12345 .profile -## both: pathos_connect foo.college.edu ppserver tunnel .profile - - if tunnel: - # establish ssh tunnel - tunnel = connect(rhost) - lport = tunnel._lport - rport = tunnel._rport - print('executing {ssh -N -L %d:%s:%d}' % (lport, rhost, rport)) - else: - lport = '' - - if server: - # run server - rserver = serve(server, rhost, rport, profile=profile) - response = rserver.response() - if response: - if tunnel: tunnel.disconnect() - print(response) - raise OSError('Failure to start server') - - # get server pid #FIXME: launcher.pid is not pid(server) - target = '[P,p]ython[^#]*'+server # filter w/ regex for python-based server - try: - pid = getpid(target, rhost) - except OSError: - print("Cleanup on host may be required...") - if tunnel: tunnel.disconnect() - raise - - # test server - # XXX: add a simple one-liner... - print("\nServer running at port=%s with pid=%s" % (rport, pid)) - if tunnel: print("Connected to localhost at port=%s" % (lport)) - print('Press to kill server') - else: - print('Press to disconnect') - sys.stdin.readline() - - if server: - # stop server - print(kill(pid,rhost)) -# del rserver #XXX: delete should run self.kill (?) - - if tunnel: - # disconnect tunnel - tunnel.disconnect() - # FIXME: just kills 'ssh', not the tunnel - # get local pid: ps u | grep "ssh -N -L%s:%s$s" % (lport,rhost,rport) - # kill -15 int(tunnelpid) - -# EOF diff --git a/cloudreg_env/bin/pip b/cloudreg_env/bin/pip deleted file mode 100755 index 635660a..0000000 --- a/cloudreg_env/bin/pip +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/pip3 b/cloudreg_env/bin/pip3 deleted file mode 100755 index 635660a..0000000 --- a/cloudreg_env/bin/pip3 +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/pip3.8 b/cloudreg_env/bin/pip3.8 deleted file mode 100755 index 635660a..0000000 --- a/cloudreg_env/bin/pip3.8 +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from pip._internal.cli.main import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/portpicker b/cloudreg_env/bin/portpicker deleted file mode 100755 index 4640cdb..0000000 --- a/cloudreg_env/bin/portpicker +++ /dev/null @@ -1,15 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) -# Copyright (c) 2018-2020 The Uncertainty Quantification Foundation. -# License: 3-clause BSD. The full license text is available at: -# - https://github.com/uqfoundation/pathos/blob/master/LICENSE - -from pathos.portpicker import portnumber, __doc__ - - -if __name__ == '__main__': - - pick = portnumber(min=1024,max=65535) - print( pick() ) - diff --git a/cloudreg_env/bin/pox b/cloudreg_env/bin/pox deleted file mode 100755 index 7dbf04d..0000000 --- a/cloudreg_env/bin/pox +++ /dev/null @@ -1,27 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) -# Copyright (c) 2018-2020 The Uncertainty Quantification Foundation. -# License: 3-clause BSD. The full license text is available at: -# - https://github.com/uqfoundation/pox/blob/master/LICENSE - -import pox.__main__ -from pox.__main__ import * -__doc__ = pox.__main__.__doc__ - - -if __name__=='__main__': - import sys - try: - func = sys.argv[1] - except: func = None - if func: - try: - exec('print(%s)' % func) - except: - print("Error: incorrect syntax '%s'\n" % func) - exec('print(%s.__doc__)' % func.split('(')[0]) - else: help() - - -# End of file diff --git a/cloudreg_env/bin/ppserver b/cloudreg_env/bin/ppserver deleted file mode 100755 index 6dec563..0000000 --- a/cloudreg_env/bin/ppserver +++ /dev/null @@ -1,425 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# Parallel Python Software: http://www.parallelpython.com -# Copyright (c) 2005-2012 Vitalii Vanovschi. -# Copyright (c) 2015-2016 California Institute of Technology. -# Copyright (c) 2016-2020 The Uncertainty Quantification Foundation. -# 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 the author 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. -""" -Parallel Python Software, Network Server - -http://www.parallelpython.com - updates, documentation, examples and support -forums -""" -from __future__ import with_statement - -import atexit -import logging -import errno -import getopt -import sys -import socket -import threading -import random -import string -import signal -import time -import os -import six - -import pp -import pp.auto as ppauto -import pp.common as ppc -import pp.transport as pptransport - -copyright = """Copyright (c) 2005-2012 Vitalii Vanovschi. -Copyright (c) 2015-2016 California Institute of Technology. -Copyright (c) 2016-2020 The Uncertainty Quantification Foundation.""" -__version__ = version = "1.6.6.3" - -LISTEN_SOCKET_TIMEOUT = 20 - -# compatibility with Jython -STAT_SIGNAL = 'SIGUSR1' if 'java' not in sys.platform else 'SIGUSR2' - -# compatibility with Python 2.6 -try: - import hashlib - sha_new = hashlib.sha1 -except ImportError: - import sha - sha_new = sha.new - - -class _NetworkServer(pp.Server): - """Network Server Class - """ - - def __init__(self, ncpus="autodetect", interface="0.0.0.0", - broadcast="255.255.255.255", port=None, secret=None, - timeout=None, restart=False, proto=2, socket_timeout=3600, pid_file=None): - pp.Server.__init__(self, ncpus, (), secret, restart, - proto, socket_timeout) - if pid_file: - with open(pid_file, 'w') as pfile: - six.print_(os.getpid(), file=pfile) - atexit.register(os.remove, pid_file) - self.host = interface - self.bcast = broadcast - if port is not None: - self.port = port - else: - self.port = ppc.randomport() - self.timeout = timeout - self.ncon = 0 - self.last_con_time = time.time() - self.ncon_lock = threading.Lock() - - self.logger.debug("Strarting network server interface=%s port=%i" - % (self.host, self.port)) - if self.timeout is not None: - self.logger.debug("ppserver will exit in %i seconds if no "\ - "connections with clients exist" % (self.timeout)) - ppc.start_thread("timeout_check", self.check_timeout) - - def ncon_add(self, val): - """Keeps track of the number of connections and time of the last one""" - self.ncon_lock.acquire() - self.ncon += val - self.last_con_time = time.time() - self.ncon_lock.release() - - def check_timeout(self): - """Checks if timeout happened and shutdowns server if it did""" - while True: - if self.ncon == 0: - idle_time = time.time() - self.last_con_time - if idle_time < self.timeout: - time.sleep(self.timeout - idle_time) - else: - self.logger.debug("exiting ppserver due to timeout (no client"\ - " connections in last %i sec)", self.timeout) - os._exit(0) - else: - time.sleep(self.timeout) - - def listen(self): - """Initiates listenting to incoming connections""" - try: - self.ssocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - # following allows ppserver to restart faster on the same port - self.ssocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.ssocket.settimeout(LISTEN_SOCKET_TIMEOUT) - self.ssocket.bind((self.host, self.port)) - self.ssocket.listen(5) - except socket.error: - e = sys.exc_info()[1] - self.logger.error("Cannot create socket for %s:%s, %s", self.host, self.port, e) - - try: - while 1: - csocket = None - # accept connections from outside - try: - (csocket, address) = self.ssocket.accept() - except socket.timeout: - pass - # don't exit on an interupt due to a signal - except socket.error: - e = sys.exc_info()[1] - if e.errno == errno.EINTR: - pass - if self._exiting: - return - # now do something with the clientsocket - # in this case, we'll pretend this is a threaded server - if csocket: - ppc.start_thread("client_socket", self.crun, (csocket, )) - except KeyboardInterrupt: - pass - except: - self.logger.debug("Exception in listen method (possibly expected)", exc_info=True) - finally: - self.logger.debug("Closing server socket") - self.ssocket.close() - - def crun(self, csocket): - """Authenticates client and handles its jobs""" - mysocket = pptransport.CSocketTransport(csocket, self.socket_timeout) - #send PP version - mysocket.send(version) - #generate a random string - srandom = "".join([random.choice(string.ascii_letters) - for i in range(16)]) - mysocket.send(srandom) - answer = sha_new(ppc.b_(srandom+self.secret)).hexdigest() - clientanswer = ppc.str_(mysocket.receive()) - if answer != clientanswer: - self.logger.warning("Authentication failed, client host=%s, port=%i" - % csocket.getpeername()) - mysocket.send("FAILED") - csocket.close() - return - else: - mysocket.send("OK") - - ctype = ppc.str_(mysocket.receive()) - self.logger.debug("Control message received: " + ctype) - self.ncon_add(1) - try: - if ctype == "STAT": - #reset time at each new connection - self.get_stats()["local"].time = 0.0 - #open('/tmp/pp.debug', 'a+').write('STAT: \n') - mysocket.send(str(self.get_ncpus())) - #open('/tmp/pp.debug', 'a+').write('STAT: get_ncpus\n') - while 1: - mysocket.receive() - #open('/tmp/pp.debug', 'a+').write('STAT: recvd\n') - mysocket.send(str(self.get_stats()["local"].time)) - #open('/tmp/pp.debug', 'a+').write('STAT: _\n') - elif ctype=="EXEC": - while 1: - #open('/tmp/pp.debug', 'a+').write('EXEC: \n') - sfunc = mysocket.creceive() - #open('/tmp/pp.debug', 'a+').write('EXEC: '+repr((sfunc,))+'\n') - sargs = mysocket.receive() - #open('/tmp/pp.debug', 'a+').write('EXEC: '+repr((sargs,))+'\n') - fun = self.insert(sfunc, sargs) - sresult = fun(True) - #open('/tmp/pp.debug', 'a+').write('EXEC: '+repr((sresult,))+'\n') - mysocket.send(sresult) - #open('/tmp/pp.debug', 'a+').write('EXEC: _\n') - except: - if self._exiting: - return - if pp.SHOW_EXPECTED_EXCEPTIONS: - self.logger.debug("Exception in crun method (possibly expected)", exc_info=True) - self.logger.debug("Closing client socket") - csocket.close() - self.ncon_add(-1) - - def broadcast(self): - """Initiaates auto-discovery mechanism""" - discover = ppauto.Discover(self) - ppc.start_thread("server_broadcast", discover.run, - ((self.host, self.port), (self.bcast, self.port))) - - -def parse_config(file_loc): - """ - Parses a config file in a very forgiving way. - """ - # If we don't have configobj installed then let the user know and exit - try: - from configobj import ConfigObj - except ImportError: - ie = sys.exc_info()[1] - #sysstderr = getattr(sys.stderr, 'buffer', sys.stderr) - six.print_(("ERROR: You must have config obj installed to use" - "configuration files. You can still use command line switches."), file=sys.stderr) - sys.exit(1) - - if not os.access(file_loc, os.F_OK): - six.print_("ERROR: Can not access %s." % arg, file=sys.stderr) - sys.exit(1) - - # Load the configuration file - config = ConfigObj(file_loc) - # try each config item and use the result if it exists. If it doesn't - # then simply pass and move along - try: - args['secret'] = config['general'].get('secret') - except: - pass - - try: - autodiscovery = config['network'].as_bool('autodiscovery') - except: - pass - - try: - args['interface'] = config['network'].get('interface', - default="0.0.0.0") - except: - pass - - try: - args['broadcast'] = config['network'].get('broadcast') - except: - pass - - try: - args['port'] = config['network'].as_int('port') - except: - pass - - try: - args['loglevel'] = config['general'].as_bool('debug') - except: - pass - - try: - args['ncpus'] = config['general'].as_int('workers') - except: - pass - - try: - args['proto'] = config['general'].as_int('proto') - except: - pass - - try: - args['restart'] = config['general'].as_bool('restart') - except: - pass - - try: - args['timeout'] = config['network'].as_int('timeout') - except: - pass - - try: - args['socket_timeout'] = config['network'].as_int('socket_timeout') - except: - pass - - try: - args['pid_file'] = config['general'].get('pid_file') - except: - pass - # Return a tuple of the args dict and autodiscovery variable - return args, autodiscovery - - -def print_usage(): - """Prints help""" - print("Parallel Python Network Server (pp-" + version + ")") - print("Usage: ppserver [-hdar] [-f format] [-n proto]"\ - " [-c config_path] [-i interface] [-b broadcast]"\ - " [-p port] [-w nworkers] [-s secret] [-t seconds]"\ - " [-k seconds] [-P pid_file]") - print("") - print("Options: ") - print("-h : this help message") - print("-d : set log level to debug") - print("-f format : log format") - print("-a : enable auto-discovery service") - print("-r : restart worker process after each"\ - " task completion") - print("-n proto : protocol number for pickle module") - print("-c path : path to config file") - print("-i interface : interface to listen") - print("-b broadcast : broadcast address for auto-discovery service") - print("-p port : port to listen") - print("-w nworkers : number of workers to start") - print("-s secret : secret for authentication") - print("-t seconds : timeout to exit if no connections with "\ - "clients exist") - print("-k seconds : socket timeout in seconds") - print("-P pid_file : file to write PID to") - print("") - print("To print server stats send %s to its main process (unix only). " % STAT_SIGNAL) - print("") - print("Due to the security concerns always use a non-trivial secret key.") - print("Secret key set by -s switch will override secret key assigned by") - print("pp_secret variable in .pythonrc.py") - print("") - print("Please visit http://www.parallelpython.com for extended up-to-date") - print("documentation, examples and support forums") - - -def create_network_server(argv): - try: - opts, args = getopt.getopt(argv, "hdarn:c:b:i:p:w:s:t:f:k:P:", ["help"]) - except getopt.GetoptError: - print_usage() - raise - - args = {} - autodiscovery = False - - log_level = logging.WARNING - log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" - - for opt, arg in opts: - if opt in ("-h", "--help"): - print_usage() - sys.exit() - elif opt == "-c": - args, autodiscovery = parse_config(arg) - elif opt == "-d": - log_level = logging.DEBUG - pp.SHOW_EXPECTED_EXCEPTIONS = True - elif opt == "-f": - log_format = arg - elif opt == "-i": - args["interface"] = arg - elif opt == "-s": - args["secret"] = arg - elif opt == "-p": - args["port"] = int(arg) - elif opt == "-w": - args["ncpus"] = int(arg) - elif opt == "-a": - autodiscovery = True - elif opt == "-r": - args["restart"] = True - elif opt == "-b": - args["broadcast"] = arg - elif opt == "-n": - args["proto"] = int(arg) - elif opt == "-t": - args["timeout"] = int(arg) - elif opt == "-k": - args["socket_timeout"] = int(arg) - elif opt == "-P": - args["pid_file"] = arg - - log_handler = logging.StreamHandler() - log_handler.setFormatter(logging.Formatter(log_format)) - logging.getLogger("pp").setLevel(log_level) - logging.getLogger("pp").addHandler(log_handler) - - server = _NetworkServer(**args) - if autodiscovery: - server.broadcast() - return server - -def signal_handler(signum, stack): - """Prints server stats when %s is received (unix only). """ % STAT_SIGNAL - server.print_stats() - -if __name__ == "__main__": - server = create_network_server(sys.argv[1:]) - statsignal = getattr(signal, STAT_SIGNAL, None) - if statsignal: - signal.signal(statsignal, signal_handler) - server.listen() - #have to destroy it here explicitly otherwise an exception - #comes out in Python 2.4 - del server - - -# Parallel Python Software: http://www.parallelpython.com diff --git a/cloudreg_env/bin/py.test b/cloudreg_env/bin/py.test deleted file mode 100755 index eff4a56..0000000 --- a/cloudreg_env/bin/py.test +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from pytest import console_main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(console_main()) diff --git a/cloudreg_env/bin/pyjson5 b/cloudreg_env/bin/pyjson5 deleted file mode 100755 index 078dfd8..0000000 --- a/cloudreg_env/bin/pyjson5 +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from json5.tool import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/pyrsa-decrypt b/cloudreg_env/bin/pyrsa-decrypt deleted file mode 100755 index f515894..0000000 --- a/cloudreg_env/bin/pyrsa-decrypt +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import decrypt -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(decrypt()) diff --git a/cloudreg_env/bin/pyrsa-encrypt b/cloudreg_env/bin/pyrsa-encrypt deleted file mode 100755 index 9412d5f..0000000 --- a/cloudreg_env/bin/pyrsa-encrypt +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import encrypt -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(encrypt()) diff --git a/cloudreg_env/bin/pyrsa-keygen b/cloudreg_env/bin/pyrsa-keygen deleted file mode 100755 index 4f1c686..0000000 --- a/cloudreg_env/bin/pyrsa-keygen +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import keygen -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(keygen()) diff --git a/cloudreg_env/bin/pyrsa-priv2pub b/cloudreg_env/bin/pyrsa-priv2pub deleted file mode 100755 index d8321da..0000000 --- a/cloudreg_env/bin/pyrsa-priv2pub +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.util import private_to_public -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(private_to_public()) diff --git a/cloudreg_env/bin/pyrsa-sign b/cloudreg_env/bin/pyrsa-sign deleted file mode 100755 index 3a9b4e6..0000000 --- a/cloudreg_env/bin/pyrsa-sign +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import sign -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(sign()) diff --git a/cloudreg_env/bin/pyrsa-verify b/cloudreg_env/bin/pyrsa-verify deleted file mode 100755 index 732e9e1..0000000 --- a/cloudreg_env/bin/pyrsa-verify +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from rsa.cli import verify -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(verify()) diff --git a/cloudreg_env/bin/pytest b/cloudreg_env/bin/pytest deleted file mode 100755 index eff4a56..0000000 --- a/cloudreg_env/bin/pytest +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from pytest import console_main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(console_main()) diff --git a/cloudreg_env/bin/python b/cloudreg_env/bin/python deleted file mode 120000 index 4e58b60..0000000 --- a/cloudreg_env/bin/python +++ /dev/null @@ -1 +0,0 @@ -python3.8 \ No newline at end of file diff --git a/cloudreg_env/bin/python-config b/cloudreg_env/bin/python-config deleted file mode 100755 index 5442697..0000000 --- a/cloudreg_env/bin/python-config +++ /dev/null @@ -1,78 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python - -import sys -import getopt -import sysconfig - -valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', - 'ldflags', 'help'] - -if sys.version_info >= (3, 2): - valid_opts.insert(-1, 'extension-suffix') - valid_opts.append('abiflags') -if sys.version_info >= (3, 3): - valid_opts.append('configdir') - - -def exit_with_usage(code=1): - sys.stderr.write("Usage: {0} [{1}]\n".format( - sys.argv[0], '|'.join('--'+opt for opt in valid_opts))) - sys.exit(code) - -try: - opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) -except getopt.error: - exit_with_usage() - -if not opts: - exit_with_usage() - -pyver = sysconfig.get_config_var('VERSION') -getvar = sysconfig.get_config_var - -opt_flags = [flag for (flag, val) in opts] - -if '--help' in opt_flags: - exit_with_usage(code=0) - -for opt in opt_flags: - if opt == '--prefix': - print(sysconfig.get_config_var('prefix')) - - elif opt == '--exec-prefix': - print(sysconfig.get_config_var('exec_prefix')) - - elif opt in ('--includes', '--cflags'): - flags = ['-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude')] - if opt == '--cflags': - flags.extend(getvar('CFLAGS').split()) - print(' '.join(flags)) - - elif opt in ('--libs', '--ldflags'): - abiflags = getattr(sys, 'abiflags', '') - libs = ['-lpython' + pyver + abiflags] - libs += getvar('LIBS').split() - libs += getvar('SYSLIBS').split() - # add the prefix/lib/pythonX.Y/config dir, but only if there is no - # shared library in prefix/lib/. - if opt == '--ldflags': - if not getvar('Py_ENABLE_SHARED'): - libs.insert(0, '-L' + getvar('LIBPL')) - if not getvar('PYTHONFRAMEWORK'): - libs.extend(getvar('LINKFORSHARED').split()) - print(' '.join(libs)) - - elif opt == '--extension-suffix': - ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') - if ext_suffix is None: - ext_suffix = sysconfig.get_config_var('SO') - print(ext_suffix) - - elif opt == '--abiflags': - if not getattr(sys, 'abiflags', None): - exit_with_usage() - print(sys.abiflags) - - elif opt == '--configdir': - print(sysconfig.get_config_var('LIBPL')) diff --git a/cloudreg_env/bin/python3 b/cloudreg_env/bin/python3 deleted file mode 120000 index 4e58b60..0000000 --- a/cloudreg_env/bin/python3 +++ /dev/null @@ -1 +0,0 @@ -python3.8 \ No newline at end of file diff --git a/cloudreg_env/bin/python3.8 b/cloudreg_env/bin/python3.8 deleted file mode 100755 index 1da441f..0000000 Binary files a/cloudreg_env/bin/python3.8 and /dev/null differ diff --git a/cloudreg_env/bin/rst2html.py b/cloudreg_env/bin/rst2html.py deleted file mode 100755 index a60665a..0000000 --- a/cloudreg_env/bin/rst2html.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing HTML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates (X)HTML documents from standalone reStructuredText ' - 'sources. ' + default_description) - -publish_cmdline(writer_name='html', description=description) diff --git a/cloudreg_env/bin/rst2html4.py b/cloudreg_env/bin/rst2html4.py deleted file mode 100755 index dcd235d..0000000 --- a/cloudreg_env/bin/rst2html4.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2html4.py 7994 2016-12-10 17:41:45Z milde $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing (X)HTML. - -The output conforms to XHTML 1.0 transitional -and almost to HTML 4.01 transitional (except for closing empty tags). -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates (X)HTML documents from standalone reStructuredText ' - 'sources. ' + default_description) - -publish_cmdline(writer_name='html4', description=description) diff --git a/cloudreg_env/bin/rst2html5.py b/cloudreg_env/bin/rst2html5.py deleted file mode 100755 index c869485..0000000 --- a/cloudreg_env/bin/rst2html5.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf8 -*- -# :Copyright: © 2015 Günter Milde. -# :License: Released under the terms of the `2-Clause BSD license`_, in short: -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. -# This file is offered as-is, without any warranty. -# -# .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause -# -# Revision: $Revision: 8410 $ -# Date: $Date: 2019-11-04 22:14:43 +0100 (Mo, 04. Nov 2019) $ - -""" -A minimal front end to the Docutils Publisher, producing HTML 5 documents. - -The output also conforms to XHTML 1.0 transitional -(except for the doctype declaration). -""" - -try: - import locale # module missing in Jython - locale.setlocale(locale.LC_ALL, '') -except locale.Error: - pass - -from docutils.core import publish_cmdline, default_description - -description = (u'Generates HTML 5 documents from standalone ' - u'reStructuredText sources ' - + default_description) - -publish_cmdline(writer_name='html5', description=description) diff --git a/cloudreg_env/bin/rst2latex.py b/cloudreg_env/bin/rst2latex.py deleted file mode 100755 index afb325a..0000000 --- a/cloudreg_env/bin/rst2latex.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2latex.py 5905 2009-04-16 12:04:49Z milde $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing LaTeX. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline - -description = ('Generates LaTeX documents from standalone reStructuredText ' - 'sources. ' - 'Reads from (default is stdin) and writes to ' - ' (default is stdout). See ' - ' for ' - 'the full reference.') - -publish_cmdline(writer_name='latex', description=description) diff --git a/cloudreg_env/bin/rst2man.py b/cloudreg_env/bin/rst2man.py deleted file mode 100755 index b55e3d2..0000000 --- a/cloudreg_env/bin/rst2man.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# Author: -# Contact: grubert@users.sf.net -# Copyright: This module has been placed in the public domain. - -""" -man.py -====== - -This module provides a simple command line interface that uses the -man page writer to output from ReStructuredText source. -""" - -import locale -try: - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description -from docutils.writers import manpage - -description = ("Generates plain unix manual documents. " + default_description) - -publish_cmdline(writer=manpage.Writer(), description=description) diff --git a/cloudreg_env/bin/rst2odt.py b/cloudreg_env/bin/rst2odt.py deleted file mode 100755 index 48d16ab..0000000 --- a/cloudreg_env/bin/rst2odt.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2odt.py 5839 2009-01-07 19:09:28Z dkuhlman $ -# Author: Dave Kuhlman -# Copyright: This module has been placed in the public domain. - -""" -A front end to the Docutils Publisher, producing OpenOffice documents. -""" - -import sys -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline_to_binary, default_description -from docutils.writers.odf_odt import Writer, Reader - - -description = ('Generates OpenDocument/OpenOffice/ODF documents from ' - 'standalone reStructuredText sources. ' + default_description) - - -writer = Writer() -reader = Reader() -output = publish_cmdline_to_binary(reader=reader, writer=writer, - description=description) - diff --git a/cloudreg_env/bin/rst2odt_prepstyles.py b/cloudreg_env/bin/rst2odt_prepstyles.py deleted file mode 100755 index 07f5558..0000000 --- a/cloudreg_env/bin/rst2odt_prepstyles.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2odt_prepstyles.py 8346 2019-08-26 12:11:32Z milde $ -# Author: Dave Kuhlman -# Copyright: This module has been placed in the public domain. - -""" -Fix a word-processor-generated styles.odt for odtwriter use: Drop page size -specifications from styles.xml in STYLE_FILE.odt. -""" - -# Author: Michael Schutte - -from __future__ import print_function - -from lxml import etree -import sys -import zipfile -from tempfile import mkstemp -import shutil -import os - -NAMESPACES = { - "style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0", - "fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" -} - - -def prepstyle(filename): - - zin = zipfile.ZipFile(filename) - styles = zin.read("styles.xml") - - root = etree.fromstring(styles) - for el in root.xpath("//style:page-layout-properties", - namespaces=NAMESPACES): - for attr in el.attrib: - if attr.startswith("{%s}" % NAMESPACES["fo"]): - del el.attrib[attr] - - tempname = mkstemp() - zout = zipfile.ZipFile(os.fdopen(tempname[0], "w"), "w", - zipfile.ZIP_DEFLATED) - - for item in zin.infolist(): - if item.filename == "styles.xml": - zout.writestr(item, etree.tostring(root)) - else: - zout.writestr(item, zin.read(item.filename)) - - zout.close() - zin.close() - shutil.move(tempname[1], filename) - - -def main(): - args = sys.argv[1:] - if len(args) != 1: - print(__doc__, file=sys.stderr) - print("Usage: %s STYLE_FILE.odt\n" % sys.argv[0], file=sys.stderr) - sys.exit(1) - filename = args[0] - prepstyle(filename) - - -if __name__ == '__main__': - main() diff --git a/cloudreg_env/bin/rst2pseudoxml.py b/cloudreg_env/bin/rst2pseudoxml.py deleted file mode 100755 index b9eed6e..0000000 --- a/cloudreg_env/bin/rst2pseudoxml.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2pseudoxml.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing pseudo-XML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates pseudo-XML from standalone reStructuredText ' - 'sources (for testing purposes). ' + default_description) - -publish_cmdline(description=description) diff --git a/cloudreg_env/bin/rst2s5.py b/cloudreg_env/bin/rst2s5.py deleted file mode 100755 index 86a0833..0000000 --- a/cloudreg_env/bin/rst2s5.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2s5.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: Chris Liechti -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing HTML slides using -the S5 template system. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates S5 (X)HTML slideshow documents from standalone ' - 'reStructuredText sources. ' + default_description) - -publish_cmdline(writer_name='s5', description=description) diff --git a/cloudreg_env/bin/rst2xetex.py b/cloudreg_env/bin/rst2xetex.py deleted file mode 100755 index 922aec5..0000000 --- a/cloudreg_env/bin/rst2xetex.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2xetex.py 7847 2015-03-17 17:30:47Z milde $ -# Author: Guenter Milde -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing Lua/XeLaTeX code. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline - -description = ('Generates LaTeX documents from standalone reStructuredText ' - 'sources for compilation with the Unicode-aware TeX variants ' - 'XeLaTeX or LuaLaTeX. ' - 'Reads from (default is stdin) and writes to ' - ' (default is stdout). See ' - ' for ' - 'the full reference.') - -publish_cmdline(writer_name='xetex', description=description) diff --git a/cloudreg_env/bin/rst2xml.py b/cloudreg_env/bin/rst2xml.py deleted file mode 100755 index 46c7187..0000000 --- a/cloudreg_env/bin/rst2xml.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rst2xml.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing Docutils XML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates Docutils-native XML from standalone ' - 'reStructuredText sources. ' + default_description) - -publish_cmdline(writer_name='xml', description=description) diff --git a/cloudreg_env/bin/rstpep2html.py b/cloudreg_env/bin/rstpep2html.py deleted file mode 100755 index 56ec66c..0000000 --- a/cloudreg_env/bin/rstpep2html.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 - -# $Id: rstpep2html.py 4564 2006-05-21 20:44:42Z wiemann $ -# Author: David Goodger -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing HTML from PEP -(Python Enhancement Proposal) documents. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates (X)HTML from reStructuredText-format PEP files. ' - + default_description) - -publish_cmdline(reader_name='pep', writer_name='pep_html', - description=description) diff --git a/cloudreg_env/bin/tiffcomment b/cloudreg_env/bin/tiffcomment deleted file mode 100755 index 0185bfa..0000000 --- a/cloudreg_env/bin/tiffcomment +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from tifffile.tiffcomment import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/tifffile b/cloudreg_env/bin/tifffile deleted file mode 100755 index b0eefe6..0000000 --- a/cloudreg_env/bin/tifffile +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from tifffile import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/tqdm b/cloudreg_env/bin/tqdm deleted file mode 100755 index 5eb65c7..0000000 --- a/cloudreg_env/bin/tqdm +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from tqdm.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/bin/undill b/cloudreg_env/bin/undill deleted file mode 100755 index c9f0474..0000000 --- a/cloudreg_env/bin/undill +++ /dev/null @@ -1,22 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) -# Copyright (c) 2008-2016 California Institute of Technology. -# Copyright (c) 2016-2020 The Uncertainty Quantification Foundation. -# License: 3-clause BSD. The full license text is available at: -# - https://github.com/uqfoundation/dill/blob/master/LICENSE -""" -unpickle the contents of a pickled object file - -Examples:: - - $ undill hello.pkl - ['hello', 'world'] -""" - -if __name__ == '__main__': - import sys - import dill - for file in sys.argv[1:]: - print (dill.load(open(file,'rb'))) - diff --git a/cloudreg_env/bin/wheel b/cloudreg_env/bin/wheel deleted file mode 100755 index 2490134..0000000 --- a/cloudreg_env/bin/wheel +++ /dev/null @@ -1,8 +0,0 @@ -#!/Users/vikram/CloudReg/cloudreg_env/bin/python3.8 -# -*- coding: utf-8 -*- -import re -import sys -from wheel.cli import main -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/cloudreg_env/include/draco/animation/keyframe_animation.h b/cloudreg_env/include/draco/animation/keyframe_animation.h deleted file mode 100644 index 0e8b111..0000000 --- a/cloudreg_env/include/draco/animation/keyframe_animation.h +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ANIMATION_KEYFRAME_ANIMATION_H_ -#define DRACO_ANIMATION_KEYFRAME_ANIMATION_H_ - -#include - -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -// Class for holding keyframe animation data. It will have two or more -// attributes as a point cloud. The first attribute is always the timestamp -// of the animation. Each KeyframeAnimation could have multiple animations with -// the same number of frames. Each animation will be treated as a point -// attribute. -class KeyframeAnimation : public PointCloud { - public: - // Force time stamp to be float type. - using TimestampType = float; - - KeyframeAnimation(); - - // Animation must have only one timestamp attribute. - // This function must be called before adding any animation data. - // Returns false if timestamp already exists. - bool SetTimestamps(const std::vector ×tamp); - - // Returns an id for the added animation data. This id will be used to - // identify this animation. - // Returns -1 if error, e.g. number of frames is not consistent. - // Type |T| should be consistent with |DataType|, e.g: - // float - DT_FLOAT32, - // int32_t - DT_INT32, ... - template - int32_t AddKeyframes(DataType data_type, uint32_t num_components, - const std::vector &data); - - const PointAttribute *timestamps() const { - return GetAttributeByUniqueId(kTimestampId); - } - const PointAttribute *keyframes(int32_t animation_id) const { - return GetAttributeByUniqueId(animation_id); - } - - // Number of frames should be equal to number points in the point cloud. - void set_num_frames(int32_t num_frames) { set_num_points(num_frames); } - int32_t num_frames() const { return static_cast(num_points()); } - - int32_t num_animations() const { return num_attributes() - 1; } - - private: - // Attribute id of timestamp is fixed to 0. - static constexpr int32_t kTimestampId = 0; -}; - -template -int32_t KeyframeAnimation::AddKeyframes(DataType data_type, - uint32_t num_components, - const std::vector &data) { - // TODO(draco-eng): Verify T is consistent with |data_type|. - if (num_components == 0) - return -1; - // If timestamps is not added yet, then reserve attribute 0 for timestamps. - if (!num_attributes()) { - // Add a temporary attribute with 0 points to fill attribute id 0. - std::unique_ptr temp_att = - std::unique_ptr(new PointAttribute()); - temp_att->Init(GeometryAttribute::GENERIC, nullptr, num_components, - data_type, false, DataTypeLength(data_type), 0); - temp_att->Reset(0); - this->AddAttribute(std::move(temp_att)); - - set_num_frames(data.size() / num_components); - } - - if (data.size() != num_components * num_frames()) - return -1; - - std::unique_ptr keyframe_att = - std::unique_ptr(new PointAttribute()); - keyframe_att->Init(GeometryAttribute::GENERIC, nullptr, num_components, - data_type, false, DataTypeLength(data_type), 0); - keyframe_att->SetIdentityMapping(); - keyframe_att->Reset(num_frames()); - const size_t stride = num_components; - for (PointIndex i(0); i < num_frames(); ++i) { - keyframe_att->SetAttributeValue(keyframe_att->mapped_index(i), - &data[i.value() * stride]); - } - return this->AddAttribute(std::move(keyframe_att)); -} - -} // namespace draco - -#endif // DRACO_ANIMATION_KEYFRAME_ANIMATION_H_ diff --git a/cloudreg_env/include/draco/animation/keyframe_animation_decoder.h b/cloudreg_env/include/draco/animation/keyframe_animation_decoder.h deleted file mode 100644 index fdf086b..0000000 --- a/cloudreg_env/include/draco/animation/keyframe_animation_decoder.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ANIMATION_KEYFRAME_ANIMATION_DECODER_H_ -#define DRACO_ANIMATION_KEYFRAME_ANIMATION_DECODER_H_ - -#include "draco/animation/keyframe_animation.h" -#include "draco/compression/point_cloud/point_cloud_sequential_decoder.h" - -namespace draco { - -// Class for decoding keyframe animation. -class KeyframeAnimationDecoder : private PointCloudSequentialDecoder { - public: - KeyframeAnimationDecoder(){}; - - Status Decode(const DecoderOptions &options, DecoderBuffer *in_buffer, - KeyframeAnimation *animation); -}; - -} // namespace draco - -#endif // DRACO_ANIMATION_KEYFRAME_ANIMATION_DECODER_H_ diff --git a/cloudreg_env/include/draco/animation/keyframe_animation_encoder.h b/cloudreg_env/include/draco/animation/keyframe_animation_encoder.h deleted file mode 100644 index 6096c79..0000000 --- a/cloudreg_env/include/draco/animation/keyframe_animation_encoder.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ANIMATION_KEYFRAME_ANIMATION_ENCODER_H_ -#define DRACO_ANIMATION_KEYFRAME_ANIMATION_ENCODER_H_ - -#include "draco/animation/keyframe_animation.h" -#include "draco/compression/point_cloud/point_cloud_sequential_encoder.h" - -namespace draco { - -// Class for encoding keyframe animation. It takes KeyframeAnimation as a -// PointCloud and compress it. It's mostly a wrapper around PointCloudEncoder so -// that the animation module could be separated from geometry compression when -// exposed to developers. -class KeyframeAnimationEncoder : private PointCloudSequentialEncoder { - public: - KeyframeAnimationEncoder(); - - // Encode an animation to a buffer. - Status EncodeKeyframeAnimation(const KeyframeAnimation &animation, - const EncoderOptions &options, - EncoderBuffer *out_buffer); -}; - -} // namespace draco - -#endif // DRACO_ANIMATION_KEYFRAME_ANIMATION_ENCODER_H_ diff --git a/cloudreg_env/include/draco/attributes/attribute_octahedron_transform.h b/cloudreg_env/include/draco/attributes/attribute_octahedron_transform.h deleted file mode 100644 index 6e4e742..0000000 --- a/cloudreg_env/include/draco/attributes/attribute_octahedron_transform.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef DRACO_ATTRIBUTES_ATTRIBUTE_OCTAHEDRON_TRANSFORM_H_ -#define DRACO_ATTRIBUTES_ATTRIBUTE_OCTAHEDRON_TRANSFORM_H_ - -#include "draco/attributes/attribute_transform.h" -#include "draco/attributes/point_attribute.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// Attribute transform for attributes transformed to octahedral coordinates. -class AttributeOctahedronTransform : public AttributeTransform { - public: - AttributeOctahedronTransform() : quantization_bits_(-1) {} - - // Return attribute transform type. - AttributeTransformType Type() const override { - return ATTRIBUTE_OCTAHEDRON_TRANSFORM; - } - // Try to init transform from attribute. - bool InitFromAttribute(const PointAttribute &attribute) override; - // Copy parameter values into the provided AttributeTransformData instance. - void CopyToAttributeTransformData( - AttributeTransformData *out_data) const override; - - // Set number of quantization bits. - void SetParameters(int quantization_bits); - - // Encode relevant parameters into buffer. - bool EncodeParameters(EncoderBuffer *encoder_buffer) const; - - bool is_initialized() const { return quantization_bits_ != -1; } - int32_t quantization_bits() const { return quantization_bits_; } - - // Create portable attribute. - std::unique_ptr GeneratePortableAttribute( - const PointAttribute &attribute, const std::vector &point_ids, - int num_points) const; - - private: - int32_t quantization_bits_; -}; - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_ATTRIBUTE_OCTAHEDRON_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/attributes/attribute_quantization_transform.h b/cloudreg_env/include/draco/attributes/attribute_quantization_transform.h deleted file mode 100644 index 934856f..0000000 --- a/cloudreg_env/include/draco/attributes/attribute_quantization_transform.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_ATTRIBUTE_QUANTIZATION_TRANSFORM_H_ -#define DRACO_ATTRIBUTES_ATTRIBUTE_QUANTIZATION_TRANSFORM_H_ - -#include - -#include "draco/attributes/attribute_transform.h" -#include "draco/attributes/point_attribute.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// Attribute transform for quantized attributes. -class AttributeQuantizationTransform : public AttributeTransform { - public: - AttributeQuantizationTransform() : quantization_bits_(-1), range_(0.f) {} - // Return attribute transform type. - AttributeTransformType Type() const override { - return ATTRIBUTE_QUANTIZATION_TRANSFORM; - } - // Try to init transform from attribute. - bool InitFromAttribute(const PointAttribute &attribute) override; - // Copy parameter values into the provided AttributeTransformData instance. - void CopyToAttributeTransformData( - AttributeTransformData *out_data) const override; - - void SetParameters(int quantization_bits, const float *min_values, - int num_components, float range); - - bool ComputeParameters(const PointAttribute &attribute, - const int quantization_bits); - - // Encode relevant parameters into buffer. - bool EncodeParameters(EncoderBuffer *encoder_buffer) const; - - int32_t quantization_bits() const { return quantization_bits_; } - float min_value(int axis) const { return min_values_[axis]; } - const std::vector &min_values() const { return min_values_; } - float range() const { return range_; } - bool is_initialized() const { return quantization_bits_ != -1; } - - // Create portable attribute using 1:1 mapping between points in the input and - // output attribute. - std::unique_ptr GeneratePortableAttribute( - const PointAttribute &attribute, int num_points) const; - - // Create portable attribute using custom mapping between input and output - // points. - std::unique_ptr GeneratePortableAttribute( - const PointAttribute &attribute, const std::vector &point_ids, - int num_points) const; - - private: - int32_t quantization_bits_; - - // Minimal dequantized value for each component of the attribute. - std::vector min_values_; - - // Bounds of the dequantized attribute (max delta over all components). - float range_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTE_DEQUANTIZATION_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/attributes/attribute_transform.h b/cloudreg_env/include/draco/attributes/attribute_transform.h deleted file mode 100644 index d746fbf..0000000 --- a/cloudreg_env/include/draco/attributes/attribute_transform.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_H_ -#define DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_H_ - -#include "draco/attributes/attribute_transform_data.h" -#include "draco/attributes/point_attribute.h" - -namespace draco { - -// Virtual base class for various attribute transforms, enforcing common -// interface where possible. -class AttributeTransform { - public: - virtual ~AttributeTransform() = default; - - // Return attribute transform type. - virtual AttributeTransformType Type() const = 0; - // Try to init transform from attribute. - virtual bool InitFromAttribute(const PointAttribute &attribute) = 0; - // Copy parameter values into the provided AttributeTransformData instance. - virtual void CopyToAttributeTransformData( - AttributeTransformData *out_data) const = 0; - bool TransferToAttribute(PointAttribute *attribute) const; - - protected: - std::unique_ptr InitPortableAttribute( - int num_entries, int num_components, int num_points, - const PointAttribute &attribute, bool is_unsigned) const; -}; - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_ATTRIBUTE_OCTAHEDRON_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/attributes/attribute_transform_data.h b/cloudreg_env/include/draco/attributes/attribute_transform_data.h deleted file mode 100644 index 96ed073..0000000 --- a/cloudreg_env/include/draco/attributes/attribute_transform_data.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_DATA_H_ -#define DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_DATA_H_ - -#include - -#include "draco/attributes/attribute_transform_type.h" -#include "draco/core/data_buffer.h" - -namespace draco { - -// Class for holding parameter values for an attribute transform of a -// PointAttribute. This can be for example quantization data for an attribute -// that holds quantized values. This class provides only a basic storage for -// attribute transform parameters and it should be accessed only through wrapper -// classes for a specific transform (e.g. AttributeQuantizationTransform). -class AttributeTransformData { - public: - AttributeTransformData() : transform_type_(ATTRIBUTE_INVALID_TRANSFORM) {} - AttributeTransformData(const AttributeTransformData &data) = default; - - // Returns the type of the attribute transform that is described by the class. - AttributeTransformType transform_type() const { return transform_type_; } - void set_transform_type(AttributeTransformType type) { - transform_type_ = type; - } - - // Returns a parameter value on a given |byte_offset|. - template - DataTypeT GetParameterValue(int byte_offset) const { - DataTypeT out_data; - buffer_.Read(byte_offset, &out_data, sizeof(DataTypeT)); - return out_data; - } - - // Sets a parameter value on a given |byte_offset|. - template - void SetParameterValue(int byte_offset, const DataTypeT &in_data) { - if (byte_offset + sizeof(DataTypeT) > buffer_.data_size()) { - buffer_.Resize(byte_offset + sizeof(DataTypeT)); - } - buffer_.Write(byte_offset, &in_data, sizeof(DataTypeT)); - } - - // Sets a parameter value at the end of the |buffer_|. - template - void AppendParameterValue(const DataTypeT &in_data) { - SetParameterValue(static_cast(buffer_.data_size()), in_data); - } - - private: - AttributeTransformType transform_type_; - DataBuffer buffer_; -}; - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_DATA_H_ diff --git a/cloudreg_env/include/draco/attributes/attribute_transform_type.h b/cloudreg_env/include/draco/attributes/attribute_transform_type.h deleted file mode 100644 index 51ce6f3..0000000 --- a/cloudreg_env/include/draco/attributes/attribute_transform_type.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_TYPE_H_ -#define DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_TYPE_H_ - -namespace draco { - -// List of all currently supported attribute transforms. -enum AttributeTransformType { - ATTRIBUTE_INVALID_TRANSFORM = -1, - ATTRIBUTE_NO_TRANSFORM = 0, - ATTRIBUTE_QUANTIZATION_TRANSFORM = 1, - ATTRIBUTE_OCTAHEDRON_TRANSFORM = 2, -}; - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_ATTRIBUTE_TRANSFORM_TYPE_H_ diff --git a/cloudreg_env/include/draco/attributes/geometry_attribute.h b/cloudreg_env/include/draco/attributes/geometry_attribute.h deleted file mode 100644 index 7be40fe..0000000 --- a/cloudreg_env/include/draco/attributes/geometry_attribute.h +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_GEOMETRY_ATTRIBUTE_H_ -#define DRACO_ATTRIBUTES_GEOMETRY_ATTRIBUTE_H_ - -#include -#include - -#include "draco/attributes/geometry_indices.h" -#include "draco/core/data_buffer.h" -#include "draco/core/hash_utils.h" - -namespace draco { - -// The class provides access to a specific attribute which is stored in a -// DataBuffer, such as normals or coordinates. However, the GeometryAttribute -// class does not own the buffer and the buffer itself may store other data -// unrelated to this attribute (such as data for other attributes in which case -// we can have multiple GeometryAttributes accessing one buffer). Typically, -// all attributes for a point (or corner, face) are stored in one block, which -// is advantageous in terms of memory access. The length of the entire block is -// given by the byte_stride, the position where the attribute starts is given by -// the byte_offset, the actual number of bytes that the attribute occupies is -// given by the data_type and the number of components. -class GeometryAttribute { - public: - // Supported attribute types. - enum Type { - INVALID = -1, - // Named attributes start here. The difference between named and generic - // attributes is that for named attributes we know their purpose and we - // can apply some special methods when dealing with them (e.g. during - // encoding). - POSITION = 0, - NORMAL, - COLOR, - TEX_COORD, - // A special id used to mark attributes that are not assigned to any known - // predefined use case. Such attributes are often used for a shader specific - // data. - GENERIC, - // Total number of different attribute types. - // Always keep behind all named attributes. - NAMED_ATTRIBUTES_COUNT, - }; - - GeometryAttribute(); - // Initializes and enables the attribute. - void Init(Type attribute_type, DataBuffer *buffer, int8_t num_components, - DataType data_type, bool normalized, int64_t byte_stride, - int64_t byte_offset); - bool IsValid() const { return buffer_ != nullptr; } - - // Copies data from the source attribute to the this attribute. - // This attribute must have a valid buffer allocated otherwise the operation - // is going to fail and return false. - bool CopyFrom(const GeometryAttribute &src_att); - - // Function for getting a attribute value with a specific format. - // Unsafe. Caller must ensure the accessed memory is valid. - // T is the attribute data type. - // att_components_t is the number of attribute components. - template - std::array GetValue( - AttributeValueIndex att_index) const { - // Byte address of the attribute index. - const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value(); - std::array out; - buffer_->Read(byte_pos, &(out[0]), sizeof(out)); - return out; - } - - // Function for getting a attribute value with a specific format. - // T is the attribute data type. - // att_components_t is the number of attribute components. - template - bool GetValue(AttributeValueIndex att_index, - std::array *out) const { - // Byte address of the attribute index. - const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value(); - // Check we are not reading past end of data. - if (byte_pos + sizeof(*out) > buffer_->data_size()) - return false; - buffer_->Read(byte_pos, &((*out)[0]), sizeof(*out)); - return true; - } - - // Returns the byte position of the attribute entry in the data buffer. - inline int64_t GetBytePos(AttributeValueIndex att_index) const { - return byte_offset_ + byte_stride_ * att_index.value(); - } - - inline const uint8_t *GetAddress(AttributeValueIndex att_index) const { - const int64_t byte_pos = GetBytePos(att_index); - return buffer_->data() + byte_pos; - } - inline uint8_t *GetAddress(AttributeValueIndex att_index) { - const int64_t byte_pos = GetBytePos(att_index); - return buffer_->data() + byte_pos; - } - - // Fills out_data with the raw value of the requested attribute entry. - // out_data must be at least byte_stride_ long. - void GetValue(AttributeValueIndex att_index, void *out_data) const { - const int64_t byte_pos = byte_offset_ + byte_stride_ * att_index.value(); - buffer_->Read(byte_pos, out_data, byte_stride_); - } - - // DEPRECATED: Use - // ConvertValue(AttributeValueIndex att_id, - // int out_num_components, - // OutT *out_val); - // - // Function for conversion of a attribute to a specific output format. - // OutT is the desired data type of the attribute. - // out_att_components_t is the number of components of the output format. - // Returns false when the conversion failed. - template - bool ConvertValue(AttributeValueIndex att_id, OutT *out_val) const { - return ConvertValue(att_id, out_att_components_t, out_val); - } - - // Function for conversion of a attribute to a specific output format. - // |out_val| needs to be able to store |out_num_components| values. - // OutT is the desired data type of the attribute. - // Returns false when the conversion failed. - template - bool ConvertValue(AttributeValueIndex att_id, int8_t out_num_components, - OutT *out_val) const { - if (out_val == nullptr) - return false; - switch (data_type_) { - case DT_INT8: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_UINT8: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_INT16: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_UINT16: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_INT32: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_UINT32: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_INT64: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_UINT64: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_FLOAT32: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_FLOAT64: - return ConvertTypedValue(att_id, out_num_components, - out_val); - case DT_BOOL: - return ConvertTypedValue(att_id, out_num_components, - out_val); - default: - // Wrong attribute type. - return false; - } - } - - // Function for conversion of a attribute to a specific output format. - // The |out_value| must be able to store all components of a single attribute - // entry. - // OutT is the desired data type of the attribute. - // Returns false when the conversion failed. - template - bool ConvertValue(AttributeValueIndex att_index, OutT *out_value) const { - return ConvertValue(att_index, num_components_, out_value); - } - - bool operator==(const GeometryAttribute &va) const; - - // Returns the type of the attribute indicating the nature of the attribute. - Type attribute_type() const { return attribute_type_; } - void set_attribute_type(Type type) { attribute_type_ = type; } - // Returns the data type that is stored in the attribute. - DataType data_type() const { return data_type_; } - // Returns the number of components that are stored for each entry. - // For position attribute this is usually three (x,y,z), - // while texture coordinates have two components (u,v). - int8_t num_components() const { return num_components_; } - // Indicates whether the data type should be normalized before interpretation, - // that is, it should be divided by the max value of the data type. - bool normalized() const { return normalized_; } - // The buffer storing the entire data of the attribute. - const DataBuffer *buffer() const { return buffer_; } - // Returns the number of bytes between two attribute entries, this is, at - // least size of the data types times number of components. - int64_t byte_stride() const { return byte_stride_; } - // The offset where the attribute starts within the block of size byte_stride. - int64_t byte_offset() const { return byte_offset_; } - void set_byte_offset(int64_t byte_offset) { byte_offset_ = byte_offset; } - DataBufferDescriptor buffer_descriptor() const { return buffer_descriptor_; } - uint32_t unique_id() const { return unique_id_; } - void set_unique_id(uint32_t id) { unique_id_ = id; } - - protected: - // Sets a new internal storage for the attribute. - void ResetBuffer(DataBuffer *buffer, int64_t byte_stride, - int64_t byte_offset); - - private: - // Function for conversion of an attribute to a specific output format given a - // format of the stored attribute. - // T is the stored attribute data type. - // OutT is the desired data type of the attribute. - template - bool ConvertTypedValue(AttributeValueIndex att_id, int8_t out_num_components, - OutT *out_value) const { - const uint8_t *src_address = GetAddress(att_id); - - // Convert all components available in both the original and output formats. - for (int i = 0; i < std::min(num_components_, out_num_components); ++i) { - const T in_value = *reinterpret_cast(src_address); - out_value[i] = static_cast(in_value); - // When converting integer to floating point, normalize the value if - // necessary. - if (std::is_integral::value && std::is_floating_point::value && - normalized_) { - out_value[i] /= static_cast(std::numeric_limits::max()); - } - // TODO(ostava): Add handling of normalized attributes when converting - // between different integer representations. If the attribute is - // normalized, integer values should be converted as if they represent 0-1 - // range. E.g. when we convert uint16 to uint8, the range <0, 2^16 - 1> - // should be converted to range <0, 2^8 - 1>. - src_address += sizeof(T); - } - // Fill empty data for unused output components if needed. - for (int i = num_components_; i < out_num_components; ++i) { - out_value[i] = static_cast(0); - } - return true; - } - - DataBuffer *buffer_; - // The buffer descriptor is stored at the time the buffer is attached to this - // attribute. The purpose is to detect if any changes happened to the buffer - // since the time it was attached. - DataBufferDescriptor buffer_descriptor_; - int8_t num_components_; - DataType data_type_; - bool normalized_; - int64_t byte_stride_; - int64_t byte_offset_; - - Type attribute_type_; - - // Unique id of this attribute. No two attributes could have the same unique - // id. It is used to identify each attribute, especially when there are - // multiple attribute of the same type in a point cloud. - uint32_t unique_id_; - - friend struct GeometryAttributeHasher; -}; - -// Hashing support - -// Function object for using Attribute as a hash key. -struct GeometryAttributeHasher { - size_t operator()(const GeometryAttribute &va) const { - size_t hash = HashCombine(va.buffer_descriptor_.buffer_id, - va.buffer_descriptor_.buffer_update_count); - hash = HashCombine(va.num_components_, hash); - hash = HashCombine((int8_t)va.data_type_, hash); - hash = HashCombine((int8_t)va.attribute_type_, hash); - hash = HashCombine(va.byte_stride_, hash); - return HashCombine(va.byte_offset_, hash); - } -}; - -// Function object for using GeometryAttribute::Type as a hash key. -struct GeometryAttributeTypeHasher { - size_t operator()(const GeometryAttribute::Type &at) const { - return static_cast(at); - } -}; - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_GEOMETRY_ATTRIBUTE_H_ diff --git a/cloudreg_env/include/draco/attributes/geometry_indices.h b/cloudreg_env/include/draco/attributes/geometry_indices.h deleted file mode 100644 index 80e43e3..0000000 --- a/cloudreg_env/include/draco/attributes/geometry_indices.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_GEOMETRY_INDICES_H_ -#define DRACO_ATTRIBUTES_GEOMETRY_INDICES_H_ - -#include - -#include - -#include "draco/core/draco_index_type.h" - -namespace draco { - -// Index of an attribute value entry stored in a GeometryAttribute. -DEFINE_NEW_DRACO_INDEX_TYPE(uint32_t, AttributeValueIndex) -// Index of a point in a PointCloud. -DEFINE_NEW_DRACO_INDEX_TYPE(uint32_t, PointIndex) -// Vertex index in a Mesh or CornerTable. -DEFINE_NEW_DRACO_INDEX_TYPE(uint32_t, VertexIndex) -// Corner index that identifies a corner in a Mesh or CornerTable. -DEFINE_NEW_DRACO_INDEX_TYPE(uint32_t, CornerIndex) -// Face index for Mesh and CornerTable. -DEFINE_NEW_DRACO_INDEX_TYPE(uint32_t, FaceIndex) - -// Constants denoting invalid indices. -static constexpr AttributeValueIndex kInvalidAttributeValueIndex( - std::numeric_limits::max()); -static constexpr PointIndex kInvalidPointIndex( - std::numeric_limits::max()); -static constexpr VertexIndex kInvalidVertexIndex( - std::numeric_limits::max()); -static constexpr CornerIndex kInvalidCornerIndex( - std::numeric_limits::max()); -static constexpr FaceIndex kInvalidFaceIndex( - std::numeric_limits::max()); - -// TODO(ostava): Add strongly typed indices for attribute id and unique -// attribute id. - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_GEOMETRY_INDICES_H_ diff --git a/cloudreg_env/include/draco/attributes/point_attribute.h b/cloudreg_env/include/draco/attributes/point_attribute.h deleted file mode 100644 index 46e58a4..0000000 --- a/cloudreg_env/include/draco/attributes/point_attribute.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_ATTRIBUTES_POINT_ATTRIBUTE_H_ -#define DRACO_ATTRIBUTES_POINT_ATTRIBUTE_H_ - -#include - -#include "draco/draco_features.h" - -#include "draco/attributes/attribute_transform_data.h" -#include "draco/attributes/geometry_attribute.h" -#include "draco/core/draco_index_type_vector.h" -#include "draco/core/hash_utils.h" -#include "draco/core/macros.h" - -namespace draco { - -// Class for storing point specific data about each attribute. In general, -// multiple points stored in a point cloud can share the same attribute value -// and this class provides the necessary mapping between point ids and attribute -// value ids. -class PointAttribute : public GeometryAttribute { - public: - PointAttribute(); - explicit PointAttribute(const GeometryAttribute &att); - - // Make sure the move constructor is defined (needed for better performance - // when new attributes are added to PointCloud). - PointAttribute(PointAttribute &&attribute) = default; - PointAttribute &operator=(PointAttribute &&attribute) = default; - - // Copies attribute data from the provided |src_att| attribute. - void CopyFrom(const PointAttribute &src_att); - - // Prepares the attribute storage for the specified number of entries. - bool Reset(size_t num_attribute_values); - - size_t size() const { return num_unique_entries_; } - AttributeValueIndex mapped_index(PointIndex point_index) const { - if (identity_mapping_) - return AttributeValueIndex(point_index.value()); - return indices_map_[point_index]; - } - DataBuffer *buffer() const { return attribute_buffer_.get(); } - bool is_mapping_identity() const { return identity_mapping_; } - size_t indices_map_size() const { - if (is_mapping_identity()) - return 0; - return indices_map_.size(); - } - - const uint8_t *GetAddressOfMappedIndex(PointIndex point_index) const { - return GetAddress(mapped_index(point_index)); - } - - // Sets the new number of unique attribute entries for the attribute. - void Resize(size_t new_num_unique_entries) { - num_unique_entries_ = static_cast(new_num_unique_entries); - } - - // Functions for setting the type of mapping between point indices and - // attribute entry ids. - // This function sets the mapping to implicit, where point indices are equal - // to attribute entry indices. - void SetIdentityMapping() { - identity_mapping_ = true; - indices_map_.clear(); - } - // This function sets the mapping to be explicitly using the indices_map_ - // array that needs to be initialized by the caller. - void SetExplicitMapping(size_t num_points) { - identity_mapping_ = false; - indices_map_.resize(num_points, kInvalidAttributeValueIndex); - } - - // Set an explicit map entry for a specific point index. - void SetPointMapEntry(PointIndex point_index, - AttributeValueIndex entry_index) { - DRACO_DCHECK(!identity_mapping_); - indices_map_[point_index] = entry_index; - } - - // Sets a value of an attribute entry. The input value must be allocated to - // cover all components of a single attribute entry. - void SetAttributeValue(AttributeValueIndex entry_index, const void *value) { - const int64_t byte_pos = entry_index.value() * byte_stride(); - buffer()->Write(byte_pos, value, byte_stride()); - } - - // Same as GeometryAttribute::GetValue(), but using point id as the input. - // Mapping to attribute value index is performed automatically. - void GetMappedValue(PointIndex point_index, void *out_data) const { - return GetValue(mapped_index(point_index), out_data); - } - -#ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED - // Deduplicate |in_att| values into |this| attribute. |in_att| can be equal - // to |this|. - // Returns -1 if the deduplication failed. - AttributeValueIndex::ValueType DeduplicateValues( - const GeometryAttribute &in_att); - - // Same as above but the values read from |in_att| are sampled with the - // provided offset |in_att_offset|. - AttributeValueIndex::ValueType DeduplicateValues( - const GeometryAttribute &in_att, AttributeValueIndex in_att_offset); -#endif - - // Set attribute transform data for the attribute. The data is used to store - // the type and parameters of the transform that is applied on the attribute - // data (optional). - void SetAttributeTransformData( - std::unique_ptr transform_data) { - attribute_transform_data_ = std::move(transform_data); - } - const AttributeTransformData *GetAttributeTransformData() const { - return attribute_transform_data_.get(); - } - - private: -#ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED - template - AttributeValueIndex::ValueType DeduplicateTypedValues( - const GeometryAttribute &in_att, AttributeValueIndex in_att_offset); - template - AttributeValueIndex::ValueType DeduplicateFormattedValues( - const GeometryAttribute &in_att, AttributeValueIndex in_att_offset); -#endif - - // Data storage for attribute values. GeometryAttribute itself doesn't own its - // buffer so we need to allocate it here. - std::unique_ptr attribute_buffer_; - - // Mapping between point ids and attribute value ids. - IndexTypeVector indices_map_; - AttributeValueIndex::ValueType num_unique_entries_; - // Flag when the mapping between point ids and attribute values is identity. - bool identity_mapping_; - - // If an attribute contains transformed data (e.g. quantized), we can specify - // the attribute transform here and use it to transform the attribute back to - // its original format. - std::unique_ptr attribute_transform_data_; - - friend struct PointAttributeHasher; -}; - -// Hash functor for the PointAttribute class. -struct PointAttributeHasher { - size_t operator()(const PointAttribute &attribute) const { - GeometryAttributeHasher base_hasher; - size_t hash = base_hasher(attribute); - hash = HashCombine(attribute.identity_mapping_, hash); - hash = HashCombine(attribute.num_unique_entries_, hash); - hash = HashCombine(attribute.indices_map_.size(), hash); - if (attribute.indices_map_.size() > 0) { - const uint64_t indices_hash = FingerprintString( - reinterpret_cast(attribute.indices_map_.data()), - attribute.indices_map_.size()); - hash = HashCombine(indices_hash, hash); - } - if (attribute.attribute_buffer_ != nullptr) { - const uint64_t buffer_hash = FingerprintString( - reinterpret_cast(attribute.attribute_buffer_->data()), - attribute.attribute_buffer_->data_size()); - hash = HashCombine(buffer_hash, hash); - } - return hash; - } -}; - -} // namespace draco - -#endif // DRACO_ATTRIBUTES_POINT_ATTRIBUTE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/attributes_decoder.h b/cloudreg_env/include/draco/compression/attributes/attributes_decoder.h deleted file mode 100644 index 9c6e9fe..0000000 --- a/cloudreg_env/include/draco/compression/attributes/attributes_decoder.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_H_ - -#include - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/attributes_decoder_interface.h" -#include "draco/compression/point_cloud/point_cloud_decoder.h" -#include "draco/core/decoder_buffer.h" -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -// Base class for decoding one or more attributes that were encoded with a -// matching AttributesEncoder. It is a basic implementation of -// AttributesDecoderInterface that provides functionality that is shared between -// all AttributesDecoders. -class AttributesDecoder : public AttributesDecoderInterface { - public: - AttributesDecoder(); - virtual ~AttributesDecoder() = default; - - // Called after all attribute decoders are created. It can be used to perform - // any custom initialization. - bool Init(PointCloudDecoder *decoder, PointCloud *pc) override; - - // Decodes any attribute decoder specific data from the |in_buffer|. - bool DecodeAttributesDecoderData(DecoderBuffer *in_buffer) override; - - int32_t GetAttributeId(int i) const override { - return point_attribute_ids_[i]; - } - int32_t GetNumAttributes() const override { - return static_cast(point_attribute_ids_.size()); - } - PointCloudDecoder *GetDecoder() const override { - return point_cloud_decoder_; - } - - // Decodes attribute data from the source buffer. - bool DecodeAttributes(DecoderBuffer *in_buffer) override { - if (!DecodePortableAttributes(in_buffer)) - return false; - if (!DecodeDataNeededByPortableTransforms(in_buffer)) - return false; - if (!TransformAttributesToOriginalFormat()) - return false; - return true; - } - - protected: - int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { - const int id_map_size = - static_cast(point_attribute_to_local_id_map_.size()); - if (point_attribute_id >= id_map_size) - return -1; - return point_attribute_to_local_id_map_[point_attribute_id]; - } - virtual bool DecodePortableAttributes(DecoderBuffer *in_buffer) = 0; - virtual bool DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer) { - return true; - } - virtual bool TransformAttributesToOriginalFormat() { return true; } - - private: - // List of attribute ids that need to be decoded with this decoder. - std::vector point_attribute_ids_; - - // Map between point attribute id and the local id (i.e., the inverse of the - // |point_attribute_ids_|. - std::vector point_attribute_to_local_id_map_; - - PointCloudDecoder *point_cloud_decoder_; - PointCloud *point_cloud_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/attributes_decoder_interface.h b/cloudreg_env/include/draco/compression/attributes/attributes_decoder_interface.h deleted file mode 100644 index 8e5cf52..0000000 --- a/cloudreg_env/include/draco/compression/attributes/attributes_decoder_interface.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_INTERFACE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_INTERFACE_H_ - -#include - -#include "draco/core/decoder_buffer.h" -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -class PointCloudDecoder; - -// Interface class for decoding one or more attributes that were encoded with a -// matching AttributesEncoder. It provides only the basic interface -// that is used by the PointCloudDecoder. The actual decoding must be -// implemented in derived classes using the DecodeAttributes() method. -class AttributesDecoderInterface { - public: - AttributesDecoderInterface() = default; - virtual ~AttributesDecoderInterface() = default; - - // Called after all attribute decoders are created. It can be used to perform - // any custom initialization. - virtual bool Init(PointCloudDecoder *decoder, PointCloud *pc) = 0; - - // Decodes any attribute decoder specific data from the |in_buffer|. - virtual bool DecodeAttributesDecoderData(DecoderBuffer *in_buffer) = 0; - - // Decode attribute data from the source buffer. Needs to be implemented by - // the derived classes. - virtual bool DecodeAttributes(DecoderBuffer *in_buffer) = 0; - - virtual int32_t GetAttributeId(int i) const = 0; - virtual int32_t GetNumAttributes() const = 0; - virtual PointCloudDecoder *GetDecoder() const = 0; - - // Returns an attribute containing data processed by the attribute transform. - // (see TransformToPortableFormat() method). This data is guaranteed to be - // same for encoder and decoder and it can be used by predictors. - virtual const PointAttribute *GetPortableAttribute( - int32_t /* point_attribute_id */) { - return nullptr; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_INTERFACE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/attributes_encoder.h b/cloudreg_env/include/draco/compression/attributes/attributes_encoder.h deleted file mode 100644 index 09d1010..0000000 --- a/cloudreg_env/include/draco/compression/attributes/attributes_encoder.h +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_ENCODER_H_ - -#include "draco/attributes/point_attribute.h" -#include "draco/core/encoder_buffer.h" -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -class PointCloudEncoder; - -// Base class for encoding one or more attributes of a PointCloud (or other -// geometry). This base class provides only the basic interface that is used -// by the PointCloudEncoder. -class AttributesEncoder { - public: - AttributesEncoder(); - // Constructs an attribute encoder associated with a given point attribute. - explicit AttributesEncoder(int point_attrib_id); - virtual ~AttributesEncoder() = default; - - // Called after all attribute encoders are created. It can be used to perform - // any custom initialization, including setting up attribute dependencies. - // Note: no data should be encoded in this function, because the decoder may - // process encoders in a different order from the decoder. - virtual bool Init(PointCloudEncoder *encoder, const PointCloud *pc); - - // Encodes data needed by the target attribute decoder. - virtual bool EncodeAttributesEncoderData(EncoderBuffer *out_buffer); - - // Returns a unique identifier of the given encoder type, that is used during - // decoding to construct the corresponding attribute decoder. - virtual uint8_t GetUniqueId() const = 0; - - // Encode attribute data to the target buffer. - virtual bool EncodeAttributes(EncoderBuffer *out_buffer) { - if (!TransformAttributesToPortableFormat()) - return false; - if (!EncodePortableAttributes(out_buffer)) - return false; - // Encode data needed by portable transforms after the attribute is encoded. - // This corresponds to the order in which the data is going to be decoded by - // the decoder. - if (!EncodeDataNeededByPortableTransforms(out_buffer)) - return false; - return true; - } - - // Returns the number of attributes that need to be encoded before the - // specified attribute is encoded. - // Note that the attribute is specified by its point attribute id. - virtual int NumParentAttributes(int32_t /* point_attribute_id */) const { - return 0; - } - - virtual int GetParentAttributeId(int32_t /* point_attribute_id */, - int32_t /* parent_i */) const { - return -1; - } - - // Marks a given attribute as a parent of another attribute. - virtual bool MarkParentAttribute(int32_t /* point_attribute_id */) { - return false; - } - - // Returns an attribute containing data processed by the attribute transform. - // (see TransformToPortableFormat() method). This data is guaranteed to be - // encoded losslessly and it can be safely used for predictors. - virtual const PointAttribute *GetPortableAttribute( - int32_t /* point_attribute_id */) { - return nullptr; - } - - void AddAttributeId(int32_t id) { - point_attribute_ids_.push_back(id); - if (id >= static_cast(point_attribute_to_local_id_map_.size())) - point_attribute_to_local_id_map_.resize(id + 1, -1); - point_attribute_to_local_id_map_[id] = - static_cast(point_attribute_ids_.size()) - 1; - } - - // Sets new attribute point ids (replacing the existing ones). - void SetAttributeIds(const std::vector &point_attribute_ids) { - point_attribute_ids_.clear(); - point_attribute_to_local_id_map_.clear(); - for (int32_t att_id : point_attribute_ids) { - AddAttributeId(att_id); - } - } - - int32_t GetAttributeId(int i) const { return point_attribute_ids_[i]; } - uint32_t num_attributes() const { - return static_cast(point_attribute_ids_.size()); - } - PointCloudEncoder *encoder() const { return point_cloud_encoder_; } - - protected: - // Transforms the input attribute data into a form that should be losslessly - // encoded (transform itself can be lossy). - virtual bool TransformAttributesToPortableFormat() { return true; } - - // Losslessly encodes data of all portable attributes. - // Precondition: All attributes must have been transformed into portable - // format at this point (see TransformAttributesToPortableFormat() method). - virtual bool EncodePortableAttributes(EncoderBuffer *out_buffer) = 0; - - // Encodes any data needed to revert the transform to portable format for each - // attribute (e.g. data needed for dequantization of quantized values). - virtual bool EncodeDataNeededByPortableTransforms(EncoderBuffer *out_buffer) { - return true; - } - - int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const { - const int id_map_size = - static_cast(point_attribute_to_local_id_map_.size()); - if (point_attribute_id >= id_map_size) - return -1; - return point_attribute_to_local_id_map_[point_attribute_id]; - } - - private: - // List of attribute ids that need to be encoded with this encoder. - std::vector point_attribute_ids_; - - // Map between point attribute id and the local id (i.e., the inverse of the - // |point_attribute_ids_|. - std::vector point_attribute_to_local_id_map_; - - PointCloudEncoder *point_cloud_encoder_; - const PointCloud *point_cloud_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_decoder.h b/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_decoder.h deleted file mode 100644 index 87338d6..0000000 --- a/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_decoder.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_KD_TREE_ATTRIBUTES_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_KD_TREE_ATTRIBUTES_DECODER_H_ - -#include "draco/attributes/attribute_quantization_transform.h" -#include "draco/compression/attributes/attributes_decoder.h" - -namespace draco { - -// Decodes attributes encoded with the KdTreeAttributesEncoder. -class KdTreeAttributesDecoder : public AttributesDecoder { - public: - KdTreeAttributesDecoder(); - - protected: - bool DecodePortableAttributes(DecoderBuffer *in_buffer) override; - bool DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer) override; - bool TransformAttributesToOriginalFormat() override; - - private: - template - bool TransformAttributeBackToSignedType(PointAttribute *att, - int num_processed_signed_components); - - std::vector - attribute_quantization_transforms_; - std::vector min_signed_values_; - std::vector> quantized_portable_attributes_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_KD_TREE_ATTRIBUTES_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_encoder.h b/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_encoder.h deleted file mode 100644 index 8b4c4e2..0000000 --- a/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_encoder.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_POINT_CLOUD_KD_TREE_ATTRIBUTES_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_POINT_CLOUD_KD_TREE_ATTRIBUTES_ENCODER_H_ - -#include "draco/attributes/attribute_quantization_transform.h" -#include "draco/compression/attributes/attributes_encoder.h" -#include "draco/compression/config/compression_shared.h" - -namespace draco { - -// Encodes all attributes of a given PointCloud using one of the available -// Kd-tree compression methods. -// See compression/point_cloud/point_cloud_kd_tree_encoder.h for more details. -class KdTreeAttributesEncoder : public AttributesEncoder { - public: - KdTreeAttributesEncoder(); - explicit KdTreeAttributesEncoder(int att_id); - - uint8_t GetUniqueId() const override { return KD_TREE_ATTRIBUTE_ENCODER; } - - protected: - bool TransformAttributesToPortableFormat() override; - bool EncodePortableAttributes(EncoderBuffer *out_buffer) override; - bool EncodeDataNeededByPortableTransforms(EncoderBuffer *out_buffer) override; - - private: - std::vector - attribute_quantization_transforms_; - // Min signed values are used to transform signed integers into unsigned ones - // (by subtracting the min signed value for each component). - std::vector min_signed_values_; - std::vector> quantized_portable_attributes_; - int num_components_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_POINT_CLOUD_KD_TREE_ATTRIBUTES_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_shared.h b/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_shared.h deleted file mode 100644 index 94841a9..0000000 --- a/cloudreg_env/include/draco/compression/attributes/kd_tree_attributes_shared.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_KD_TREE_ATTRIBUTES_SHARED_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_KD_TREE_ATTRIBUTES_SHARED_H_ - -namespace draco { - -// Defines types of kD-tree compression -enum KdTreeAttributesEncodingMethod { - kKdTreeQuantizationEncoding = 0, - kKdTreeIntegerEncoding -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_KD_TREE_ATTRIBUTES_SHARED_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/linear_sequencer.h b/cloudreg_env/include/draco/compression/attributes/linear_sequencer.h deleted file mode 100644 index dc4dfff..0000000 --- a/cloudreg_env/include/draco/compression/attributes/linear_sequencer.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_LINEAR_SEQUENCER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_LINEAR_SEQUENCER_H_ - -#include "draco/compression/attributes/points_sequencer.h" - -namespace draco { - -// A simple sequencer that generates a linear sequence [0, num_points - 1]. -// I.e., the order of the points is preserved for the input data. -class LinearSequencer : public PointsSequencer { - public: - explicit LinearSequencer(int32_t num_points) : num_points_(num_points) {} - - bool UpdatePointToAttributeIndexMapping(PointAttribute *attribute) override { - attribute->SetIdentityMapping(); - return true; - } - - protected: - bool GenerateSequenceInternal() override { - if (num_points_ < 0) - return false; - out_point_ids()->resize(num_points_); - for (int i = 0; i < num_points_; ++i) { - out_point_ids()->at(i) = PointIndex(i); - } - return true; - } - - private: - int32_t num_points_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_LINEAR_SEQUENCER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h b/cloudreg_env/include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h deleted file mode 100644 index 9a358e4..0000000 --- a/cloudreg_env/include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_ - -#include - -#include - -#include "draco/attributes/geometry_indices.h" - -namespace draco { - -// Data used for encoding and decoding of mesh attributes. -struct MeshAttributeIndicesEncodingData { - MeshAttributeIndicesEncodingData() : num_values(0) {} - - void Init(int num_vertices) { - vertex_to_encoded_attribute_value_index_map.resize(num_vertices); - - // We expect to store one value for each vertex. - encoded_attribute_value_index_to_corner_map.reserve(num_vertices); - } - - // Array for storing the corner ids in the order their associated attribute - // entries were encoded/decoded. For every encoded attribute value entry we - // store exactly one corner. I.e., this is the mapping between an encoded - // attribute entry ids and corner ids. This map is needed for example by - // prediction schemes. Note that not all corners are included in this map, - // e.g., if multiple corners share the same attribute value, only one of these - // corners will be usually included. - std::vector encoded_attribute_value_index_to_corner_map; - - // Map for storing encoding order of attribute entries for each vertex. - // i.e. Mapping between vertices and their corresponding attribute entry ids - // that are going to be used by the decoder. - // -1 if an attribute entry hasn't been encoded/decoded yet. - std::vector vertex_to_encoded_attribute_value_index_map; - - // Total number of encoded/decoded attribute entries. - int num_values; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/normal_compression_utils.h b/cloudreg_env/include/draco/compression/attributes/normal_compression_utils.h deleted file mode 100644 index 4e6ff1a..0000000 --- a/cloudreg_env/include/draco/compression/attributes/normal_compression_utils.h +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Utilities for converting unit vectors to octahedral coordinates and back. -// For more details about octahedral coordinates, see for example Cigolle -// et al.'14 “A Survey of Efficient Representations for Independent Unit -// Vectors”. -// -// In short this is motivated by an octahedron inscribed into a sphere. The -// direction of the normal vector can be defined by a point on the octahedron. -// On the right hemisphere (x > 0) this point is projected onto the x = 0 plane, -// that is, the right side of the octahedron forms a diamond like shape. The -// left side of the octahedron is also projected onto the x = 0 plane, however, -// in this case we flap the triangles of the diamond outward. Afterwards we -// shift the resulting square such that all values are positive. -// -// Important values in this file: -// * q: number of quantization bits -// * max_quantized_value: the max value representable with q bits (odd) -// * max_value: max value of the diamond = max_quantized_value - 1 (even) -// * center_value: center of the diamond after shift -// -// Note that the parameter space is somewhat periodic, e.g. (0, 0) == -// (max_value, max_value), which is also why the diamond is one smaller than the -// maximal representable value in order to have an odd range of values. - -#ifndef DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_ - -#include -#include -#include - -#include "draco/core/macros.h" - -namespace draco { - -class OctahedronToolBox { - public: - OctahedronToolBox() - : quantization_bits_(-1), - max_quantized_value_(-1), - max_value_(-1), - center_value_(-1) {} - - bool SetQuantizationBits(int32_t q) { - if (q < 2 || q > 30) - return false; - quantization_bits_ = q; - max_quantized_value_ = (1 << quantization_bits_) - 1; - max_value_ = max_quantized_value_ - 1; - center_value_ = max_value_ / 2; - return true; - } - bool IsInitialized() const { return quantization_bits_ != -1; } - - // Convert all edge points in the top left and bottom right quadrants to - // their corresponding position in the bottom left and top right quadrants. - // Convert all corner edge points to the top right corner. - inline void CanonicalizeOctahedralCoords(int32_t s, int32_t t, int32_t *out_s, - int32_t *out_t) const { - if ((s == 0 && t == 0) || (s == 0 && t == max_value_) || - (s == max_value_ && t == 0)) { - s = max_value_; - t = max_value_; - } else if (s == 0 && t > center_value_) { - t = center_value_ - (t - center_value_); - } else if (s == max_value_ && t < center_value_) { - t = center_value_ + (center_value_ - t); - } else if (t == max_value_ && s < center_value_) { - s = center_value_ + (center_value_ - s); - } else if (t == 0 && s > center_value_) { - s = center_value_ - (s - center_value_); - } - - *out_s = s; - *out_t = t; - } - - // Converts an integer vector to octahedral coordinates. - // Precondition: |int_vec| abs sum must equal center value. - inline void IntegerVectorToQuantizedOctahedralCoords(const int32_t *int_vec, - int32_t *out_s, - int32_t *out_t) const { - DRACO_DCHECK_EQ( - std::abs(int_vec[0]) + std::abs(int_vec[1]) + std::abs(int_vec[2]), - center_value_); - int32_t s, t; - if (int_vec[0] >= 0) { - // Right hemisphere. - s = (int_vec[1] + center_value_); - t = (int_vec[2] + center_value_); - } else { - // Left hemisphere. - if (int_vec[1] < 0) { - s = std::abs(int_vec[2]); - } else { - s = (max_value_ - std::abs(int_vec[2])); - } - if (int_vec[2] < 0) { - t = std::abs(int_vec[1]); - } else { - t = (max_value_ - std::abs(int_vec[1])); - } - } - CanonicalizeOctahedralCoords(s, t, out_s, out_t); - } - - template - void FloatVectorToQuantizedOctahedralCoords(const T *vector, int32_t *out_s, - int32_t *out_t) const { - const double abs_sum = std::abs(static_cast(vector[0])) + - std::abs(static_cast(vector[1])) + - std::abs(static_cast(vector[2])); - - // Adjust values such that abs sum equals 1. - double scaled_vector[3]; - if (abs_sum > 1e-6) { - // Scale needed to project the vector to the surface of an octahedron. - const double scale = 1.0 / abs_sum; - scaled_vector[0] = vector[0] * scale; - scaled_vector[1] = vector[1] * scale; - scaled_vector[2] = vector[2] * scale; - } else { - scaled_vector[0] = 1.0; - scaled_vector[1] = 0; - scaled_vector[2] = 0; - } - - // Scale vector such that the sum equals the center value. - int32_t int_vec[3]; - int_vec[0] = - static_cast(floor(scaled_vector[0] * center_value_ + 0.5)); - int_vec[1] = - static_cast(floor(scaled_vector[1] * center_value_ + 0.5)); - // Make sure the sum is exactly the center value. - int_vec[2] = center_value_ - std::abs(int_vec[0]) - std::abs(int_vec[1]); - if (int_vec[2] < 0) { - // If the sum of first two coordinates is too large, we need to decrease - // the length of one of the coordinates. - if (int_vec[1] > 0) { - int_vec[1] += int_vec[2]; - } else { - int_vec[1] -= int_vec[2]; - } - int_vec[2] = 0; - } - // Take care of the sign. - if (scaled_vector[2] < 0) - int_vec[2] *= -1; - - IntegerVectorToQuantizedOctahedralCoords(int_vec, out_s, out_t); - } - - // Normalize |vec| such that its abs sum is equal to the center value; - template - void CanonicalizeIntegerVector(T *vec) const { - static_assert(std::is_integral::value, "T must be an integral type."); - static_assert(std::is_signed::value, "T must be a signed type."); - const int64_t abs_sum = static_cast(std::abs(vec[0])) + - static_cast(std::abs(vec[1])) + - static_cast(std::abs(vec[2])); - - if (abs_sum == 0) { - vec[0] = center_value_; // vec[1] == v[2] == 0 - } else { - vec[0] = - (static_cast(vec[0]) * static_cast(center_value_)) / - abs_sum; - vec[1] = - (static_cast(vec[1]) * static_cast(center_value_)) / - abs_sum; - if (vec[2] >= 0) { - vec[2] = center_value_ - std::abs(vec[0]) - std::abs(vec[1]); - } else { - vec[2] = -(center_value_ - std::abs(vec[0]) - std::abs(vec[1])); - } - } - } - - template - void OctaherdalCoordsToUnitVector(T in_s, T in_t, T *out_vector) const { - DRACO_DCHECK_GE(in_s, 0); - DRACO_DCHECK_GE(in_t, 0); - DRACO_DCHECK_LE(in_s, 1); - DRACO_DCHECK_LE(in_t, 1); - T s = in_s; - T t = in_t; - T spt = s + t; - T smt = s - t; - T x_sign = 1.0; - if (spt >= 0.5 && spt <= 1.5 && smt >= -0.5 && smt <= 0.5) { - // Right hemisphere. Don't do anything. - } else { - // Left hemisphere. - x_sign = -1.0; - if (spt <= 0.5) { - s = 0.5 - in_t; - t = 0.5 - in_s; - } else if (spt >= 1.5) { - s = 1.5 - in_t; - t = 1.5 - in_s; - } else if (smt <= -0.5) { - s = in_t - 0.5; - t = in_s + 0.5; - } else { - s = in_t + 0.5; - t = in_s - 0.5; - } - spt = s + t; - smt = s - t; - } - const T y = 2.0 * s - 1.0; - const T z = 2.0 * t - 1.0; - const T x = std::min(std::min(2.0 * spt - 1.0, 3.0 - 2.0 * spt), - std::min(2.0 * smt + 1.0, 1.0 - 2.0 * smt)) * - x_sign; - // Normalize the computed vector. - const T normSquared = x * x + y * y + z * z; - if (normSquared < 1e-6) { - out_vector[0] = 0; - out_vector[1] = 0; - out_vector[2] = 0; - } else { - const T d = 1.0 / std::sqrt(normSquared); - out_vector[0] = x * d; - out_vector[1] = y * d; - out_vector[2] = z * d; - } - } - - template - void QuantizedOctaherdalCoordsToUnitVector(int32_t in_s, int32_t in_t, - T *out_vector) const { - T scale = 1.0 / static_cast(max_value_); - OctaherdalCoordsToUnitVector(in_s * scale, in_t * scale, out_vector); - } - - // |s| and |t| are expected to be signed values. - inline bool IsInDiamond(const int32_t &s, const int32_t &t) const { - // Expect center already at origin. - DRACO_DCHECK_LE(s, center_value_); - DRACO_DCHECK_LE(t, center_value_); - DRACO_DCHECK_GE(s, -center_value_); - DRACO_DCHECK_GE(t, -center_value_); - return std::abs(s) + std::abs(t) <= center_value_; - } - - void InvertDiamond(int32_t *s, int32_t *t) const { - // Expect center already at origin. - DRACO_DCHECK_LE(*s, center_value_); - DRACO_DCHECK_LE(*t, center_value_); - DRACO_DCHECK_GE(*s, -center_value_); - DRACO_DCHECK_GE(*t, -center_value_); - int32_t sign_s = 0; - int32_t sign_t = 0; - if (*s >= 0 && *t >= 0) { - sign_s = 1; - sign_t = 1; - } else if (*s <= 0 && *t <= 0) { - sign_s = -1; - sign_t = -1; - } else { - sign_s = (*s > 0) ? 1 : -1; - sign_t = (*t > 0) ? 1 : -1; - } - - const int32_t corner_point_s = sign_s * center_value_; - const int32_t corner_point_t = sign_t * center_value_; - *s = 2 * *s - corner_point_s; - *t = 2 * *t - corner_point_t; - if (sign_s * sign_t >= 0) { - int32_t temp = *s; - *s = -*t; - *t = -temp; - } else { - std::swap(*s, *t); - } - *s = (*s + corner_point_s) / 2; - *t = (*t + corner_point_t) / 2; - } - - void InvertDirection(int32_t *s, int32_t *t) const { - // Expect center already at origin. - DRACO_DCHECK_LE(*s, center_value_); - DRACO_DCHECK_LE(*t, center_value_); - DRACO_DCHECK_GE(*s, -center_value_); - DRACO_DCHECK_GE(*t, -center_value_); - *s *= -1; - *t *= -1; - this->InvertDiamond(s, t); - } - - // For correction values. - int32_t ModMax(int32_t x) const { - if (x > this->center_value()) - return x - this->max_quantized_value(); - if (x < -this->center_value()) - return x + this->max_quantized_value(); - return x; - } - - // For correction values. - int32_t MakePositive(int32_t x) const { - DRACO_DCHECK_LE(x, this->center_value() * 2); - if (x < 0) - return x + this->max_quantized_value(); - return x; - } - - int32_t quantization_bits() const { return quantization_bits_; } - int32_t max_quantized_value() const { return max_quantized_value_; } - int32_t max_value() const { return max_value_; } - int32_t center_value() const { return center_value_; } - - private: - int32_t quantization_bits_; - int32_t max_quantized_value_; - int32_t max_value_; - int32_t center_value_; -}; -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/point_d_vector.h b/cloudreg_env/include/draco/compression/attributes/point_d_vector.h deleted file mode 100644 index ce99c80..0000000 --- a/cloudreg_env/include/draco/compression/attributes/point_d_vector.h +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright 2018 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef DRACO_COMPRESSION_ATTRIBUTES_POINT_D_VECTOR_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_POINT_D_VECTOR_H_ - -#include -#include -#include -#include "draco/core/macros.h" - -namespace draco { - -// The main class of this file is PointDVector providing an interface similar to -// std::vector for arbitrary number of dimensions (without a template -// argument). PointDVectorIterator is a random access iterator, which allows for -// compatibility with existing algorithms. PseudoPointD provides for a view on -// the individual items in a contiguous block of memory, which is compatible -// with the swap function and is returned by a dereference of -// PointDVectorIterator. Swap functions provide for compatibility/specialization -// that allows these classes to work with currently utilized STL functions. - -// This class allows for swap functionality from the RandomIterator -// It seems problematic to bring this inside PointDVector due to templating. -template -class PseudoPointD { - public: - PseudoPointD(internal_t *mem, internal_t dimension) - : mem_(mem), dimension_(dimension) {} - - // Specifically copies referenced memory - void swap(PseudoPointD &other) noexcept { - for (internal_t dim = 0; dim < dimension_; dim += 1) - std::swap(mem_[dim], other.mem_[dim]); - } - - PseudoPointD(const PseudoPointD &other) - : mem_(other.mem_), dimension_(other.dimension_) {} - - const internal_t &operator[](const size_t &n) const { - DRACO_DCHECK_LT(n, dimension_); - return mem_[n]; - } - internal_t &operator[](const size_t &n) { - DRACO_DCHECK_LT(n, dimension_); - return mem_[n]; - } - - bool operator==(const PseudoPointD &other) const { - for (auto dim = 0; dim < dimension_; dim += 1) - if (mem_[dim] != other.mem_[dim]) - return false; - return true; - } - bool operator!=(const PseudoPointD &other) const { - return !this->operator==(other); - } - - private: - internal_t *const mem_; - const internal_t dimension_; -}; - -// It seems problematic to bring this inside PointDVector due to templating. -template -void swap(draco::PseudoPointD &&a, - draco::PseudoPointD &&b) noexcept { - a.swap(b); -}; -template -void swap(draco::PseudoPointD &a, - draco::PseudoPointD &b) noexcept { - a.swap(b); -}; - -template -class PointDVector { - public: - PointDVector(const uint32_t n_items, const uint32_t dimensionality) - : n_items_(n_items), - dimensionality_(dimensionality), - item_size_bytes_(dimensionality * sizeof(internal_t)), - data_(n_items * dimensionality), - data0_(data_.data()) {} - // random access iterator - class PointDVectorIterator - : public std::iterator { - friend class PointDVector; - - public: - // std::iter_swap is called inside of std::partition and needs this - // specialized support - PseudoPointD operator*() const { - return PseudoPointD(vec_->data0_ + item_ * dimensionality_, - dimensionality_); - } - const PointDVectorIterator &operator++() { - item_ += 1; - return *this; - } - const PointDVectorIterator &operator--() { - item_ -= 1; - return *this; - } - PointDVectorIterator operator++(int32_t) { - PointDVectorIterator copy(*this); - item_ += 1; - return copy; - } - PointDVectorIterator operator--(int32_t) { - PointDVectorIterator copy(*this); - item_ -= 1; - return copy; - } - PointDVectorIterator &operator=(const PointDVectorIterator &other) { - this->item_ = other.item_; - return *this; - } - - bool operator==(const PointDVectorIterator &ref) const { - return item_ == ref.item_; - } - bool operator!=(const PointDVectorIterator &ref) const { - return item_ != ref.item_; - } - bool operator<(const PointDVectorIterator &ref) const { - return item_ < ref.item_; - } - bool operator>(const PointDVectorIterator &ref) const { - return item_ > ref.item_; - } - bool operator<=(const PointDVectorIterator &ref) const { - return item_ <= ref.item_; - } - bool operator>=(const PointDVectorIterator &ref) const { - return item_ >= ref.item_; - } - - PointDVectorIterator operator+(const int32_t &add) const { - PointDVectorIterator copy(vec_, item_ + add); - return copy; - } - PointDVectorIterator &operator+=(const int32_t &add) { - item_ += add; - return *this; - } - PointDVectorIterator operator-(const int32_t &sub) const { - PointDVectorIterator copy(vec_, item_ - sub); - return copy; - } - size_t operator-(const PointDVectorIterator &sub) const { - return (item_ - sub.item_); - } - - PointDVectorIterator &operator-=(const int32_t &sub) { - item_ -= sub; - return *this; - } - - internal_t *operator[](const size_t &n) const { - return vec_->data0_ + (item_ + n) * dimensionality_; - } - - protected: - explicit PointDVectorIterator(PointDVector *vec, size_t start_item) - : item_(start_item), vec_(vec), dimensionality_(vec->dimensionality_) {} - - private: - size_t item_; // this counts the item that should be referenced. - PointDVector *const vec_; // the thing that we're iterating on - const uint32_t dimensionality_; // local copy from vec_ - }; - - PointDVectorIterator begin() { return PointDVectorIterator(this, 0); } - PointDVectorIterator end() { return PointDVectorIterator(this, n_items_); } - - // operator[] allows for unprotected user-side usage of operator[] on the - // return value AS IF it were a natively indexable type like Point3* - internal_t *operator[](const uint32_t index) { - DRACO_DCHECK_LT(index, n_items_); - return data0_ + index * dimensionality_; - } - const internal_t *operator[](const uint32_t index) const { - DRACO_DCHECK_LT(index, n_items_); - return data0_ + index * dimensionality_; - } - - uint32_t size() const { return n_items_; } - size_t GetBufferSize() const { return data_.size(); } - - // copy a single contiguous 'item' from one PointDVector into this one. - void CopyItem(const PointDVector &source, const internal_t source_index, - const internal_t destination_index) { - DRACO_DCHECK(&source != this || - (&source == this && source_index != destination_index)); - DRACO_DCHECK_LT(destination_index, n_items_); - DRACO_DCHECK_LT(source_index, source.n_items_); - - // DRACO_DCHECK_EQ(source.n_items_, n_items_); // not technically necessary - DRACO_DCHECK_EQ(source.dimensionality_, dimensionality_); - - const internal_t *ref = source[source_index]; - internal_t *const dest = this->operator[](destination_index); - std::memcpy(dest, ref, item_size_bytes_); - } - - // Copy data directly off of an attribute buffer interleaved into internal - // memory. - void CopyAttribute( - // The dimensionality of the attribute being integrated - const internal_t attribute_dimensionality, - // The offset in dimensions to insert this attribute. - const internal_t offset_dimensionality, const internal_t index, - // The direct pointer to the data - const void *const attribute_item_data) { - // chunk copy - const size_t copy_size = sizeof(internal_t) * attribute_dimensionality; - - // a multiply and add can be optimized away with an iterator - std::memcpy(data0_ + index * dimensionality_ + offset_dimensionality, - attribute_item_data, copy_size); - } - // Copy data off of a contiguous buffer interleaved into internal memory - void CopyAttribute( - // The dimensionality of the attribute being integrated - const internal_t attribute_dimensionality, - // The offset in dimensions to insert this attribute. - const internal_t offset_dimensionality, - const internal_t *const attribute_mem) { - DRACO_DCHECK_LT(offset_dimensionality, - dimensionality_ - attribute_dimensionality); - // degenerate case block copy the whole buffer. - if (dimensionality_ == attribute_dimensionality) { - DRACO_DCHECK_EQ(offset_dimensionality, 0); - const size_t copy_size = - sizeof(internal_t) * attribute_dimensionality * n_items_; - std::memcpy(data0_, attribute_mem, copy_size); - } else { // chunk copy - const size_t copy_size = sizeof(internal_t) * attribute_dimensionality; - internal_t *internal_data; - const internal_t *attribute_data; - internal_t item; - for (internal_data = data0_ + offset_dimensionality, - attribute_data = attribute_mem, item = 0; - item < n_items_; internal_data += dimensionality_, - attribute_data += attribute_dimensionality, item += 1) { - std::memcpy(internal_data, attribute_data, copy_size); - } - } - } - - private: - // internal parameters. - const uint32_t n_items_; - const uint32_t dimensionality_; // The dimension of the points in the buffer - const uint32_t item_size_bytes_; - std::vector data_; // contiguously stored data. Never resized. - internal_t *const data0_; // raw pointer to base data. -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_POINT_D_VECTOR_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/points_sequencer.h b/cloudreg_env/include/draco/compression/attributes/points_sequencer.h deleted file mode 100644 index 2f4f7e1..0000000 --- a/cloudreg_env/include/draco/compression/attributes/points_sequencer.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_POINTS_SEQUENCER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_POINTS_SEQUENCER_H_ - -#include - -#include "draco/attributes/point_attribute.h" - -namespace draco { - -// Class for generating a sequence of point ids that can be used to encode -// or decode attribute values in a specific order. -// See sequential_attribute_encoders/decoders_controller.h for more details. -class PointsSequencer { - public: - PointsSequencer() : out_point_ids_(nullptr) {} - virtual ~PointsSequencer() = default; - - // Fills the |out_point_ids| with the generated sequence of point ids. - bool GenerateSequence(std::vector *out_point_ids) { - out_point_ids_ = out_point_ids; - return GenerateSequenceInternal(); - } - - // Appends a point to the sequence. - void AddPointId(PointIndex point_id) { out_point_ids_->push_back(point_id); } - - // Sets the correct mapping between point ids and value ids. I.e., the inverse - // of the |out_point_ids|. In general, |out_point_ids_| does not contain - // sufficient information to compute the inverse map, because not all point - // ids are necessarily contained within the map. - // Must be implemented for sequencers that are used by attribute decoders. - virtual bool UpdatePointToAttributeIndexMapping(PointAttribute * /* attr */) { - return false; - } - - protected: - // Method that needs to be implemented by the derived classes. The - // implementation is responsible for filling |out_point_ids_| with the valid - // sequence of point ids. - virtual bool GenerateSequenceInternal() = 0; - std::vector *out_point_ids() const { return out_point_ids_; } - - private: - std::vector *out_point_ids_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_POINTS_SEQUENCER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h deleted file mode 100644 index b64b23d..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ - -#include -#include - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" -#include "draco/compression/bit_coders/rans_bit_decoder.h" -#include "draco/core/varint_decoding.h" - -namespace draco { - -// Decoder for predictions encoded with the constrained multi-parallelogram -// encoder. See the corresponding encoder for more details about the prediction -// method. -template -class MeshPredictionSchemeConstrainedMultiParallelogramDecoder - : public MeshPredictionSchemeDecoder { - public: - using CorrType = - typename PredictionSchemeDecoder::CorrType; - using CornerTable = typename MeshDataT::CornerTable; - - explicit MeshPredictionSchemeConstrainedMultiParallelogramDecoder( - const PointAttribute *attribute) - : MeshPredictionSchemeDecoder( - attribute), - selected_mode_(Mode::OPTIMAL_MULTI_PARALLELOGRAM) {} - MeshPredictionSchemeConstrainedMultiParallelogramDecoder( - const PointAttribute *attribute, const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeDecoder( - attribute, transform, mesh_data), - selected_mode_(Mode::OPTIMAL_MULTI_PARALLELOGRAM) {} - - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - - bool DecodePredictionData(DecoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM; - } - - bool IsInitialized() const override { - return this->mesh_data().IsInitialized(); - } - - private: - typedef constrained_multi_parallelogram::Mode Mode; - static constexpr int kMaxNumParallelograms = - constrained_multi_parallelogram::kMaxNumParallelograms; - // Crease edges are used to store whether any given edge should be used for - // parallelogram prediction or not. New values are added in the order in which - // the edges are processed. For better compression, the flags are stored in - // in separate contexts based on the number of available parallelograms at a - // given vertex. - std::vector is_crease_edge_[kMaxNumParallelograms]; - Mode selected_mode_; -}; - -template -bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder< - DataTypeT, TransformT, MeshDataT>:: - ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int /* size */, int num_components, - const PointIndex * /* entry_to_point_id_map */) { - this->transform().Init(num_components); - - // Predicted values for all simple parallelograms encountered at any given - // vertex. - std::vector pred_vals[kMaxNumParallelograms]; - for (int i = 0; i < kMaxNumParallelograms; ++i) { - pred_vals[i].resize(num_components, 0); - } - this->transform().ComputeOriginalValue(pred_vals[0].data(), in_corr, - out_data); - - const CornerTable *const table = this->mesh_data().corner_table(); - const std::vector *const vertex_to_data_map = - this->mesh_data().vertex_to_data_map(); - - // Current position in the |is_crease_edge_| array for each context. - std::vector is_crease_edge_pos(kMaxNumParallelograms, 0); - - // Used to store predicted value for multi-parallelogram prediction. - std::vector multi_pred_vals(num_components); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - for (int p = 1; p < corner_map_size; ++p) { - const CornerIndex start_corner_id = - this->mesh_data().data_to_corner_map()->at(p); - - CornerIndex corner_id(start_corner_id); - int num_parallelograms = 0; - bool first_pass = true; - while (corner_id != kInvalidCornerIndex) { - if (ComputeParallelogramPrediction( - p, corner_id, table, *vertex_to_data_map, out_data, - num_components, &(pred_vals[num_parallelograms][0]))) { - // Parallelogram prediction applied and stored in - // |pred_vals[num_parallelograms]| - ++num_parallelograms; - // Stop processing when we reach the maximum number of allowed - // parallelograms. - if (num_parallelograms == kMaxNumParallelograms) - break; - } - - // Proceed to the next corner attached to the vertex. First swing left - // and if we reach a boundary, swing right from the start corner. - if (first_pass) { - corner_id = table->SwingLeft(corner_id); - } else { - corner_id = table->SwingRight(corner_id); - } - if (corner_id == start_corner_id) { - break; - } - if (corner_id == kInvalidCornerIndex && first_pass) { - first_pass = false; - corner_id = table->SwingRight(start_corner_id); - } - } - - // Check which of the available parallelograms are actually used and compute - // the final predicted value. - int num_used_parallelograms = 0; - if (num_parallelograms > 0) { - for (int i = 0; i < num_components; ++i) { - multi_pred_vals[i] = 0; - } - // Check which parallelograms are actually used. - for (int i = 0; i < num_parallelograms; ++i) { - const int context = num_parallelograms - 1; - const int pos = is_crease_edge_pos[context]++; - if (is_crease_edge_[context].size() <= pos) - return false; - const bool is_crease = is_crease_edge_[context][pos]; - if (!is_crease) { - ++num_used_parallelograms; - for (int j = 0; j < num_components; ++j) { - multi_pred_vals[j] += pred_vals[i][j]; - } - } - } - } - const int dst_offset = p * num_components; - if (num_used_parallelograms == 0) { - // No parallelogram was valid. - // We use the last decoded point as a reference. - const int src_offset = (p - 1) * num_components; - this->transform().ComputeOriginalValue( - out_data + src_offset, in_corr + dst_offset, out_data + dst_offset); - } else { - // Compute the correction from the predicted value. - for (int c = 0; c < num_components; ++c) { - multi_pred_vals[c] /= num_used_parallelograms; - } - this->transform().ComputeOriginalValue( - multi_pred_vals.data(), in_corr + dst_offset, out_data + dst_offset); - } - } - return true; -} - -template -bool MeshPredictionSchemeConstrainedMultiParallelogramDecoder< - DataTypeT, TransformT, MeshDataT>::DecodePredictionData(DecoderBuffer - *buffer) { -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - // Decode prediction mode. - uint8_t mode; - if (!buffer->Decode(&mode)) { - return false; - } - - if (mode != Mode::OPTIMAL_MULTI_PARALLELOGRAM) { - // Unsupported mode. - return false; - } - } -#endif - - // Encode selected edges using separate rans bit coder for each context. - for (int i = 0; i < kMaxNumParallelograms; ++i) { - uint32_t num_flags; - DecodeVarint(&num_flags, buffer); - if (num_flags > 0) { - is_crease_edge_[i].resize(num_flags); - RAnsBitDecoder decoder; - if (!decoder.StartDecoding(buffer)) - return false; - for (uint32_t j = 0; j < num_flags; ++j) { - is_crease_edge_[i][j] = decoder.DecodeNextBit(); - } - decoder.EndDecoding(); - } - } - return MeshPredictionSchemeDecoder::DecodePredictionData(buffer); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h deleted file mode 100644 index 455c2ce..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_ENCODER_H_ - -#include -#include - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" -#include "draco/compression/bit_coders/rans_bit_encoder.h" -#include "draco/compression/entropy/shannon_entropy.h" -#include "draco/core/varint_encoding.h" - -namespace draco { - -// Compared to standard multi-parallelogram, constrained multi-parallelogram can -// explicitly select which of the available parallelograms are going to be used -// for the prediction by marking crease edges between two triangles. This -// requires storing extra data, but it allows the predictor to avoid using -// parallelograms that would lead to poor predictions. For improved efficiency, -// our current implementation limits the maximum number of used parallelograms -// to four, which covers >95% of the cases (on average, there are only two -// parallelograms available for any given vertex). -// All bits of the explicitly chosen configuration are stored together in a -// single context chosen by the total number of parallelograms available to -// choose from. -template -class MeshPredictionSchemeConstrainedMultiParallelogramEncoder - : public MeshPredictionSchemeEncoder { - public: - using CorrType = - typename PredictionSchemeEncoder::CorrType; - using CornerTable = typename MeshDataT::CornerTable; - - explicit MeshPredictionSchemeConstrainedMultiParallelogramEncoder( - const PointAttribute *attribute) - : MeshPredictionSchemeEncoder( - attribute), - selected_mode_(Mode::OPTIMAL_MULTI_PARALLELOGRAM) {} - MeshPredictionSchemeConstrainedMultiParallelogramEncoder( - const PointAttribute *attribute, const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeEncoder( - attribute, transform, mesh_data), - selected_mode_(Mode::OPTIMAL_MULTI_PARALLELOGRAM) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - - bool EncodePredictionData(EncoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM; - } - - bool IsInitialized() const override { - return this->mesh_data().IsInitialized(); - } - - private: - // Function used to compute number of bits needed to store overhead of the - // predictor. In this case, we consider overhead to be all bits that mark - // whether a parallelogram should be used for prediction or not. The input - // to this method is the total number of parallelograms that were evaluated so - // far(total_parallelogram), and the number of parallelograms we decided to - // use for prediction (total_used_parallelograms). - // Returns number of bits required to store the overhead. - int64_t ComputeOverheadBits(int64_t total_used_parallelograms, - int64_t total_parallelogram) const { - // For now we assume RAns coding for the bits where the total required size - // is directly correlated to the binary entropy of the input stream. - // TODO(ostava): This should be generalized in case we use other binary - // coding scheme. - const double entropy = ComputeBinaryShannonEntropy( - static_cast(total_parallelogram), - static_cast(total_used_parallelograms)); - - // Round up to the nearest full bit. - return static_cast( - ceil(static_cast(total_parallelogram) * entropy)); - } - - // Struct that contains data used for measuring the error of each available - // parallelogram configuration. - struct Error { - Error() : num_bits(0), residual_error(0) {} - - // Primary metric: number of bits required to store the data as a result of - // the selected prediction configuration. - int num_bits; - // Secondary metric: absolute difference of residuals for the given - // configuration. - int residual_error; - - bool operator<(const Error &e) const { - if (num_bits < e.num_bits) - return true; - if (num_bits > e.num_bits) - return false; - return residual_error < e.residual_error; - } - }; - - // Computes error for predicting |predicted_val| instead of |actual_val|. - // Error is computed as the number of bits needed to encode the difference - // between the values. - Error ComputeError(const DataTypeT *predicted_val, - const DataTypeT *actual_val, int *out_residuals, - int num_components) { - Error error; - - for (int i = 0; i < num_components; ++i) { - const int dif = (predicted_val[i] - actual_val[i]); - error.residual_error += std::abs(dif); - out_residuals[i] = dif; - // Entropy needs unsigned symbols, so convert the signed difference to an - // unsigned symbol. - entropy_symbols_[i] = ConvertSignedIntToSymbol(dif); - } - - // Generate entropy data for case that this configuration was used. - // Note that the entropy stream is NOT updated in this case. - const auto entropy_data = - entropy_tracker_.Peek(entropy_symbols_.data(), num_components); - - error.num_bits = entropy_tracker_.GetNumberOfDataBits(entropy_data) + - entropy_tracker_.GetNumberOfRAnsTableBits(entropy_data); - return error; - } - - typedef constrained_multi_parallelogram::Mode Mode; - static constexpr int kMaxNumParallelograms = - constrained_multi_parallelogram::kMaxNumParallelograms; - // Crease edges are used to store whether any given edge should be used for - // parallelogram prediction or not. New values are added in the order in which - // the edges are processed. For better compression, the flags are stored in - // in separate contexts based on the number of available parallelograms at a - // given vertex. - // TODO(draco-eng) reconsider std::vector (performance/space). - std::vector is_crease_edge_[kMaxNumParallelograms]; - Mode selected_mode_; - - ShannonEntropyTracker entropy_tracker_; - - // Temporary storage for symbols that are fed into the |entropy_stream|. - // Always contains only |num_components| entries. - std::vector entropy_symbols_; -}; - -template -bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder< - DataTypeT, TransformT, MeshDataT>:: - ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, - int size, int num_components, - const PointIndex * /* entry_to_point_id_map */) { - this->transform().Init(in_data, size, num_components); - const CornerTable *const table = this->mesh_data().corner_table(); - const std::vector *const vertex_to_data_map = - this->mesh_data().vertex_to_data_map(); - - // Predicted values for all simple parallelograms encountered at any given - // vertex. - std::vector pred_vals[kMaxNumParallelograms]; - for (int i = 0; i < kMaxNumParallelograms; ++i) { - pred_vals[i].resize(num_components); - } - // Used to store predicted value for various multi-parallelogram predictions - // (combinations of simple parallelogram predictions). - std::vector multi_pred_vals(num_components); - entropy_symbols_.resize(num_components); - - // Struct for holding data about prediction configuration for different sets - // of used parallelograms. - struct PredictionConfiguration { - PredictionConfiguration() - : error(), configuration(0), num_used_parallelograms(0) {} - Error error; - uint8_t configuration; // Bitfield, 1 use parallelogram, 0 don't use it. - int num_used_parallelograms; - std::vector predicted_value; - std::vector residuals; - }; - - // Bit-field used for computing permutations of excluded edges - // (parallelograms). - bool exluded_parallelograms[kMaxNumParallelograms]; - - // Data about the number of used parallelogram and total number of available - // parallelogram for each context. Used to compute overhead needed for storing - // the parallelogram choices made by the encoder. - int64_t total_used_parallelograms[kMaxNumParallelograms] = {0}; - int64_t total_parallelograms[kMaxNumParallelograms] = {0}; - - std::vector current_residuals(num_components); - - // We start processing the vertices from the end because this prediction uses - // data from previous entries that could be overwritten when an entry is - // processed. - for (int p = - static_cast(this->mesh_data().data_to_corner_map()->size()) - 1; - p > 0; --p) { - const CornerIndex start_corner_id = - this->mesh_data().data_to_corner_map()->at(p); - - // Go over all corners attached to the vertex and compute the predicted - // value from the parallelograms defined by their opposite faces. - CornerIndex corner_id(start_corner_id); - int num_parallelograms = 0; - bool first_pass = true; - while (corner_id != kInvalidCornerIndex) { - if (ComputeParallelogramPrediction( - p, corner_id, table, *vertex_to_data_map, in_data, num_components, - &(pred_vals[num_parallelograms][0]))) { - // Parallelogram prediction applied and stored in - // |pred_vals[num_parallelograms]| - ++num_parallelograms; - // Stop processing when we reach the maximum number of allowed - // parallelograms. - if (num_parallelograms == kMaxNumParallelograms) - break; - } - - // Proceed to the next corner attached to the vertex. First swing left - // and if we reach a boundary, swing right from the start corner. - if (first_pass) { - corner_id = table->SwingLeft(corner_id); - } else { - corner_id = table->SwingRight(corner_id); - } - if (corner_id == start_corner_id) { - break; - } - if (corner_id == kInvalidCornerIndex && first_pass) { - first_pass = false; - corner_id = table->SwingRight(start_corner_id); - } - } - - // Offset to the target (destination) vertex. - const int dst_offset = p * num_components; - Error error; - - // Compute all prediction errors for all possible configurations of - // available parallelograms. - - // Variable for holding the best configuration that has been found so far. - PredictionConfiguration best_prediction; - - // Compute delta coding error (configuration when no parallelogram is - // selected). - const int src_offset = (p - 1) * num_components; - error = ComputeError(in_data + src_offset, in_data + dst_offset, - ¤t_residuals[0], num_components); - - if (num_parallelograms > 0) { - total_parallelograms[num_parallelograms - 1] += num_parallelograms; - const int64_t new_overhead_bits = - ComputeOverheadBits(total_used_parallelograms[num_parallelograms - 1], - total_parallelograms[num_parallelograms - 1]); - error.num_bits += new_overhead_bits; - } - - best_prediction.error = error; - best_prediction.configuration = 0; - best_prediction.num_used_parallelograms = 0; - best_prediction.predicted_value.assign( - in_data + src_offset, in_data + src_offset + num_components); - best_prediction.residuals.assign(current_residuals.begin(), - current_residuals.end()); - - // Compute prediction error for different cases of used parallelograms. - for (int num_used_parallelograms = 1; - num_used_parallelograms <= num_parallelograms; - ++num_used_parallelograms) { - // Mark all parallelograms as excluded. - std::fill(exluded_parallelograms, - exluded_parallelograms + num_parallelograms, true); - // TODO(draco-eng) maybe this should be another std::fill. - // Mark the first |num_used_parallelograms| as not excluded. - for (int j = 0; j < num_used_parallelograms; ++j) { - exluded_parallelograms[j] = false; - } - // Permute over the excluded edges and compute error for each - // configuration (permutation of excluded parallelograms). - do { - // Reset the multi-parallelogram predicted values. - for (int j = 0; j < num_components; ++j) { - multi_pred_vals[j] = 0; - } - uint8_t configuration = 0; - for (int j = 0; j < num_parallelograms; ++j) { - if (exluded_parallelograms[j]) - continue; - for (int c = 0; c < num_components; ++c) { - multi_pred_vals[c] += pred_vals[j][c]; - } - // Set jth bit of the configuration. - configuration |= (1 << j); - } - - for (int j = 0; j < num_components; ++j) { - multi_pred_vals[j] /= num_used_parallelograms; - } - error = ComputeError(multi_pred_vals.data(), in_data + dst_offset, - ¤t_residuals[0], num_components); - if (num_parallelograms > 0) { - const int64_t new_overhead_bits = ComputeOverheadBits( - total_used_parallelograms[num_parallelograms - 1] + - num_used_parallelograms, - total_parallelograms[num_parallelograms - 1]); - - // Add overhead bits to the total error. - error.num_bits += new_overhead_bits; - } - if (error < best_prediction.error) { - best_prediction.error = error; - best_prediction.configuration = configuration; - best_prediction.num_used_parallelograms = num_used_parallelograms; - best_prediction.predicted_value.assign(multi_pred_vals.begin(), - multi_pred_vals.end()); - best_prediction.residuals.assign(current_residuals.begin(), - current_residuals.end()); - } - } while (std::next_permutation( - exluded_parallelograms, exluded_parallelograms + num_parallelograms)); - } - if (num_parallelograms > 0) { - total_used_parallelograms[num_parallelograms - 1] += - best_prediction.num_used_parallelograms; - } - - // Update the entropy stream by adding selected residuals as symbols to the - // stream. - for (int i = 0; i < num_components; ++i) { - entropy_symbols_[i] = - ConvertSignedIntToSymbol(best_prediction.residuals[i]); - } - entropy_tracker_.Push(entropy_symbols_.data(), num_components); - - for (int i = 0; i < num_parallelograms; ++i) { - if ((best_prediction.configuration & (1 << i)) == 0) { - // Parallelogram not used, mark the edge as crease. - is_crease_edge_[num_parallelograms - 1].push_back(true); - } else { - // Parallelogram used. Add it to the predicted value and mark the - // edge as not a crease. - is_crease_edge_[num_parallelograms - 1].push_back(false); - } - } - this->transform().ComputeCorrection(in_data + dst_offset, - best_prediction.predicted_value.data(), - out_corr + dst_offset); - } - // First element is always fixed because it cannot be predicted. - for (int i = 0; i < num_components; ++i) { - pred_vals[0][i] = static_cast(0); - } - this->transform().ComputeCorrection(in_data, pred_vals[0].data(), out_corr); - return true; -} - -template -bool MeshPredictionSchemeConstrainedMultiParallelogramEncoder< - DataTypeT, TransformT, MeshDataT>::EncodePredictionData(EncoderBuffer - *buffer) { - // Encode selected edges using separate rans bit coder for each context. - for (int i = 0; i < kMaxNumParallelograms; ++i) { - // |i| is the context based on the number of available parallelograms, which - // is always equal to |i + 1|. - const int num_used_parallelograms = i + 1; - EncodeVarint(is_crease_edge_[i].size(), buffer); - if (is_crease_edge_[i].size()) { - RAnsBitEncoder encoder; - encoder.StartEncoding(); - // Encode the crease edge flags in the reverse vertex order that is needed - // be the decoder. Note that for the currently supported mode, each vertex - // has exactly |num_used_parallelograms| edges that need to be encoded. - for (int j = static_cast(is_crease_edge_[i].size()) - - num_used_parallelograms; - j >= 0; j -= num_used_parallelograms) { - // Go over all edges of the current vertex. - for (int k = 0; k < num_used_parallelograms; ++k) { - encoder.EncodeBit(is_crease_edge_[i][j + k]); - } - } - encoder.EndEncoding(buffer); - } - } - return MeshPredictionSchemeEncoder::EncodePredictionData(buffer); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h deleted file mode 100644 index c7a4e35..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_SHARED_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_SHARED_H_ - -namespace draco { - -// Data shared between constrained multi-parallelogram encoder and decoder. -namespace constrained_multi_parallelogram { - -enum Mode { - // Selects the optimal multi-parallelogram from up to 4 available - // parallelograms. - OPTIMAL_MULTI_PARALLELOGRAM = 0, -}; - -static constexpr int kMaxNumParallelograms = 4; - -} // namespace constrained_multi_parallelogram -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_CONSTRAINED_MULTI_PARALLELOGRAM_SHARED_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h deleted file mode 100644 index f712952..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_MESH_PREDICTION_SCHEMES_PREDICTION_SCHEME_DATA_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_MESH_PREDICTION_SCHEMES_PREDICTION_SCHEME_DATA_H_ - -#include "draco/mesh/corner_table.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Class stores data about the connectivity data of the mesh and information -// about how the connectivity was encoded/decoded. -template -class MeshPredictionSchemeData { - public: - typedef CornerTableT CornerTable; - MeshPredictionSchemeData() - : mesh_(nullptr), - corner_table_(nullptr), - vertex_to_data_map_(nullptr), - data_to_corner_map_(nullptr) {} - - void Set(const Mesh *mesh, const CornerTable *table, - const std::vector *data_to_corner_map, - const std::vector *vertex_to_data_map) { - mesh_ = mesh; - corner_table_ = table; - data_to_corner_map_ = data_to_corner_map; - vertex_to_data_map_ = vertex_to_data_map; - } - - const Mesh *mesh() const { return mesh_; } - const CornerTable *corner_table() const { return corner_table_; } - const std::vector *vertex_to_data_map() const { - return vertex_to_data_map_; - } - const std::vector *data_to_corner_map() const { - return data_to_corner_map_; - } - bool IsInitialized() const { - return mesh_ != nullptr && corner_table_ != nullptr && - vertex_to_data_map_ != nullptr && data_to_corner_map_ != nullptr; - } - - private: - const Mesh *mesh_; - const CornerTable *corner_table_; - - // Mapping between vertices and their encoding order. I.e. when an attribute - // entry on a given vertex was encoded. - const std::vector *vertex_to_data_map_; - - // Array that stores which corner was processed when a given attribute entry - // was encoded or decoded. - const std::vector *data_to_corner_map_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DATA_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h deleted file mode 100644 index 6694a98..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DECODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h" - -namespace draco { - -// Base class for all mesh prediction scheme decoders that use the mesh -// connectivity data. |MeshDataT| can be any class that provides the same -// interface as the PredictionSchemeMeshData class. -template -class MeshPredictionSchemeDecoder - : public PredictionSchemeDecoder { - public: - typedef MeshDataT MeshData; - MeshPredictionSchemeDecoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : PredictionSchemeDecoder(attribute, transform), - mesh_data_(mesh_data) {} - - protected: - const MeshData &mesh_data() const { return mesh_data_; } - - private: - MeshData mesh_data_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h deleted file mode 100644 index ab3c81a..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h" - -namespace draco { - -// Base class for all mesh prediction scheme encoders that use the mesh -// connectivity data. |MeshDataT| can be any class that provides the same -// interface as the PredictionSchemeMeshData class. -template -class MeshPredictionSchemeEncoder - : public PredictionSchemeEncoder { - public: - typedef MeshDataT MeshData; - MeshPredictionSchemeEncoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : PredictionSchemeEncoder(attribute, transform), - mesh_data_(mesh_data) {} - - protected: - const MeshData &mesh_data() const { return mesh_data_; } - - private: - MeshData mesh_data_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h deleted file mode 100644 index cd82996..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" -#include "draco/compression/bit_coders/rans_bit_decoder.h" - -namespace draco { - -// See MeshPredictionSchemeGeometricNormalEncoder for documentation. -template -class MeshPredictionSchemeGeometricNormalDecoder - : public MeshPredictionSchemeDecoder { - public: - using CorrType = typename MeshPredictionSchemeDecoder::CorrType; - MeshPredictionSchemeGeometricNormalDecoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeDecoder( - attribute, transform, mesh_data), - predictor_(mesh_data) {} - - private: - MeshPredictionSchemeGeometricNormalDecoder() {} - - public: - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - - bool DecodePredictionData(DecoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_GEOMETRIC_NORMAL; - } - - bool IsInitialized() const override { - if (!predictor_.IsInitialized()) - return false; - if (!this->mesh_data().IsInitialized()) - return false; - if (!octahedron_tool_box_.IsInitialized()) - return false; - return true; - } - - int GetNumParentAttributes() const override { return 1; } - - GeometryAttribute::Type GetParentAttributeType(int i) const override { - DRACO_DCHECK_EQ(i, 0); - (void)i; - return GeometryAttribute::POSITION; - } - - bool SetParentAttribute(const PointAttribute *att) override { - if (att->attribute_type() != GeometryAttribute::POSITION) - return false; // Invalid attribute type. - if (att->num_components() != 3) - return false; // Currently works only for 3 component positions. - predictor_.SetPositionAttribute(*att); - return true; - } - void SetQuantizationBits(int q) { - octahedron_tool_box_.SetQuantizationBits(q); - } - - private: - MeshPredictionSchemeGeometricNormalPredictorArea - predictor_; - OctahedronToolBox octahedron_tool_box_; - RAnsBitDecoder flip_normal_bit_decoder_; -}; - -template -bool MeshPredictionSchemeGeometricNormalDecoder< - DataTypeT, TransformT, - MeshDataT>::ComputeOriginalValues(const CorrType *in_corr, - DataTypeT *out_data, int /* size */, - int num_components, - const PointIndex *entry_to_point_id_map) { - this->SetQuantizationBits(this->transform().quantization_bits()); - predictor_.SetEntryToPointIdMap(entry_to_point_id_map); - DRACO_DCHECK(this->IsInitialized()); - - // Expecting in_data in octahedral coordinates, i.e., portable attribute. - DRACO_DCHECK_EQ(num_components, 2); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - - VectorD pred_normal_3d; - int32_t pred_normal_oct[2]; - - for (int data_id = 0; data_id < corner_map_size; ++data_id) { - const CornerIndex corner_id = - this->mesh_data().data_to_corner_map()->at(data_id); - predictor_.ComputePredictedValue(corner_id, pred_normal_3d.data()); - - // Compute predicted octahedral coordinates. - octahedron_tool_box_.CanonicalizeIntegerVector(pred_normal_3d.data()); - DRACO_DCHECK_EQ(pred_normal_3d.AbsSum(), - octahedron_tool_box_.center_value()); - if (flip_normal_bit_decoder_.DecodeNextBit()) { - pred_normal_3d = -pred_normal_3d; - } - octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords( - pred_normal_3d.data(), pred_normal_oct, pred_normal_oct + 1); - - const int data_offset = data_id * 2; - this->transform().ComputeOriginalValue( - pred_normal_oct, in_corr + data_offset, out_data + data_offset); - } - flip_normal_bit_decoder_.EndDecoding(); - return true; -} - -template -bool MeshPredictionSchemeGeometricNormalDecoder< - DataTypeT, TransformT, MeshDataT>::DecodePredictionData(DecoderBuffer - *buffer) { - // Get data needed for transform - if (!this->transform().DecodeTransformData(buffer)) - return false; - -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - uint8_t prediction_mode; - buffer->Decode(&prediction_mode); - - if (!predictor_.SetNormalPredictionMode( - NormalPredictionMode(prediction_mode))) - return false; - } -#endif - - // Init normal flips. - if (!flip_normal_bit_decoder_.StartDecoding(buffer)) - return false; - - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h deleted file mode 100644 index ffddf01..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" -#include "draco/compression/bit_coders/rans_bit_encoder.h" -#include "draco/compression/config/compression_shared.h" - -namespace draco { - -// Prediction scheme for normals based on the underlying geometry. -// At a smooth vertices normals are computed by weighting the normals of -// adjacent faces with the area of these faces. At seams, the same approach -// applies for seam corners. -template -class MeshPredictionSchemeGeometricNormalEncoder - : public MeshPredictionSchemeEncoder { - public: - using CorrType = typename MeshPredictionSchemeEncoder::CorrType; - MeshPredictionSchemeGeometricNormalEncoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeEncoder( - attribute, transform, mesh_data), - predictor_(mesh_data) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - - bool EncodePredictionData(EncoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_GEOMETRIC_NORMAL; - } - - bool IsInitialized() const override { - if (!predictor_.IsInitialized()) - return false; - if (!this->mesh_data().IsInitialized()) - return false; - return true; - } - - int GetNumParentAttributes() const override { return 1; } - - GeometryAttribute::Type GetParentAttributeType(int i) const override { - DRACO_DCHECK_EQ(i, 0); - (void)i; - return GeometryAttribute::POSITION; - } - - bool SetParentAttribute(const PointAttribute *att) override { - if (att->attribute_type() != GeometryAttribute::POSITION) - return false; // Invalid attribute type. - if (att->num_components() != 3) - return false; // Currently works only for 3 component positions. - predictor_.SetPositionAttribute(*att); - return true; - } - - private: - void SetQuantizationBits(int q) { - DRACO_DCHECK_GE(q, 2); - DRACO_DCHECK_LE(q, 30); - octahedron_tool_box_.SetQuantizationBits(q); - } - MeshPredictionSchemeGeometricNormalPredictorArea - predictor_; - - OctahedronToolBox octahedron_tool_box_; - RAnsBitEncoder flip_normal_bit_encoder_; -}; - -template -bool MeshPredictionSchemeGeometricNormalEncoder:: - ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, - int size, int num_components, - const PointIndex *entry_to_point_id_map) { - this->SetQuantizationBits(this->transform().quantization_bits()); - predictor_.SetEntryToPointIdMap(entry_to_point_id_map); - DRACO_DCHECK(this->IsInitialized()); - // Expecting in_data in octahedral coordinates, i.e., portable attribute. - DRACO_DCHECK_EQ(num_components, 2); - - flip_normal_bit_encoder_.StartEncoding(); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - - VectorD pred_normal_3d; - VectorD pos_pred_normal_oct; - VectorD neg_pred_normal_oct; - VectorD pos_correction; - VectorD neg_correction; - for (int data_id = 0; data_id < corner_map_size; ++data_id) { - const CornerIndex corner_id = - this->mesh_data().data_to_corner_map()->at(data_id); - predictor_.ComputePredictedValue(corner_id, pred_normal_3d.data()); - - // Compute predicted octahedral coordinates. - octahedron_tool_box_.CanonicalizeIntegerVector(pred_normal_3d.data()); - DRACO_DCHECK_EQ(pred_normal_3d.AbsSum(), - octahedron_tool_box_.center_value()); - - // Compute octahedral coordinates for both possible directions. - octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords( - pred_normal_3d.data(), pos_pred_normal_oct.data(), - pos_pred_normal_oct.data() + 1); - pred_normal_3d = -pred_normal_3d; - octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords( - pred_normal_3d.data(), neg_pred_normal_oct.data(), - neg_pred_normal_oct.data() + 1); - - // Choose the one with the best correction value. - const int data_offset = data_id * 2; - this->transform().ComputeCorrection(in_data + data_offset, - pos_pred_normal_oct.data(), - pos_correction.data()); - this->transform().ComputeCorrection(in_data + data_offset, - neg_pred_normal_oct.data(), - neg_correction.data()); - pos_correction[0] = octahedron_tool_box_.ModMax(pos_correction[0]); - pos_correction[1] = octahedron_tool_box_.ModMax(pos_correction[1]); - neg_correction[0] = octahedron_tool_box_.ModMax(neg_correction[0]); - neg_correction[1] = octahedron_tool_box_.ModMax(neg_correction[1]); - if (pos_correction.AbsSum() < neg_correction.AbsSum()) { - flip_normal_bit_encoder_.EncodeBit(false); - (out_corr + data_offset)[0] = - octahedron_tool_box_.MakePositive(pos_correction[0]); - (out_corr + data_offset)[1] = - octahedron_tool_box_.MakePositive(pos_correction[1]); - } else { - flip_normal_bit_encoder_.EncodeBit(true); - (out_corr + data_offset)[0] = - octahedron_tool_box_.MakePositive(neg_correction[0]); - (out_corr + data_offset)[1] = - octahedron_tool_box_.MakePositive(neg_correction[1]); - } - } - return true; -} - -template -bool MeshPredictionSchemeGeometricNormalEncoder< - DataTypeT, TransformT, MeshDataT>::EncodePredictionData(EncoderBuffer - *buffer) { - if (!this->transform().EncodeTransformData(buffer)) - return false; - - // Encode normal flips. - flip_normal_bit_encoder_.EndEncoding(buffer); - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h deleted file mode 100644 index bf1a614..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_AREA_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_AREA_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h" - -namespace draco { - -// This predictor estimates the normal via the surrounding triangles of the -// given corner. Triangles are weighted according to their area. -template -class MeshPredictionSchemeGeometricNormalPredictorArea - : public MeshPredictionSchemeGeometricNormalPredictorBase< - DataTypeT, TransformT, MeshDataT> { - typedef MeshPredictionSchemeGeometricNormalPredictorBase< - DataTypeT, TransformT, MeshDataT> - Base; - - public: - explicit MeshPredictionSchemeGeometricNormalPredictorArea(const MeshDataT &md) - : Base(md) { - this->SetNormalPredictionMode(TRIANGLE_AREA); - }; - virtual ~MeshPredictionSchemeGeometricNormalPredictorArea() {} - - // Computes predicted octahedral coordinates on a given corner. - void ComputePredictedValue(CornerIndex corner_id, - DataTypeT *prediction) override { - DRACO_DCHECK(this->IsInitialized()); - typedef typename MeshDataT::CornerTable CornerTable; - const CornerTable *const corner_table = this->mesh_data_.corner_table(); - // Going to compute the predicted normal from the surrounding triangles - // according to the connectivity of the given corner table. - VertexCornersIterator cit(corner_table, corner_id); - // Position of central vertex does not change in loop. - const VectorD pos_cent = this->GetPositionForCorner(corner_id); - // Computing normals for triangles and adding them up. - - VectorD normal; - CornerIndex c_next, c_prev; - while (!cit.End()) { - // Getting corners. - if (this->normal_prediction_mode_ == ONE_TRIANGLE) { - c_next = corner_table->Next(corner_id); - c_prev = corner_table->Previous(corner_id); - } else { - c_next = corner_table->Next(cit.Corner()); - c_prev = corner_table->Previous(cit.Corner()); - } - const VectorD pos_next = this->GetPositionForCorner(c_next); - const VectorD pos_prev = this->GetPositionForCorner(c_prev); - - // Computing delta vectors to next and prev. - const VectorD delta_next = pos_next - pos_cent; - const VectorD delta_prev = pos_prev - pos_cent; - - // Computing cross product. - const VectorD cross = CrossProduct(delta_next, delta_prev); - normal = normal + cross; - cit.Next(); - } - - // Convert to int32_t, make sure entries are not too large. - constexpr int64_t upper_bound = 1 << 29; - if (this->normal_prediction_mode_ == ONE_TRIANGLE) { - const int32_t abs_sum = static_cast(normal.AbsSum()); - if (abs_sum > upper_bound) { - const int64_t quotient = abs_sum / upper_bound; - normal = normal / quotient; - } - } else { - const int64_t abs_sum = normal.AbsSum(); - if (abs_sum > upper_bound) { - const int64_t quotient = abs_sum / upper_bound; - normal = normal / quotient; - } - } - DRACO_DCHECK_LE(normal.AbsSum(), upper_bound); - prediction[0] = static_cast(normal[0]); - prediction[1] = static_cast(normal[1]); - prediction[2] = static_cast(normal[2]); - } - bool SetNormalPredictionMode(NormalPredictionMode mode) override { - if (mode == ONE_TRIANGLE) { - this->normal_prediction_mode_ = mode; - return true; - } else if (mode == TRIANGLE_AREA) { - this->normal_prediction_mode_ = mode; - return true; - } - return false; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_AREA_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h deleted file mode 100644 index 9a26551..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_ - -#include - -#include "draco/attributes/point_attribute.h" -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/core/math_utils.h" -#include "draco/core/vector_d.h" -#include "draco/mesh/corner_table.h" -#include "draco/mesh/corner_table_iterators.h" - -namespace draco { - -// Base class for geometric normal predictors using position attribute. -template -class MeshPredictionSchemeGeometricNormalPredictorBase { - protected: - explicit MeshPredictionSchemeGeometricNormalPredictorBase(const MeshDataT &md) - : pos_attribute_(nullptr), - entry_to_point_id_map_(nullptr), - mesh_data_(md) {} - virtual ~MeshPredictionSchemeGeometricNormalPredictorBase() {} - - public: - void SetPositionAttribute(const PointAttribute &position_attribute) { - pos_attribute_ = &position_attribute; - } - void SetEntryToPointIdMap(const PointIndex *map) { - entry_to_point_id_map_ = map; - } - bool IsInitialized() const { - if (pos_attribute_ == nullptr) - return false; - if (entry_to_point_id_map_ == nullptr) - return false; - return true; - } - - virtual bool SetNormalPredictionMode(NormalPredictionMode mode) = 0; - virtual NormalPredictionMode GetNormalPredictionMode() const { - return normal_prediction_mode_; - } - - protected: - VectorD GetPositionForDataId(int data_id) const { - DRACO_DCHECK(this->IsInitialized()); - const auto point_id = entry_to_point_id_map_[data_id]; - const auto pos_val_id = pos_attribute_->mapped_index(point_id); - VectorD pos; - pos_attribute_->ConvertValue(pos_val_id, &pos[0]); - return pos; - } - VectorD GetPositionForCorner(CornerIndex ci) const { - DRACO_DCHECK(this->IsInitialized()); - const auto corner_table = mesh_data_.corner_table(); - const auto vert_id = corner_table->Vertex(ci).value(); - const auto data_id = mesh_data_.vertex_to_data_map()->at(vert_id); - return GetPositionForDataId(data_id); - } - VectorD GetOctahedralCoordForDataId(int data_id, - const DataTypeT *data) const { - DRACO_DCHECK(this->IsInitialized()); - const int data_offset = data_id * 2; - return VectorD(data[data_offset], data[data_offset + 1]); - } - // Computes predicted octahedral coordinates on a given corner. - virtual void ComputePredictedValue(CornerIndex corner_id, - DataTypeT *prediction) = 0; - - const PointAttribute *pos_attribute_; - const PointIndex *entry_to_point_id_map_; - MeshDataT mesh_data_; - NormalPredictionMode normal_prediction_mode_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h deleted file mode 100644 index a0cc802..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_MULTI_PARALLELOGRAM_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_MULTI_PARALLELOGRAM_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" - -namespace draco { - -// Decoder for predictions encoded by multi-parallelogram encoding scheme. -// See the corresponding encoder for method description. -template -class MeshPredictionSchemeMultiParallelogramDecoder - : public MeshPredictionSchemeDecoder { - public: - using CorrType = - typename PredictionSchemeDecoder::CorrType; - using CornerTable = typename MeshDataT::CornerTable; - - explicit MeshPredictionSchemeMultiParallelogramDecoder( - const PointAttribute *attribute) - : MeshPredictionSchemeDecoder( - attribute) {} - MeshPredictionSchemeMultiParallelogramDecoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeDecoder( - attribute, transform, mesh_data) {} - - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_MULTI_PARALLELOGRAM; - } - - bool IsInitialized() const override { - return this->mesh_data().IsInitialized(); - } -}; - -template -bool MeshPredictionSchemeMultiParallelogramDecoder:: - ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int /* size */, int num_components, - const PointIndex * /* entry_to_point_id_map */) { - this->transform().Init(num_components); - - // For storage of prediction values (already initialized to zero). - std::unique_ptr pred_vals(new DataTypeT[num_components]()); - std::unique_ptr parallelogram_pred_vals( - new DataTypeT[num_components]()); - - this->transform().ComputeOriginalValue(pred_vals.get(), in_corr, out_data); - - const CornerTable *const table = this->mesh_data().corner_table(); - const std::vector *const vertex_to_data_map = - this->mesh_data().vertex_to_data_map(); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - for (int p = 1; p < corner_map_size; ++p) { - const CornerIndex start_corner_id = - this->mesh_data().data_to_corner_map()->at(p); - - CornerIndex corner_id(start_corner_id); - int num_parallelograms = 0; - for (int i = 0; i < num_components; ++i) { - pred_vals[i] = static_cast(0); - } - while (corner_id != kInvalidCornerIndex) { - if (ComputeParallelogramPrediction( - p, corner_id, table, *vertex_to_data_map, out_data, - num_components, parallelogram_pred_vals.get())) { - for (int c = 0; c < num_components; ++c) { - pred_vals[c] += parallelogram_pred_vals[c]; - } - ++num_parallelograms; - } - - // Proceed to the next corner attached to the vertex. - corner_id = table->SwingRight(corner_id); - if (corner_id == start_corner_id) { - corner_id = kInvalidCornerIndex; - } - } - - const int dst_offset = p * num_components; - if (num_parallelograms == 0) { - // No parallelogram was valid. - // We use the last decoded point as a reference. - const int src_offset = (p - 1) * num_components; - this->transform().ComputeOriginalValue( - out_data + src_offset, in_corr + dst_offset, out_data + dst_offset); - } else { - // Compute the correction from the predicted value. - for (int c = 0; c < num_components; ++c) { - pred_vals[c] /= num_parallelograms; - } - this->transform().ComputeOriginalValue( - pred_vals.get(), in_corr + dst_offset, out_data + dst_offset); - } - } - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_MULTI_PARALLELOGRAM_DECODER_H_ -#endif diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h deleted file mode 100644 index 301b357..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_MULTI_PARALLELOGRAM_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_MULTI_PARALLELOGRAM_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" - -namespace draco { - -// Multi parallelogram prediction predicts attribute values using information -// from all opposite faces to the predicted vertex, compared to the standard -// prediction scheme, where only one opposite face is used (see -// prediction_scheme_parallelogram.h). This approach is generally slower than -// the standard parallelogram prediction, but it usually results in better -// prediction (5 - 20% based on the quantization level. Better gains can be -// achieved when more aggressive quantization is used). -template -class MeshPredictionSchemeMultiParallelogramEncoder - : public MeshPredictionSchemeEncoder { - public: - using CorrType = - typename PredictionSchemeEncoder::CorrType; - using CornerTable = typename MeshDataT::CornerTable; - - explicit MeshPredictionSchemeMultiParallelogramEncoder( - const PointAttribute *attribute) - : MeshPredictionSchemeEncoder( - attribute) {} - MeshPredictionSchemeMultiParallelogramEncoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeEncoder( - attribute, transform, mesh_data) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_MULTI_PARALLELOGRAM; - } - - bool IsInitialized() const override { - return this->mesh_data().IsInitialized(); - } -}; - -template -bool MeshPredictionSchemeMultiParallelogramEncoder:: - ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, - int size, int num_components, - const PointIndex * /* entry_to_point_id_map */) { - this->transform().Init(in_data, size, num_components); - const CornerTable *const table = this->mesh_data().corner_table(); - const std::vector *const vertex_to_data_map = - this->mesh_data().vertex_to_data_map(); - - // For storage of prediction values (already initialized to zero). - std::unique_ptr pred_vals(new DataTypeT[num_components]()); - std::unique_ptr parallelogram_pred_vals( - new DataTypeT[num_components]()); - - // We start processing from the end because this prediction uses data from - // previous entries that could be overwritten when an entry is processed. - for (int p = - static_cast(this->mesh_data().data_to_corner_map()->size() - 1); - p > 0; --p) { - const CornerIndex start_corner_id = - this->mesh_data().data_to_corner_map()->at(p); - - // Go over all corners attached to the vertex and compute the predicted - // value from the parallelograms defined by their opposite faces. - CornerIndex corner_id(start_corner_id); - int num_parallelograms = 0; - for (int i = 0; i < num_components; ++i) { - pred_vals[i] = static_cast(0); - } - while (corner_id != kInvalidCornerIndex) { - if (ComputeParallelogramPrediction( - p, corner_id, table, *vertex_to_data_map, in_data, num_components, - parallelogram_pred_vals.get())) { - for (int c = 0; c < num_components; ++c) { - pred_vals[c] += parallelogram_pred_vals[c]; - } - ++num_parallelograms; - } - - // Proceed to the next corner attached to the vertex. - corner_id = table->SwingRight(corner_id); - if (corner_id == start_corner_id) { - corner_id = kInvalidCornerIndex; - } - } - const int dst_offset = p * num_components; - if (num_parallelograms == 0) { - // No parallelogram was valid. - // We use the last encoded point as a reference. - const int src_offset = (p - 1) * num_components; - this->transform().ComputeCorrection( - in_data + dst_offset, in_data + src_offset, out_corr + dst_offset); - } else { - // Compute the correction from the predicted value. - for (int c = 0; c < num_components; ++c) { - pred_vals[c] /= num_parallelograms; - } - this->transform().ComputeCorrection(in_data + dst_offset, pred_vals.get(), - out_corr + dst_offset); - } - } - // First element is always fixed because it cannot be predicted. - for (int i = 0; i < num_components; ++i) { - pred_vals[i] = static_cast(0); - } - this->transform().ComputeCorrection(in_data, pred_vals.get(), out_corr); - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_MULTI_PARALLELOGRAM_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h deleted file mode 100644 index 4d47ddf..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_DECODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" - -namespace draco { - -// Decoder for attribute values encoded with the standard parallelogram -// prediction. See the description of the corresponding encoder for more -// details. -template -class MeshPredictionSchemeParallelogramDecoder - : public MeshPredictionSchemeDecoder { - public: - using CorrType = - typename PredictionSchemeDecoder::CorrType; - using CornerTable = typename MeshDataT::CornerTable; - explicit MeshPredictionSchemeParallelogramDecoder( - const PointAttribute *attribute) - : MeshPredictionSchemeDecoder( - attribute) {} - MeshPredictionSchemeParallelogramDecoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeDecoder( - attribute, transform, mesh_data) {} - - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_PARALLELOGRAM; - } - - bool IsInitialized() const override { - return this->mesh_data().IsInitialized(); - } -}; - -template -bool MeshPredictionSchemeParallelogramDecoder:: - ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int /* size */, int num_components, - const PointIndex * /* entry_to_point_id_map */) { - this->transform().Init(num_components); - - const CornerTable *const table = this->mesh_data().corner_table(); - const std::vector *const vertex_to_data_map = - this->mesh_data().vertex_to_data_map(); - - // For storage of prediction values (already initialized to zero). - std::unique_ptr pred_vals(new DataTypeT[num_components]()); - - // Restore the first value. - this->transform().ComputeOriginalValue(pred_vals.get(), in_corr, out_data); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - for (int p = 1; p < corner_map_size; ++p) { - const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); - const int dst_offset = p * num_components; - if (!ComputeParallelogramPrediction(p, corner_id, table, - *vertex_to_data_map, out_data, - num_components, pred_vals.get())) { - // Parallelogram could not be computed, Possible because some of the - // vertices are not valid (not encoded yet). - // We use the last encoded point as a reference (delta coding). - const int src_offset = (p - 1) * num_components; - this->transform().ComputeOriginalValue( - out_data + src_offset, in_corr + dst_offset, out_data + dst_offset); - } else { - // Apply the parallelogram prediction. - this->transform().ComputeOriginalValue( - pred_vals.get(), in_corr + dst_offset, out_data + dst_offset); - } - } - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h deleted file mode 100644 index f008019..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" - -namespace draco { - -// Parallelogram prediction predicts an attribute value V from three vertices -// on the opposite face to the predicted vertex. The values on the three -// vertices are used to construct a parallelogram V' = O - A - B, where O is the -// value on the opposite vertex, and A, B are values on the shared vertices: -// V -// / \ -// / \ -// / \ -// A-------B -// \ / -// \ / -// \ / -// O -// -template -class MeshPredictionSchemeParallelogramEncoder - : public MeshPredictionSchemeEncoder { - public: - using CorrType = - typename PredictionSchemeEncoder::CorrType; - using CornerTable = typename MeshDataT::CornerTable; - explicit MeshPredictionSchemeParallelogramEncoder( - const PointAttribute *attribute) - : MeshPredictionSchemeEncoder( - attribute) {} - MeshPredictionSchemeParallelogramEncoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeEncoder( - attribute, transform, mesh_data) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_PARALLELOGRAM; - } - - bool IsInitialized() const override { - return this->mesh_data().IsInitialized(); - } -}; - -template -bool MeshPredictionSchemeParallelogramEncoder:: - ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, - int size, int num_components, - const PointIndex * /* entry_to_point_id_map */) { - this->transform().Init(in_data, size, num_components); - // For storage of prediction values (already initialized to zero). - std::unique_ptr pred_vals(new DataTypeT[num_components]()); - - // We start processing from the end because this prediction uses data from - // previous entries that could be overwritten when an entry is processed. - const CornerTable *const table = this->mesh_data().corner_table(); - const std::vector *const vertex_to_data_map = - this->mesh_data().vertex_to_data_map(); - for (int p = - static_cast(this->mesh_data().data_to_corner_map()->size() - 1); - p > 0; --p) { - const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); - const int dst_offset = p * num_components; - if (!ComputeParallelogramPrediction(p, corner_id, table, - *vertex_to_data_map, in_data, - num_components, pred_vals.get())) { - // Parallelogram could not be computed, Possible because some of the - // vertices are not valid (not encoded yet). - // We use the last encoded point as a reference (delta coding). - const int src_offset = (p - 1) * num_components; - this->transform().ComputeCorrection( - in_data + dst_offset, in_data + src_offset, out_corr + dst_offset); - } else { - // Apply the parallelogram prediction. - this->transform().ComputeCorrection(in_data + dst_offset, pred_vals.get(), - out_corr + dst_offset); - } - } - // First element is always fixed because it cannot be predicted. - for (int i = 0; i < num_components; ++i) { - pred_vals[i] = static_cast(0); - } - this->transform().ComputeCorrection(in_data, pred_vals.get(), out_corr); - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h deleted file mode 100644 index c63c8d0..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Shared functionality for different parallelogram prediction schemes. - -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_SHARED_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_SHARED_H_ - -#include "draco/mesh/corner_table.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// TODO(draco-eng) consolidate Vertex/next/previous queries to one call -// (performance). -template -inline void GetParallelogramEntries( - const CornerIndex ci, const CornerTableT *table, - const std::vector &vertex_to_data_map, int *opp_entry, - int *next_entry, int *prev_entry) { - // One vertex of the input |table| correspond to exactly one attribute value - // entry. The |table| can be either CornerTable for per-vertex attributes, - // or MeshAttributeCornerTable for attributes with interior seams. - *opp_entry = vertex_to_data_map[table->Vertex(ci).value()]; - *next_entry = vertex_to_data_map[table->Vertex(table->Next(ci)).value()]; - *prev_entry = vertex_to_data_map[table->Vertex(table->Previous(ci)).value()]; -} - -// Computes parallelogram prediction for a given corner and data entry id. -// The prediction is stored in |out_prediction|. -// Function returns false when the prediction couldn't be computed, e.g. because -// not all entry points were available. -template -inline bool ComputeParallelogramPrediction( - int data_entry_id, const CornerIndex ci, const CornerTableT *table, - const std::vector &vertex_to_data_map, const DataTypeT *in_data, - int num_components, DataTypeT *out_prediction) { - const CornerIndex oci = table->Opposite(ci); - if (oci == kInvalidCornerIndex) - return false; - int vert_opp, vert_next, vert_prev; - GetParallelogramEntries(oci, table, vertex_to_data_map, - &vert_opp, &vert_next, &vert_prev); - if (vert_opp < data_entry_id && vert_next < data_entry_id && - vert_prev < data_entry_id) { - // Apply the parallelogram prediction. - const int v_opp_off = vert_opp * num_components; - const int v_next_off = vert_next * num_components; - const int v_prev_off = vert_prev * num_components; - for (int c = 0; c < num_components; ++c) { - out_prediction[c] = (in_data[v_next_off + c] + in_data[v_prev_off + c]) - - in_data[v_opp_off + c]; - } - return true; - } - return false; // Not all data is available for prediction -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_PARALLELOGRAM_SHARED_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h deleted file mode 100644 index 2e389b2..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ - -#include - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" -#include "draco/compression/bit_coders/rans_bit_decoder.h" -#include "draco/core/varint_decoding.h" -#include "draco/core/vector_d.h" -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Decoder for predictions of UV coordinates encoded by our specialized texture -// coordinate predictor. See the corresponding encoder for more details. Note -// that this predictor is not portable and should not be used anymore. See -// MeshPredictionSchemeTexCoordsPortableEncoder/Decoder for a portable version -// of this prediction scheme. -template -class MeshPredictionSchemeTexCoordsDecoder - : public MeshPredictionSchemeDecoder { - public: - using CorrType = typename MeshPredictionSchemeDecoder::CorrType; - MeshPredictionSchemeTexCoordsDecoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data, int version) - : MeshPredictionSchemeDecoder( - attribute, transform, mesh_data), - pos_attribute_(nullptr), - entry_to_point_id_map_(nullptr), - num_components_(0), - version_(version) {} - - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - - bool DecodePredictionData(DecoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_TEX_COORDS_DEPRECATED; - } - - bool IsInitialized() const override { - if (pos_attribute_ == nullptr) - return false; - if (!this->mesh_data().IsInitialized()) - return false; - return true; - } - - int GetNumParentAttributes() const override { return 1; } - - GeometryAttribute::Type GetParentAttributeType(int i) const override { - DRACO_DCHECK_EQ(i, 0); - (void)i; - return GeometryAttribute::POSITION; - } - - bool SetParentAttribute(const PointAttribute *att) override { - if (att == nullptr) - return false; - if (att->attribute_type() != GeometryAttribute::POSITION) - return false; // Invalid attribute type. - if (att->num_components() != 3) - return false; // Currently works only for 3 component positions. - pos_attribute_ = att; - return true; - } - - protected: - Vector3f GetPositionForEntryId(int entry_id) const { - const PointIndex point_id = entry_to_point_id_map_[entry_id]; - Vector3f pos; - pos_attribute_->ConvertValue(pos_attribute_->mapped_index(point_id), - &pos[0]); - return pos; - } - - Vector2f GetTexCoordForEntryId(int entry_id, const DataTypeT *data) const { - const int data_offset = entry_id * num_components_; - return Vector2f(static_cast(data[data_offset]), - static_cast(data[data_offset + 1])); - } - - void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, - int data_id); - - private: - const PointAttribute *pos_attribute_; - const PointIndex *entry_to_point_id_map_; - std::unique_ptr predicted_value_; - int num_components_; - // Encoded / decoded array of UV flips. - std::vector orientations_; - int version_; -}; - -template -bool MeshPredictionSchemeTexCoordsDecoder:: - ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int /* size */, int num_components, - const PointIndex *entry_to_point_id_map) { - num_components_ = num_components; - entry_to_point_id_map_ = entry_to_point_id_map; - predicted_value_ = - std::unique_ptr(new DataTypeT[num_components]); - this->transform().Init(num_components); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - for (int p = 0; p < corner_map_size; ++p) { - const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); - ComputePredictedValue(corner_id, out_data, p); - - const int dst_offset = p * num_components; - this->transform().ComputeOriginalValue( - predicted_value_.get(), in_corr + dst_offset, out_data + dst_offset); - } - return true; -} - -template -bool MeshPredictionSchemeTexCoordsDecoder:: - DecodePredictionData(DecoderBuffer *buffer) { - // Decode the delta coded orientations. - uint32_t num_orientations = 0; - if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - if (!buffer->Decode(&num_orientations)) - return false; - } else { - if (!DecodeVarint(&num_orientations, buffer)) - return false; - } - if (num_orientations == 0) - return false; - orientations_.resize(num_orientations); - bool last_orientation = true; - RAnsBitDecoder decoder; - if (!decoder.StartDecoding(buffer)) - return false; - for (uint32_t i = 0; i < num_orientations; ++i) { - if (!decoder.DecodeNextBit()) - last_orientation = !last_orientation; - orientations_[i] = last_orientation; - } - decoder.EndDecoding(); - return MeshPredictionSchemeDecoder::DecodePredictionData(buffer); -} - -template -void MeshPredictionSchemeTexCoordsDecoder:: - ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, - int data_id) { - // Compute the predicted UV coordinate from the positions on all corners - // of the processed triangle. For the best prediction, the UV coordinates - // on the next/previous corners need to be already encoded/decoded. - const CornerIndex next_corner_id = - this->mesh_data().corner_table()->Next(corner_id); - const CornerIndex prev_corner_id = - this->mesh_data().corner_table()->Previous(corner_id); - // Get the encoded data ids from the next and previous corners. - // The data id is the encoding order of the UV coordinates. - int next_data_id, prev_data_id; - - int next_vert_id, prev_vert_id; - next_vert_id = - this->mesh_data().corner_table()->Vertex(next_corner_id).value(); - prev_vert_id = - this->mesh_data().corner_table()->Vertex(prev_corner_id).value(); - - next_data_id = this->mesh_data().vertex_to_data_map()->at(next_vert_id); - prev_data_id = this->mesh_data().vertex_to_data_map()->at(prev_vert_id); - - if (prev_data_id < data_id && next_data_id < data_id) { - // Both other corners have available UV coordinates for prediction. - const Vector2f n_uv = GetTexCoordForEntryId(next_data_id, data); - const Vector2f p_uv = GetTexCoordForEntryId(prev_data_id, data); - if (p_uv == n_uv) { - // We cannot do a reliable prediction on degenerated UV triangles. - predicted_value_[0] = static_cast(p_uv[0]); - predicted_value_[1] = static_cast(p_uv[1]); - return; - } - - // Get positions at all corners. - const Vector3f tip_pos = GetPositionForEntryId(data_id); - const Vector3f next_pos = GetPositionForEntryId(next_data_id); - const Vector3f prev_pos = GetPositionForEntryId(prev_data_id); - // Use the positions of the above triangle to predict the texture coordinate - // on the tip corner C. - // Convert the triangle into a new coordinate system defined by orthogonal - // bases vectors S, T, where S is vector prev_pos - next_pos and T is an - // perpendicular vector to S in the same plane as vector the - // tip_pos - next_pos. - // The transformed triangle in the new coordinate system is then going to - // be represented as: - // - // 1 ^ - // | - // | - // | C - // | / \ - // | / \ - // |/ \ - // N--------------P - // 0 1 - // - // Where next_pos point (N) is at position (0, 0), prev_pos point (P) is - // at (1, 0). Our goal is to compute the position of the tip_pos point (C) - // in this new coordinate space (s, t). - // - const Vector3f pn = prev_pos - next_pos; - const Vector3f cn = tip_pos - next_pos; - const float pn_norm2_squared = pn.SquaredNorm(); - // Coordinate s of the tip corner C is simply the dot product of the - // normalized vectors |pn| and |cn| (normalized by the length of |pn|). - // Since both of these vectors are normalized, we don't need to perform the - // normalization explicitly and instead we can just use the squared norm - // of |pn| as a denominator of the resulting dot product of non normalized - // vectors. - float s, t; - // |pn_norm2_squared| can be exactly 0 when the next_pos and prev_pos are - // the same positions (e.g. because they were quantized to the same - // location). - if (version_ < DRACO_BITSTREAM_VERSION(1, 2) || pn_norm2_squared > 0) { - s = pn.Dot(cn) / pn_norm2_squared; - // To get the coordinate t, we can use formula: - // t = |C-N - (P-N) * s| / |P-N| - // Do not use std::sqrt to avoid changes in the bitstream. - t = sqrt((cn - pn * s).SquaredNorm() / pn_norm2_squared); - } else { - s = 0; - t = 0; - } - - // Now we need to transform the point (s, t) to the texture coordinate space - // UV. We know the UV coordinates on points N and P (N_UV and P_UV). Lets - // denote P_UV - N_UV = PN_UV. PN_UV is then 2 dimensional vector that can - // be used to define transformation from the normalized coordinate system - // to the texture coordinate system using a 3x3 affine matrix M: - // - // M = | PN_UV[0] -PN_UV[1] N_UV[0] | - // | PN_UV[1] PN_UV[0] N_UV[1] | - // | 0 0 1 | - // - // The predicted point C_UV in the texture space is then equal to - // C_UV = M * (s, t, 1). Because the triangle in UV space may be flipped - // around the PN_UV axis, we also need to consider point C_UV' = M * (s, -t) - // as the prediction. - const Vector2f pn_uv = p_uv - n_uv; - const float pnus = pn_uv[0] * s + n_uv[0]; - const float pnut = pn_uv[0] * t; - const float pnvs = pn_uv[1] * s + n_uv[1]; - const float pnvt = pn_uv[1] * t; - Vector2f predicted_uv; - - // When decoding the data, we already know which orientation to use. - const bool orientation = orientations_.back(); - orientations_.pop_back(); - if (orientation) - predicted_uv = Vector2f(pnus - pnvt, pnvs + pnut); - else - predicted_uv = Vector2f(pnus + pnvt, pnvs - pnut); - - if (std::is_integral::value) { - // Round the predicted value for integer types. - if (std::isnan(predicted_uv[0])) { - predicted_value_[0] = INT_MIN; - } else { - predicted_value_[0] = static_cast(floor(predicted_uv[0] + 0.5)); - } - if (std::isnan(predicted_uv[1])) { - predicted_value_[1] = INT_MIN; - } else { - predicted_value_[1] = static_cast(floor(predicted_uv[1] + 0.5)); - } - } else { - predicted_value_[0] = static_cast(predicted_uv[0]); - predicted_value_[1] = static_cast(predicted_uv[1]); - } - return; - } - // Else we don't have available textures on both corners. For such case we - // can't use positions for predicting the uv value and we resort to delta - // coding. - int data_offset = 0; - if (prev_data_id < data_id) { - // Use the value on the previous corner as the prediction. - data_offset = prev_data_id * num_components_; - } - if (next_data_id < data_id) { - // Use the value on the next corner as the prediction. - data_offset = next_data_id * num_components_; - } else { - // None of the other corners have a valid value. Use the last encoded value - // as the prediction if possible. - if (data_id > 0) { - data_offset = (data_id - 1) * num_components_; - } else { - // We are encoding the first value. Predict 0. - for (int i = 0; i < num_components_; ++i) { - predicted_value_[i] = 0; - } - return; - } - } - for (int i = 0; i < num_components_; ++i) { - predicted_value_[i] = data[data_offset + i]; - } -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_DECODER_H_ -#endif diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h deleted file mode 100644 index 0e938b9..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +++ /dev/null @@ -1,313 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_ENCODER_H_ - -#include -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" -#include "draco/compression/bit_coders/rans_bit_encoder.h" -#include "draco/core/varint_encoding.h" -#include "draco/core/vector_d.h" -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Prediction scheme designed for predicting texture coordinates from known -// spatial position of vertices. For good parametrization, the ratios between -// triangle edge lengths should be about the same in both the spatial and UV -// coordinate spaces, which makes the positions a good predictor for the UV -// coordinates. -template -class MeshPredictionSchemeTexCoordsEncoder - : public MeshPredictionSchemeEncoder { - public: - using CorrType = typename MeshPredictionSchemeEncoder::CorrType; - MeshPredictionSchemeTexCoordsEncoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeEncoder( - attribute, transform, mesh_data), - pos_attribute_(nullptr), - entry_to_point_id_map_(nullptr), - num_components_(0) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - - bool EncodePredictionData(EncoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_TEX_COORDS_DEPRECATED; - } - - bool IsInitialized() const override { - if (pos_attribute_ == nullptr) - return false; - if (!this->mesh_data().IsInitialized()) - return false; - return true; - } - - int GetNumParentAttributes() const override { return 1; } - - GeometryAttribute::Type GetParentAttributeType(int i) const override { - DRACO_DCHECK_EQ(i, 0); - (void)i; - return GeometryAttribute::POSITION; - } - - bool SetParentAttribute(const PointAttribute *att) override { - if (att->attribute_type() != GeometryAttribute::POSITION) - return false; // Invalid attribute type. - if (att->num_components() != 3) - return false; // Currently works only for 3 component positions. - pos_attribute_ = att; - return true; - } - - protected: - Vector3f GetPositionForEntryId(int entry_id) const { - const PointIndex point_id = entry_to_point_id_map_[entry_id]; - Vector3f pos; - pos_attribute_->ConvertValue(pos_attribute_->mapped_index(point_id), - &pos[0]); - return pos; - } - - Vector2f GetTexCoordForEntryId(int entry_id, const DataTypeT *data) const { - const int data_offset = entry_id * num_components_; - return Vector2f(static_cast(data[data_offset]), - static_cast(data[data_offset + 1])); - } - - void ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, - int data_id); - - private: - const PointAttribute *pos_attribute_; - const PointIndex *entry_to_point_id_map_; - std::unique_ptr predicted_value_; - int num_components_; - // Encoded / decoded array of UV flips. - std::vector orientations_; -}; - -template -bool MeshPredictionSchemeTexCoordsEncoder:: - ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, - int size, int num_components, - const PointIndex *entry_to_point_id_map) { - num_components_ = num_components; - entry_to_point_id_map_ = entry_to_point_id_map; - predicted_value_ = - std::unique_ptr(new DataTypeT[num_components]); - this->transform().Init(in_data, size, num_components); - // We start processing from the end because this prediction uses data from - // previous entries that could be overwritten when an entry is processed. - for (int p = - static_cast(this->mesh_data().data_to_corner_map()->size()) - 1; - p >= 0; --p) { - const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); - ComputePredictedValue(corner_id, in_data, p); - - const int dst_offset = p * num_components; - this->transform().ComputeCorrection( - in_data + dst_offset, predicted_value_.get(), out_corr + dst_offset); - } - return true; -} - -template -bool MeshPredictionSchemeTexCoordsEncoder:: - EncodePredictionData(EncoderBuffer *buffer) { - // Encode the delta-coded orientations using arithmetic coding. - const uint32_t num_orientations = static_cast(orientations_.size()); - EncodeVarint(num_orientations, buffer); - bool last_orientation = true; - RAnsBitEncoder encoder; - encoder.StartEncoding(); - for (bool orientation : orientations_) { - encoder.EncodeBit(orientation == last_orientation); - last_orientation = orientation; - } - encoder.EndEncoding(buffer); - return MeshPredictionSchemeEncoder::EncodePredictionData(buffer); -} - -template -void MeshPredictionSchemeTexCoordsEncoder:: - ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, - int data_id) { - // Compute the predicted UV coordinate from the positions on all corners - // of the processed triangle. For the best prediction, the UV coordinates - // on the next/previous corners need to be already encoded/decoded. - const CornerIndex next_corner_id = - this->mesh_data().corner_table()->Next(corner_id); - const CornerIndex prev_corner_id = - this->mesh_data().corner_table()->Previous(corner_id); - // Get the encoded data ids from the next and previous corners. - // The data id is the encoding order of the UV coordinates. - int next_data_id, prev_data_id; - - int next_vert_id, prev_vert_id; - next_vert_id = - this->mesh_data().corner_table()->Vertex(next_corner_id).value(); - prev_vert_id = - this->mesh_data().corner_table()->Vertex(prev_corner_id).value(); - - next_data_id = this->mesh_data().vertex_to_data_map()->at(next_vert_id); - prev_data_id = this->mesh_data().vertex_to_data_map()->at(prev_vert_id); - - if (prev_data_id < data_id && next_data_id < data_id) { - // Both other corners have available UV coordinates for prediction. - const Vector2f n_uv = GetTexCoordForEntryId(next_data_id, data); - const Vector2f p_uv = GetTexCoordForEntryId(prev_data_id, data); - if (p_uv == n_uv) { - // We cannot do a reliable prediction on degenerated UV triangles. - predicted_value_[0] = static_cast(p_uv[0]); - predicted_value_[1] = static_cast(p_uv[1]); - return; - } - - // Get positions at all corners. - const Vector3f tip_pos = GetPositionForEntryId(data_id); - const Vector3f next_pos = GetPositionForEntryId(next_data_id); - const Vector3f prev_pos = GetPositionForEntryId(prev_data_id); - // Use the positions of the above triangle to predict the texture coordinate - // on the tip corner C. - // Convert the triangle into a new coordinate system defined by orthogonal - // bases vectors S, T, where S is vector prev_pos - next_pos and T is an - // perpendicular vector to S in the same plane as vector the - // tip_pos - next_pos. - // The transformed triangle in the new coordinate system is then going to - // be represented as: - // - // 1 ^ - // | - // | - // | C - // | / \ - // | / \ - // |/ \ - // N--------------P - // 0 1 - // - // Where next_pos point (N) is at position (0, 0), prev_pos point (P) is - // at (1, 0). Our goal is to compute the position of the tip_pos point (C) - // in this new coordinate space (s, t). - // - const Vector3f pn = prev_pos - next_pos; - const Vector3f cn = tip_pos - next_pos; - const float pn_norm2_squared = pn.SquaredNorm(); - // Coordinate s of the tip corner C is simply the dot product of the - // normalized vectors |pn| and |cn| (normalized by the length of |pn|). - // Since both of these vectors are normalized, we don't need to perform the - // normalization explicitly and instead we can just use the squared norm - // of |pn| as a denominator of the resulting dot product of non normalized - // vectors. - float s, t; - // |pn_norm2_squared| can be exactly 0 when the next_pos and prev_pos are - // the same positions (e.g. because they were quantized to the same - // location). - if (pn_norm2_squared > 0) { - s = pn.Dot(cn) / pn_norm2_squared; - // To get the coordinate t, we can use formula: - // t = |C-N - (P-N) * s| / |P-N| - // Do not use std::sqrt to avoid changes in the bitstream. - t = sqrt((cn - pn * s).SquaredNorm() / pn_norm2_squared); - } else { - s = 0; - t = 0; - } - - // Now we need to transform the point (s, t) to the texture coordinate space - // UV. We know the UV coordinates on points N and P (N_UV and P_UV). Lets - // denote P_UV - N_UV = PN_UV. PN_UV is then 2 dimensional vector that can - // be used to define transformation from the normalized coordinate system - // to the texture coordinate system using a 3x3 affine matrix M: - // - // M = | PN_UV[0] -PN_UV[1] N_UV[0] | - // | PN_UV[1] PN_UV[0] N_UV[1] | - // | 0 0 1 | - // - // The predicted point C_UV in the texture space is then equal to - // C_UV = M * (s, t, 1). Because the triangle in UV space may be flipped - // around the PN_UV axis, we also need to consider point C_UV' = M * (s, -t) - // as the prediction. - const Vector2f pn_uv = p_uv - n_uv; - const float pnus = pn_uv[0] * s + n_uv[0]; - const float pnut = pn_uv[0] * t; - const float pnvs = pn_uv[1] * s + n_uv[1]; - const float pnvt = pn_uv[1] * t; - Vector2f predicted_uv; - - // When encoding compute both possible vectors and determine which one - // results in a better prediction. - const Vector2f predicted_uv_0(pnus - pnvt, pnvs + pnut); - const Vector2f predicted_uv_1(pnus + pnvt, pnvs - pnut); - const Vector2f c_uv = GetTexCoordForEntryId(data_id, data); - if ((c_uv - predicted_uv_0).SquaredNorm() < - (c_uv - predicted_uv_1).SquaredNorm()) { - predicted_uv = predicted_uv_0; - orientations_.push_back(true); - } else { - predicted_uv = predicted_uv_1; - orientations_.push_back(false); - } - if (std::is_integral::value) { - // Round the predicted value for integer types. - predicted_value_[0] = static_cast(floor(predicted_uv[0] + 0.5)); - predicted_value_[1] = static_cast(floor(predicted_uv[1] + 0.5)); - } else { - predicted_value_[0] = static_cast(predicted_uv[0]); - predicted_value_[1] = static_cast(predicted_uv[1]); - } - return; - } - // Else we don't have available textures on both corners. For such case we - // can't use positions for predicting the uv value and we resort to delta - // coding. - int data_offset = 0; - if (prev_data_id < data_id) { - // Use the value on the previous corner as the prediction. - data_offset = prev_data_id * num_components_; - } - if (next_data_id < data_id) { - // Use the value on the next corner as the prediction. - data_offset = next_data_id * num_components_; - } else { - // None of the other corners have a valid value. Use the last encoded value - // as the prediction if possible. - if (data_id > 0) { - data_offset = (data_id - 1) * num_components_; - } else { - // We are encoding the first value. Predict 0. - for (int i = 0; i < num_components_; ++i) { - predicted_value_[i] = 0; - } - return; - } - } - for (int i = 0; i < num_components_; ++i) { - predicted_value_[i] = data[data_offset + i]; - } -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h deleted file mode 100644 index 0fee0ce..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_DECODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h" -#include "draco/compression/bit_coders/rans_bit_decoder.h" - -namespace draco { - -// Decoder for predictions of UV coordinates encoded by our specialized and -// portable texture coordinate predictor. See the corresponding encoder for more -// details. -template -class MeshPredictionSchemeTexCoordsPortableDecoder - : public MeshPredictionSchemeDecoder { - public: - using CorrType = typename MeshPredictionSchemeDecoder::CorrType; - MeshPredictionSchemeTexCoordsPortableDecoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeDecoder( - attribute, transform, mesh_data), - predictor_(mesh_data) {} - - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - - bool DecodePredictionData(DecoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_TEX_COORDS_PORTABLE; - } - - bool IsInitialized() const override { - if (!predictor_.IsInitialized()) - return false; - if (!this->mesh_data().IsInitialized()) - return false; - return true; - } - - int GetNumParentAttributes() const override { return 1; } - - GeometryAttribute::Type GetParentAttributeType(int i) const override { - DRACO_DCHECK_EQ(i, 0); - (void)i; - return GeometryAttribute::POSITION; - } - - bool SetParentAttribute(const PointAttribute *att) override { - if (!att || att->attribute_type() != GeometryAttribute::POSITION) - return false; // Invalid attribute type. - if (att->num_components() != 3) - return false; // Currently works only for 3 component positions. - predictor_.SetPositionAttribute(*att); - return true; - } - - private: - MeshPredictionSchemeTexCoordsPortablePredictor - predictor_; -}; - -template -bool MeshPredictionSchemeTexCoordsPortableDecoder< - DataTypeT, TransformT, - MeshDataT>::ComputeOriginalValues(const CorrType *in_corr, - DataTypeT *out_data, int /* size */, - int num_components, - const PointIndex *entry_to_point_id_map) { - predictor_.SetEntryToPointIdMap(entry_to_point_id_map); - this->transform().Init(num_components); - - const int corner_map_size = - static_cast(this->mesh_data().data_to_corner_map()->size()); - for (int p = 0; p < corner_map_size; ++p) { - const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); - if (!predictor_.template ComputePredictedValue(corner_id, out_data, - p)) - return false; - - const int dst_offset = p * num_components; - this->transform().ComputeOriginalValue(predictor_.predicted_value(), - in_corr + dst_offset, - out_data + dst_offset); - } - return true; -} - -template -bool MeshPredictionSchemeTexCoordsPortableDecoder< - DataTypeT, TransformT, MeshDataT>::DecodePredictionData(DecoderBuffer - *buffer) { - // Decode the delta coded orientations. - int32_t num_orientations = 0; - if (!buffer->Decode(&num_orientations) || num_orientations < 0) - return false; - predictor_.ResizeOrientations(num_orientations); - bool last_orientation = true; - RAnsBitDecoder decoder; - if (!decoder.StartDecoding(buffer)) - return false; - for (int i = 0; i < num_orientations; ++i) { - if (!decoder.DecodeNextBit()) - last_orientation = !last_orientation; - predictor_.set_orientation(i, last_orientation); - } - decoder.EndDecoding(); - return MeshPredictionSchemeDecoder::DecodePredictionData(buffer); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h deleted file mode 100644 index 04a6632..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h" -#include "draco/compression/bit_coders/rans_bit_encoder.h" - -namespace draco { - -// Prediction scheme designed for predicting texture coordinates from known -// spatial position of vertices. For isometric parametrizations, the ratios -// between triangle edge lengths should be about the same in both the spatial -// and UV coordinate spaces, which makes the positions a good predictor for the -// UV coordinates. Note that this may not be the optimal approach for other -// parametrizations such as projective ones. -template -class MeshPredictionSchemeTexCoordsPortableEncoder - : public MeshPredictionSchemeEncoder { - public: - using CorrType = typename MeshPredictionSchemeEncoder::CorrType; - MeshPredictionSchemeTexCoordsPortableEncoder(const PointAttribute *attribute, - const TransformT &transform, - const MeshDataT &mesh_data) - : MeshPredictionSchemeEncoder( - attribute, transform, mesh_data), - predictor_(mesh_data) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - - bool EncodePredictionData(EncoderBuffer *buffer) override; - - PredictionSchemeMethod GetPredictionMethod() const override { - return MESH_PREDICTION_TEX_COORDS_PORTABLE; - } - - bool IsInitialized() const override { - if (!predictor_.IsInitialized()) - return false; - if (!this->mesh_data().IsInitialized()) - return false; - return true; - } - - int GetNumParentAttributes() const override { return 1; } - - GeometryAttribute::Type GetParentAttributeType(int i) const override { - DRACO_DCHECK_EQ(i, 0); - (void)i; - return GeometryAttribute::POSITION; - } - - bool SetParentAttribute(const PointAttribute *att) override { - if (att->attribute_type() != GeometryAttribute::POSITION) - return false; // Invalid attribute type. - if (att->num_components() != 3) - return false; // Currently works only for 3 component positions. - predictor_.SetPositionAttribute(*att); - return true; - } - - private: - MeshPredictionSchemeTexCoordsPortablePredictor - predictor_; -}; - -template -bool MeshPredictionSchemeTexCoordsPortableEncoder:: - ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr, - int size, int num_components, - const PointIndex *entry_to_point_id_map) { - predictor_.SetEntryToPointIdMap(entry_to_point_id_map); - this->transform().Init(in_data, size, num_components); - // We start processing from the end because this prediction uses data from - // previous entries that could be overwritten when an entry is processed. - for (int p = - static_cast(this->mesh_data().data_to_corner_map()->size() - 1); - p >= 0; --p) { - const CornerIndex corner_id = this->mesh_data().data_to_corner_map()->at(p); - predictor_.template ComputePredictedValue(corner_id, in_data, p); - - const int dst_offset = p * num_components; - this->transform().ComputeCorrection(in_data + dst_offset, - predictor_.predicted_value(), - out_corr + dst_offset); - } - return true; -} - -template -bool MeshPredictionSchemeTexCoordsPortableEncoder< - DataTypeT, TransformT, MeshDataT>::EncodePredictionData(EncoderBuffer - *buffer) { - // Encode the delta-coded orientations using arithmetic coding. - const int32_t num_orientations = predictor_.num_orientations(); - buffer->Encode(num_orientations); - bool last_orientation = true; - RAnsBitEncoder encoder; - encoder.StartEncoding(); - for (int i = 0; i < num_orientations; ++i) { - const bool orientation = predictor_.orientation(i); - encoder.EncodeBit(orientation == last_orientation); - last_orientation = orientation; - } - encoder.EndEncoding(buffer); - return MeshPredictionSchemeEncoder::EncodePredictionData(buffer); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h deleted file mode 100644 index f935771..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_PREDICTOR_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_PREDICTOR_H_ - -#include -#include "draco/attributes/point_attribute.h" -#include "draco/core/math_utils.h" -#include "draco/core/vector_d.h" -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Predictor functionality used for portable UV prediction by both encoder and -// decoder. -template -class MeshPredictionSchemeTexCoordsPortablePredictor { - public: - explicit MeshPredictionSchemeTexCoordsPortablePredictor(const MeshDataT &md) - : pos_attribute_(nullptr), - entry_to_point_id_map_(nullptr), - mesh_data_(md) {} - void SetPositionAttribute(const PointAttribute &position_attribute) { - pos_attribute_ = &position_attribute; - } - void SetEntryToPointIdMap(const PointIndex *map) { - entry_to_point_id_map_ = map; - } - bool IsInitialized() const { return pos_attribute_ != nullptr; } - - VectorD GetPositionForEntryId(int entry_id) const { - const PointIndex point_id = entry_to_point_id_map_[entry_id]; - VectorD pos; - pos_attribute_->ConvertValue(pos_attribute_->mapped_index(point_id), - &pos[0]); - return pos; - } - - VectorD GetTexCoordForEntryId(int entry_id, - const DataTypeT *data) const { - const int data_offset = entry_id * kNumComponents; - return VectorD(data[data_offset], data[data_offset + 1]); - } - - // Computes predicted UV coordinates on a given corner. The coordinates are - // stored in |predicted_value_| member. - template - bool ComputePredictedValue(CornerIndex corner_id, const DataTypeT *data, - int data_id); - - const DataTypeT *predicted_value() const { return predicted_value_; } - bool orientation(int i) const { return orientations_[i]; } - void set_orientation(int i, bool v) { orientations_[i] = v; } - size_t num_orientations() const { return orientations_.size(); } - void ResizeOrientations(int num_orientations) { - orientations_.resize(num_orientations); - } - - private: - const PointAttribute *pos_attribute_; - const PointIndex *entry_to_point_id_map_; - static constexpr int kNumComponents = 2; - DataTypeT predicted_value_[kNumComponents]; - // Encoded / decoded array of UV flips. - // TODO(ostava): We should remove this and replace this with in-place encoding - // and decoding to avoid unnecessary copy. - std::vector orientations_; - MeshDataT mesh_data_; -}; - -template -template -bool MeshPredictionSchemeTexCoordsPortablePredictor< - DataTypeT, MeshDataT>::ComputePredictedValue(CornerIndex corner_id, - const DataTypeT *data, - int data_id) { - // Compute the predicted UV coordinate from the positions on all corners - // of the processed triangle. For the best prediction, the UV coordinates - // on the next/previous corners need to be already encoded/decoded. - const CornerIndex next_corner_id = mesh_data_.corner_table()->Next(corner_id); - const CornerIndex prev_corner_id = - mesh_data_.corner_table()->Previous(corner_id); - // Get the encoded data ids from the next and previous corners. - // The data id is the encoding order of the UV coordinates. - int next_data_id, prev_data_id; - - int next_vert_id, prev_vert_id; - next_vert_id = mesh_data_.corner_table()->Vertex(next_corner_id).value(); - prev_vert_id = mesh_data_.corner_table()->Vertex(prev_corner_id).value(); - - next_data_id = mesh_data_.vertex_to_data_map()->at(next_vert_id); - prev_data_id = mesh_data_.vertex_to_data_map()->at(prev_vert_id); - - if (prev_data_id < data_id && next_data_id < data_id) { - // Both other corners have available UV coordinates for prediction. - const VectorD n_uv = GetTexCoordForEntryId(next_data_id, data); - const VectorD p_uv = GetTexCoordForEntryId(prev_data_id, data); - if (p_uv == n_uv) { - // We cannot do a reliable prediction on degenerated UV triangles. - predicted_value_[0] = p_uv[0]; - predicted_value_[1] = p_uv[1]; - return true; - } - - // Get positions at all corners. - const VectorD tip_pos = GetPositionForEntryId(data_id); - const VectorD next_pos = GetPositionForEntryId(next_data_id); - const VectorD prev_pos = GetPositionForEntryId(prev_data_id); - // We use the positions of the above triangle to predict the texture - // coordinate on the tip corner C. - // To convert the triangle into the UV coordinate system we first compute - // position X on the vector |prev_pos - next_pos| that is the projection of - // point C onto vector |prev_pos - next_pos|: - // - // C - // /. \ - // / . \ - // / . \ - // N---X----------P - // - // Where next_pos is point (N), prev_pos is point (P) and tip_pos is the - // position of predicted coordinate (C). - // - const VectorD pn = prev_pos - next_pos; - const uint64_t pn_norm2_squared = pn.SquaredNorm(); - if (pn_norm2_squared != 0) { - // Compute the projection of C onto PN by computing dot product of CN with - // PN and normalizing it by length of PN. This gives us a factor |s| where - // |s = PN.Dot(CN) / PN.SquaredNorm2()|. This factor can be used to - // compute X in UV space |X_UV| as |X_UV = N_UV + s * PN_UV|. - const VectorD cn = tip_pos - next_pos; - const int64_t cn_dot_pn = pn.Dot(cn); - - const VectorD pn_uv = p_uv - n_uv; - // Because we perform all computations with integers, we don't explicitly - // compute the normalized factor |s|, but rather we perform all operations - // over UV vectors in a non-normalized coordinate system scaled with a - // scaling factor |pn_norm2_squared|: - // - // x_uv = X_UV * PN.Norm2Squared() - // - const VectorD x_uv = - n_uv * pn_norm2_squared + (cn_dot_pn * pn_uv); - - // Compute squared length of vector CX in position coordinate system: - const VectorD x_pos = - next_pos + (cn_dot_pn * pn) / pn_norm2_squared; - const uint64_t cx_norm2_squared = (tip_pos - x_pos).SquaredNorm(); - - // Compute vector CX_UV in the uv space by rotating vector PN_UV by 90 - // degrees and scaling it with factor CX.Norm2() / PN.Norm2(): - // - // CX_UV = (CX.Norm2() / PN.Norm2()) * Rot(PN_UV) - // - // To preserve precision, we perform all operations in scaled space as - // explained above, so we want the final vector to be: - // - // cx_uv = CX_UV * PN.Norm2Squared() - // - // We can then rewrite the formula as: - // - // cx_uv = CX.Norm2() * PN.Norm2() * Rot(PN_UV) - // - VectorD cx_uv(pn_uv[1], -pn_uv[0]); // Rotated PN_UV. - // Compute CX.Norm2() * PN.Norm2() - const uint64_t norm_squared = - IntSqrt(cx_norm2_squared * pn_norm2_squared); - // Final cx_uv in the scaled coordinate space. - cx_uv = cx_uv * norm_squared; - - // Predicted uv coordinate is then computed by either adding or - // subtracting CX_UV to/from X_UV. - VectorD predicted_uv; - if (is_encoder_t) { - // When encoding, compute both possible vectors and determine which one - // results in a better prediction. - // Both vectors need to be transformed back from the scaled space to - // the real UV coordinate space. - const VectorD predicted_uv_0((x_uv + cx_uv) / - pn_norm2_squared); - const VectorD predicted_uv_1((x_uv - cx_uv) / - pn_norm2_squared); - const VectorD c_uv = GetTexCoordForEntryId(data_id, data); - if ((c_uv - predicted_uv_0).SquaredNorm() < - (c_uv - predicted_uv_1).SquaredNorm()) { - predicted_uv = predicted_uv_0; - orientations_.push_back(true); - } else { - predicted_uv = predicted_uv_1; - orientations_.push_back(false); - } - } else { - // When decoding the data, we already know which orientation to use. - if (orientations_.empty()) - return false; - const bool orientation = orientations_.back(); - orientations_.pop_back(); - if (orientation) - predicted_uv = (x_uv + cx_uv) / pn_norm2_squared; - else - predicted_uv = (x_uv - cx_uv) / pn_norm2_squared; - } - predicted_value_[0] = static_cast(predicted_uv[0]); - predicted_value_[1] = static_cast(predicted_uv[1]); - return true; - } - } - // Else we don't have available textures on both corners or the position data - // is invalid. For such cases we can't use positions for predicting the uv - // value and we resort to delta coding. - int data_offset = 0; - if (prev_data_id < data_id) { - // Use the value on the previous corner as the prediction. - data_offset = prev_data_id * kNumComponents; - } - if (next_data_id < data_id) { - // Use the value on the next corner as the prediction. - data_offset = next_data_id * kNumComponents; - } else { - // None of the other corners have a valid value. Use the last encoded value - // as the prediction if possible. - if (data_id > 0) { - data_offset = (data_id - 1) * kNumComponents; - } else { - // We are encoding the first value. Predict 0. - for (int i = 0; i < kNumComponents; ++i) { - predicted_value_[i] = 0; - } - return true; - } - } - for (int i = 0; i < kNumComponents; ++i) { - predicted_value_[i] = data[data_offset + i]; - } - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_TEX_COORDS_PORTABLE_PREDICTOR_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h deleted file mode 100644 index 9a14ff8..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_H_ - -#include - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h" - -// Prediction schemes can be used during encoding and decoding of vertex -// attributes to predict attribute values based on the previously -// encoded/decoded data. The differences between the original and predicted -// attribute values are used to compute correction values that can be usually -// encoded with fewer bits compared to the original data. -namespace draco { - -// Abstract base class for typed prediction schemes. It provides basic access -// to the encoded attribute and to the supplied prediction transform. -template > -class PredictionSchemeDecoder : public PredictionSchemeTypedDecoderInterface< - DataTypeT, typename TransformT::CorrType> { - public: - typedef DataTypeT DataType; - typedef TransformT Transform; - // Correction type needs to be defined in the prediction transform class. - typedef typename Transform::CorrType CorrType; - explicit PredictionSchemeDecoder(const PointAttribute *attribute) - : PredictionSchemeDecoder(attribute, Transform()) {} - PredictionSchemeDecoder(const PointAttribute *attribute, - const Transform &transform) - : attribute_(attribute), transform_(transform) {} - - bool DecodePredictionData(DecoderBuffer *buffer) override { - if (!transform_.DecodeTransformData(buffer)) - return false; - return true; - } - - const PointAttribute *GetAttribute() const override { return attribute(); } - - // Returns the number of parent attributes that are needed for the prediction. - int GetNumParentAttributes() const override { return 0; } - - // Returns the type of each of the parent attribute. - GeometryAttribute::Type GetParentAttributeType(int /* i */) const override { - return GeometryAttribute::INVALID; - } - - // Sets the required parent attribute. - bool SetParentAttribute(const PointAttribute * /* att */) override { - return false; - } - - bool AreCorrectionsPositive() override { - return transform_.AreCorrectionsPositive(); - } - - PredictionSchemeTransformType GetTransformType() const override { - return transform_.GetType(); - } - - protected: - inline const PointAttribute *attribute() const { return attribute_; } - inline const Transform &transform() const { return transform_; } - inline Transform &transform() { return transform_; } - - private: - const PointAttribute *attribute_; - Transform transform_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h deleted file mode 100644 index db83555..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Functions for creating prediction schemes for decoders using the provided -// prediction method id. - -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_FACTORY_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_FACTORY_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h" -#ifdef DRACO_NORMAL_ENCODING_SUPPORTED -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h" -#endif -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h" -#include "draco/compression/mesh/mesh_decoder.h" - -namespace draco { - -// Factory class for creating mesh prediction schemes. The factory implements -// operator() that is used to create an appropriate mesh prediction scheme in -// CreateMeshPredictionScheme() function in prediction_scheme_factory.h -template -struct MeshPredictionSchemeDecoderFactory { - // Operator () specialized for the wrap transform. Wrap transform can be used - // for all mesh prediction schemes. The specialization is done in compile time - // to prevent instantiations of unneeded combinations of prediction schemes + - // prediction transforms. - template - struct DispatchFunctor { - std::unique_ptr> operator()( - PredictionSchemeMethod method, const PointAttribute *attribute, - const TransformT &transform, const MeshDataT &mesh_data, - uint16_t bitstream_version) { - if (method == MESH_PREDICTION_PARALLELOGRAM) { - return std::unique_ptr>( - new MeshPredictionSchemeParallelogramDecoder( - attribute, transform, mesh_data)); - } -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - else if (method == MESH_PREDICTION_MULTI_PARALLELOGRAM) { - return std::unique_ptr>( - new MeshPredictionSchemeMultiParallelogramDecoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } -#endif - else if (method == MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM) { - return std::unique_ptr>( - new MeshPredictionSchemeConstrainedMultiParallelogramDecoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - else if (method == MESH_PREDICTION_TEX_COORDS_DEPRECATED) { - return std::unique_ptr>( - new MeshPredictionSchemeTexCoordsDecoder( - attribute, transform, mesh_data, bitstream_version)); - } -#endif - else if (method == MESH_PREDICTION_TEX_COORDS_PORTABLE) { - return std::unique_ptr>( - new MeshPredictionSchemeTexCoordsPortableDecoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } -#ifdef DRACO_NORMAL_ENCODING_SUPPORTED - else if (method == MESH_PREDICTION_GEOMETRIC_NORMAL) { - return std::unique_ptr>( - new MeshPredictionSchemeGeometricNormalDecoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } -#endif - return nullptr; - } - }; - -#ifdef DRACO_NORMAL_ENCODING_SUPPORTED - // Operator () specialized for normal octahedron transforms. These transforms - // are currently used only by the geometric normal prediction scheme (the - // transform is also used by delta coding, but delta predictor is not - // constructed in this function). - template - struct DispatchFunctor { - std::unique_ptr> operator()( - PredictionSchemeMethod method, const PointAttribute *attribute, - const TransformT &transform, const MeshDataT &mesh_data, - uint16_t bitstream_version) { - if (method == MESH_PREDICTION_GEOMETRIC_NORMAL) { - return std::unique_ptr>( - new MeshPredictionSchemeGeometricNormalDecoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } - return nullptr; - } - }; - template - struct DispatchFunctor { - std::unique_ptr> operator()( - PredictionSchemeMethod method, const PointAttribute *attribute, - const TransformT &transform, const MeshDataT &mesh_data, - uint16_t bitstream_version) { - if (method == MESH_PREDICTION_GEOMETRIC_NORMAL) { - return std::unique_ptr>( - new MeshPredictionSchemeGeometricNormalDecoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } - return nullptr; - } - }; -#endif - - template - std::unique_ptr> operator()( - PredictionSchemeMethod method, const PointAttribute *attribute, - const TransformT &transform, const MeshDataT &mesh_data, - uint16_t bitstream_version) { - return DispatchFunctor()( - method, attribute, transform, mesh_data, bitstream_version); - } -}; - -// Creates a prediction scheme for a given decoder and given prediction method. -// The prediction schemes are automatically initialized with decoder specific -// data if needed. -template -std::unique_ptr> -CreatePredictionSchemeForDecoder(PredictionSchemeMethod method, int att_id, - const PointCloudDecoder *decoder, - const TransformT &transform) { - if (method == PREDICTION_NONE) - return nullptr; - const PointAttribute *const att = decoder->point_cloud()->attribute(att_id); - if (decoder->GetGeometryType() == TRIANGULAR_MESH) { - // Cast the decoder to mesh decoder. This is not necessarily safe if there - // is some other decoder decides to use TRIANGULAR_MESH as the return type, - // but unfortunately there is not nice work around for this without using - // RTTI (double dispatch and similar concepts will not work because of the - // template nature of the prediction schemes). - const MeshDecoder *const mesh_decoder = - static_cast(decoder); - - auto ret = CreateMeshPredictionScheme< - MeshDecoder, PredictionSchemeDecoder, - MeshPredictionSchemeDecoderFactory>( - mesh_decoder, method, att_id, transform, decoder->bitstream_version()); - if (ret) - return ret; - // Otherwise try to create another prediction scheme. - } - // Create delta decoder. - return std::unique_ptr>( - new PredictionSchemeDeltaDecoder(att, transform)); -} - -// Create a prediction scheme using a default transform constructor. -template -std::unique_ptr> -CreatePredictionSchemeForDecoder(PredictionSchemeMethod method, int att_id, - const PointCloudDecoder *decoder) { - return CreatePredictionSchemeForDecoder( - method, att_id, decoder, TransformT()); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_FACTORY_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h deleted file mode 100644 index 6f19f7f..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_INTERFACE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_INTERFACE_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h" -#include "draco/core/decoder_buffer.h" - -// Prediction schemes can be used during encoding and decoding of attributes -// to predict attribute values based on the previously encoded/decoded data. -// See prediction_scheme.h for more details. -namespace draco { - -// Abstract interface for all prediction schemes used during attribute encoding. -class PredictionSchemeDecoderInterface : public PredictionSchemeInterface { - public: - // Method that can be used to decode any prediction scheme specific data - // from the input buffer. - virtual bool DecodePredictionData(DecoderBuffer *buffer) = 0; -}; - -// A specialized version of the prediction scheme interface for specific -// input and output data types. -// |entry_to_point_id_map| is the mapping between value entries to point ids -// of the associated point cloud, where one entry is defined as |num_components| -// values of the |in_data|. -// DataTypeT is the data type of input and predicted values. -// CorrTypeT is the data type used for storing corrected values. -template -class PredictionSchemeTypedDecoderInterface - : public PredictionSchemeDecoderInterface { - public: - // Reverts changes made by the prediction scheme during encoding. - virtual bool ComputeOriginalValues( - const CorrTypeT *in_corr, DataTypeT *out_data, int size, - int num_components, const PointIndex *entry_to_point_id_map) = 0; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODER_INTERFACE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h deleted file mode 100644 index 47c1532..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODING_TRANSFORM_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// PredictionSchemeDecodingTransform is used to transform predicted values and -// correction values into the final original attribute values. -// DataTypeT is the data type of predicted values. -// CorrTypeT is the data type used for storing corrected values. It allows -// transforms to store corrections into a different type or format compared to -// the predicted data. -template -class PredictionSchemeDecodingTransform { - public: - typedef CorrTypeT CorrType; - PredictionSchemeDecodingTransform() : num_components_(0) {} - - void Init(int num_components) { num_components_ = num_components; } - - // Computes the original value from the input predicted value and the decoded - // corrections. The default implementation is equal to std:plus. - inline void ComputeOriginalValue(const DataTypeT *predicted_vals, - const CorrTypeT *corr_vals, - DataTypeT *out_original_vals) const { - static_assert(std::is_same::value, - "For the default prediction transform, correction and input " - "data must be of the same type."); - for (int i = 0; i < num_components_; ++i) { - out_original_vals[i] = predicted_vals[i] + corr_vals[i]; - } - } - - // Decodes any transform specific data. Called before Init() method. - bool DecodeTransformData(DecoderBuffer * /* buffer */) { return true; } - - // Should return true if all corrected values are guaranteed to be positive. - bool AreCorrectionsPositive() const { return false; } - - protected: - int num_components() const { return num_components_; } - - private: - int num_components_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DECODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h deleted file mode 100644 index ae72c71..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_DECODER_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h" - -namespace draco { - -// Decoder for values encoded with delta coding. See the corresponding encoder -// for more details. -template -class PredictionSchemeDeltaDecoder - : public PredictionSchemeDecoder { - public: - using CorrType = - typename PredictionSchemeDecoder::CorrType; - // Initialized the prediction scheme. - explicit PredictionSchemeDeltaDecoder(const PointAttribute *attribute) - : PredictionSchemeDecoder(attribute) {} - PredictionSchemeDeltaDecoder(const PointAttribute *attribute, - const TransformT &transform) - : PredictionSchemeDecoder(attribute, transform) {} - - bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data, - int size, int num_components, - const PointIndex *entry_to_point_id_map) override; - PredictionSchemeMethod GetPredictionMethod() const override { - return PREDICTION_DIFFERENCE; - } - bool IsInitialized() const override { return true; } -}; - -template -bool PredictionSchemeDeltaDecoder::ComputeOriginalValues( - const CorrType *in_corr, DataTypeT *out_data, int size, int num_components, - const PointIndex *) { - this->transform().Init(num_components); - // Decode the original value for the first element. - std::unique_ptr zero_vals(new DataTypeT[num_components]()); - this->transform().ComputeOriginalValue(zero_vals.get(), in_corr, out_data); - - // Decode data from the front using D(i) = D(i) + D(i - 1). - for (int i = num_components; i < size; i += num_components) { - this->transform().ComputeOriginalValue(out_data + i - num_components, - in_corr + i, out_data + i); - } - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h deleted file mode 100644 index 324afaf..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h" - -namespace draco { - -// Basic prediction scheme based on computing backward differences between -// stored attribute values (also known as delta-coding). Usually works better -// than the reference point prediction scheme, because nearby values are often -// encoded next to each other. -template -class PredictionSchemeDeltaEncoder - : public PredictionSchemeEncoder { - public: - using CorrType = - typename PredictionSchemeEncoder::CorrType; - // Initialized the prediction scheme. - explicit PredictionSchemeDeltaEncoder(const PointAttribute *attribute) - : PredictionSchemeEncoder(attribute) {} - PredictionSchemeDeltaEncoder(const PointAttribute *attribute, - const TransformT &transform) - : PredictionSchemeEncoder(attribute, transform) {} - - bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrType *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) override; - PredictionSchemeMethod GetPredictionMethod() const override { - return PREDICTION_DIFFERENCE; - } - bool IsInitialized() const override { return true; } -}; - -template -bool PredictionSchemeDeltaEncoder< - DataTypeT, TransformT>::ComputeCorrectionValues(const DataTypeT *in_data, - CorrType *out_corr, - int size, - int num_components, - const PointIndex *) { - this->transform().Init(in_data, size, num_components); - // Encode data from the back using D(i) = D(i) - D(i - 1). - for (int i = size - num_components; i > 0; i -= num_components) { - this->transform().ComputeCorrection( - in_data + i, in_data + i - num_components, out_corr + i); - } - // Encode correction for the first element. - std::unique_ptr zero_vals(new DataTypeT[num_components]()); - this->transform().ComputeCorrection(in_data, zero_vals.get(), out_corr); - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_DELTA_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h deleted file mode 100644 index 548a54d..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_H_ - -#include - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h" - -// Prediction schemes can be used during encoding and decoding of vertex -// attributes to predict attribute values based on the previously -// encoded/decoded data. The differences between the original and predicted -// attribute values are used to compute correction values that can be usually -// encoded with fewer bits compared to the original data. -namespace draco { - -// Abstract base class for typed prediction schemes. It provides basic access -// to the encoded attribute and to the supplied prediction transform. -template > -class PredictionSchemeEncoder : public PredictionSchemeTypedEncoderInterface< - DataTypeT, typename TransformT::CorrType> { - public: - typedef DataTypeT DataType; - typedef TransformT Transform; - // Correction type needs to be defined in the prediction transform class. - typedef typename Transform::CorrType CorrType; - explicit PredictionSchemeEncoder(const PointAttribute *attribute) - : PredictionSchemeEncoder(attribute, Transform()) {} - PredictionSchemeEncoder(const PointAttribute *attribute, - const Transform &transform) - : attribute_(attribute), transform_(transform) {} - - bool EncodePredictionData(EncoderBuffer *buffer) override { - if (!transform_.EncodeTransformData(buffer)) - return false; - return true; - } - - const PointAttribute *GetAttribute() const override { return attribute(); } - - // Returns the number of parent attributes that are needed for the prediction. - int GetNumParentAttributes() const override { return 0; } - - // Returns the type of each of the parent attribute. - GeometryAttribute::Type GetParentAttributeType(int /* i */) const override { - return GeometryAttribute::INVALID; - } - - // Sets the required parent attribute. - bool SetParentAttribute(const PointAttribute * /* att */) override { - return false; - } - - bool AreCorrectionsPositive() override { - return transform_.AreCorrectionsPositive(); - } - - PredictionSchemeTransformType GetTransformType() const override { - return transform_.GetType(); - } - - protected: - inline const PointAttribute *attribute() const { return attribute_; } - inline const Transform &transform() const { return transform_; } - inline Transform &transform() { return transform_; } - - private: - const PointAttribute *attribute_; - Transform transform_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h deleted file mode 100644 index 4cc4001..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Functions for creating prediction schemes for encoders using the provided -// prediction method id. - -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_ - -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h" -#ifdef DRACO_NORMAL_ENCODING_SUPPORTED -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h" -#endif -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h" -#include "draco/compression/mesh/mesh_encoder.h" - -namespace draco { - -// Selects a prediction method based on the input geometry type and based on the -// encoder options. -PredictionSchemeMethod SelectPredictionMethod(int att_id, - const PointCloudEncoder *encoder); - -// Factory class for creating mesh prediction schemes. -template -struct MeshPredictionSchemeEncoderFactory { - template - std::unique_ptr> operator()( - PredictionSchemeMethod method, const PointAttribute *attribute, - const TransformT &transform, const MeshDataT &mesh_data, - uint16_t bitstream_version) { - if (method == MESH_PREDICTION_PARALLELOGRAM) { - return std::unique_ptr>( - new MeshPredictionSchemeParallelogramEncoder( - attribute, transform, mesh_data)); - } else if (method == MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM) { - return std::unique_ptr>( - new MeshPredictionSchemeConstrainedMultiParallelogramEncoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } else if (method == MESH_PREDICTION_TEX_COORDS_PORTABLE) { - return std::unique_ptr>( - new MeshPredictionSchemeTexCoordsPortableEncoder< - DataTypeT, TransformT, MeshDataT>(attribute, transform, - mesh_data)); - } -#ifdef DRACO_NORMAL_ENCODING_SUPPORTED - else if (method == MESH_PREDICTION_GEOMETRIC_NORMAL) { - return std::unique_ptr>( - new MeshPredictionSchemeGeometricNormalEncoder( - attribute, transform, mesh_data)); - } -#endif - return nullptr; - } -}; - -// Creates a prediction scheme for a given encoder and given prediction method. -// The prediction schemes are automatically initialized with encoder specific -// data if needed. -template -std::unique_ptr> -CreatePredictionSchemeForEncoder(PredictionSchemeMethod method, int att_id, - const PointCloudEncoder *encoder, - const TransformT &transform) { - const PointAttribute *const att = encoder->point_cloud()->attribute(att_id); - if (method == PREDICTION_UNDEFINED) { - method = SelectPredictionMethod(att_id, encoder); - } - if (method == PREDICTION_NONE) - return nullptr; // No prediction is used. - if (encoder->GetGeometryType() == TRIANGULAR_MESH) { - // Cast the encoder to mesh encoder. This is not necessarily safe if there - // is some other encoder decides to use TRIANGULAR_MESH as the return type, - // but unfortunately there is not nice work around for this without using - // RTTI (double dispatch and similar concepts will not work because of the - // template nature of the prediction schemes). - const MeshEncoder *const mesh_encoder = - static_cast(encoder); - auto ret = CreateMeshPredictionScheme< - MeshEncoder, PredictionSchemeEncoder, - MeshPredictionSchemeEncoderFactory>( - mesh_encoder, method, att_id, transform, kDracoMeshBitstreamVersion); - if (ret) - return ret; - // Otherwise try to create another prediction scheme. - } - // Create delta encoder. - return std::unique_ptr>( - new PredictionSchemeDeltaEncoder(att, transform)); -} - -// Create a prediction scheme using a default transform constructor. -template -std::unique_ptr> -CreatePredictionSchemeForEncoder(PredictionSchemeMethod method, int att_id, - const PointCloudEncoder *encoder) { - return CreatePredictionSchemeForEncoder( - method, att_id, encoder, TransformT()); -} - -// Returns the preferred prediction scheme based on the encoder options. -PredictionSchemeMethod GetPredictionMethodFromOptions( - int att_id, const EncoderOptions &options); - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODER_FACTORY_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h deleted file mode 100644 index ab64bce..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_INTERFACE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_INTERFACE_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h" -#include "draco/core/encoder_buffer.h" - -// Prediction schemes can be used during encoding and decoding of attributes -// to predict attribute values based on the previously encoded/decoded data. -// See prediction_scheme.h for more details. -namespace draco { - -// Abstract interface for all prediction schemes used during attribute encoding. -class PredictionSchemeEncoderInterface : public PredictionSchemeInterface { - public: - // Method that can be used to encode any prediction scheme specific data - // into the output buffer. - virtual bool EncodePredictionData(EncoderBuffer *buffer) = 0; -}; - -// A specialized version of the prediction scheme interface for specific -// input and output data types. -// |entry_to_point_id_map| is the mapping between value entries to point ids -// of the associated point cloud, where one entry is defined as |num_components| -// values of the |in_data|. -// DataTypeT is the data type of input and predicted values. -// CorrTypeT is the data type used for storing corrected values. -template -class PredictionSchemeTypedEncoderInterface - : public PredictionSchemeEncoderInterface { - public: - // Applies the prediction scheme when encoding the attribute. - // |in_data| contains value entries to be encoded. - // |out_corr| is an output array containing the to be encoded corrections. - virtual bool ComputeCorrectionValues( - const DataTypeT *in_data, CorrTypeT *out_corr, int size, - int num_components, const PointIndex *entry_to_point_id_map) = 0; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_INTERFACE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h deleted file mode 100644 index 0929492..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_TRANSFORM_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// PredictionSchemeEncodingTransform is used to transform predicted values into -// correction values. -// CorrTypeT is the data type used for storing corrected values. It allows -// transforms to store corrections into a different type or format compared to -// the predicted data. -template -class PredictionSchemeEncodingTransform { - public: - typedef CorrTypeT CorrType; - PredictionSchemeEncodingTransform() : num_components_(0) {} - - PredictionSchemeTransformType GetType() const { - return PREDICTION_TRANSFORM_DELTA; - } - - // Performs any custom initialization of the transform for the encoder. - // |size| = total number of values in |orig_data| (i.e., number of entries * - // number of components). - void Init(const DataTypeT * /* orig_data */, int /* size */, - int num_components) { - num_components_ = num_components; - } - - // Computes the corrections based on the input original values and the - // predicted values. The correction is always computed for all components - // of the input element. |val_id| is the id of the input value - // (i.e., element_id * num_components). The default implementation is equal to - // std::minus. - inline void ComputeCorrection(const DataTypeT *original_vals, - const DataTypeT *predicted_vals, - CorrTypeT *out_corr_vals) { - static_assert(std::is_same::value, - "For the default prediction transform, correction and input " - "data must be of the same type."); - for (int i = 0; i < num_components_; ++i) { - out_corr_vals[i] = original_vals[i] - predicted_vals[i]; - } - } - - // Encode any transform specific data. - bool EncodeTransformData(EncoderBuffer * /* buffer */) { return true; } - - // Should return true if all corrected values are guaranteed to be positive. - bool AreCorrectionsPositive() const { return false; } - - protected: - int num_components() const { return num_components_; } - - private: - int num_components_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_ENCODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h deleted file mode 100644 index 9fce686..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Functions for creating prediction schemes from a provided prediction method -// name. The functions in this file can create only basic prediction schemes -// that don't require any encoder or decoder specific data. To create more -// sophisticated prediction schemes, use functions from either -// prediction_scheme_encoder_factory.h or, -// prediction_scheme_decoder_factory.h. - -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_FACTORY_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_FACTORY_H_ - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -template -std::unique_ptr CreateMeshPredictionScheme( - const EncodingDataSourceT *source, PredictionSchemeMethod method, - int att_id, const typename PredictionSchemeT::Transform &transform, - uint16_t bitstream_version) { - const PointAttribute *const att = source->point_cloud()->attribute(att_id); - if (source->GetGeometryType() == TRIANGULAR_MESH && - (method == MESH_PREDICTION_PARALLELOGRAM || - method == MESH_PREDICTION_MULTI_PARALLELOGRAM || - method == MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM || - method == MESH_PREDICTION_TEX_COORDS_PORTABLE || - method == MESH_PREDICTION_GEOMETRIC_NORMAL || - method == MESH_PREDICTION_TEX_COORDS_DEPRECATED)) { - const CornerTable *const ct = source->GetCornerTable(); - const MeshAttributeIndicesEncodingData *const encoding_data = - source->GetAttributeEncodingData(att_id); - if (ct == nullptr || encoding_data == nullptr) { - // No connectivity data found. - return nullptr; - } - // Connectivity data exists. - const MeshAttributeCornerTable *const att_ct = - source->GetAttributeCornerTable(att_id); - if (att_ct != nullptr) { - typedef MeshPredictionSchemeData MeshData; - MeshData md; - md.Set(source->mesh(), att_ct, - &encoding_data->encoded_attribute_value_index_to_corner_map, - &encoding_data->vertex_to_encoded_attribute_value_index_map); - MeshPredictionSchemeFactoryT factory; - auto ret = factory(method, att, transform, md, bitstream_version); - if (ret) - return ret; - } else { - typedef MeshPredictionSchemeData MeshData; - MeshData md; - md.Set(source->mesh(), ct, - &encoding_data->encoded_attribute_value_index_to_corner_map, - &encoding_data->vertex_to_encoded_attribute_value_index_map); - MeshPredictionSchemeFactoryT factory; - auto ret = factory(method, att, transform, md, bitstream_version); - if (ret) - return ret; - } - } - return nullptr; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_FACTORY_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h deleted file mode 100644 index c9b3706..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_INTERFACE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_INTERFACE_H_ - -#include "draco/attributes/point_attribute.h" -#include "draco/compression/config/compression_shared.h" - -// Prediction schemes can be used during encoding and decoding of attributes -// to predict attribute values based on the previously encoded/decoded data. -// See prediction_scheme.h for more details. -namespace draco { - -// Abstract interface for all prediction schemes used during attribute encoding. -class PredictionSchemeInterface { - public: - virtual ~PredictionSchemeInterface() = default; - virtual PredictionSchemeMethod GetPredictionMethod() const = 0; - - // Returns the encoded attribute. - virtual const PointAttribute *GetAttribute() const = 0; - - // Returns true when the prediction scheme is initialized with all data it - // needs. - virtual bool IsInitialized() const = 0; - - // Returns the number of parent attributes that are needed for the prediction. - virtual int GetNumParentAttributes() const = 0; - - // Returns the type of each of the parent attribute. - virtual GeometryAttribute::Type GetParentAttributeType(int i) const = 0; - - // Sets the required parent attribute. - // Returns false if the attribute doesn't meet the requirements of the - // prediction scheme. - virtual bool SetParentAttribute(const PointAttribute *att) = 0; - - // Method should return true if the prediction scheme guarantees that all - // correction values are always positive (or at least non-negative). - virtual bool AreCorrectionsPositive() = 0; - - // Returns the transform type used by the prediction scheme. - virtual PredictionSchemeTransformType GetTransformType() const = 0; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_INTERFACE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h deleted file mode 100644 index 14ecb84..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_DECODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_DECODING_TRANSFORM_H_ - -#include - -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h" -#include "draco/core/decoder_buffer.h" -#include "draco/core/macros.h" -#include "draco/core/vector_d.h" - -namespace draco { - -// Class for converting correction values transformed by the canonicalized -// normal octahedron transform back to the original values. See the -// corresponding encoder for more details. -template -class PredictionSchemeNormalOctahedronCanonicalizedDecodingTransform - : public PredictionSchemeNormalOctahedronCanonicalizedTransformBase< - DataTypeT> { - public: - typedef VectorD Point2; - typedef DataTypeT CorrType; - typedef DataTypeT DataType; - - PredictionSchemeNormalOctahedronCanonicalizedDecodingTransform() {} - - // Dummy to fulfill concept. - void Init(int num_components) {} - - bool DecodeTransformData(DecoderBuffer *buffer) { - DataTypeT max_quantized_value, center_value; - if (!buffer->Decode(&max_quantized_value)) - return false; - if (!buffer->Decode(¢er_value)) - return false; - (void)center_value; - if (!this->set_max_quantized_value(max_quantized_value)) - return false; - // Account for reading wrong values, e.g., due to fuzzing. - if (this->quantization_bits() < 2) - return false; - if (this->quantization_bits() > 30) - return false; - return true; - } - - inline void ComputeOriginalValue(const DataType *pred_vals, - const CorrType *corr_vals, - DataType *out_orig_vals) const { - DRACO_DCHECK_LE(pred_vals[0], 2 * this->center_value()); - DRACO_DCHECK_LE(pred_vals[1], 2 * this->center_value()); - DRACO_DCHECK_LE(corr_vals[0], 2 * this->center_value()); - DRACO_DCHECK_LE(corr_vals[1], 2 * this->center_value()); - - DRACO_DCHECK_LE(0, pred_vals[0]); - DRACO_DCHECK_LE(0, pred_vals[1]); - DRACO_DCHECK_LE(0, corr_vals[0]); - DRACO_DCHECK_LE(0, corr_vals[1]); - - const Point2 pred = Point2(pred_vals[0], pred_vals[1]); - const Point2 corr = Point2(corr_vals[0], corr_vals[1]); - const Point2 orig = ComputeOriginalValue(pred, corr); - - out_orig_vals[0] = orig[0]; - out_orig_vals[1] = orig[1]; - } - - private: - Point2 ComputeOriginalValue(Point2 pred, Point2 corr) const { - const Point2 t(this->center_value(), this->center_value()); - pred = pred - t; - const bool pred_is_in_diamond = this->IsInDiamond(pred[0], pred[1]); - if (!pred_is_in_diamond) { - this->InvertDiamond(&pred[0], &pred[1]); - } - const bool pred_is_in_bottom_left = this->IsInBottomLeft(pred); - const int32_t rotation_count = this->GetRotationCount(pred); - if (!pred_is_in_bottom_left) { - pred = this->RotatePoint(pred, rotation_count); - } - Point2 orig = pred + corr; - orig[0] = this->ModMax(orig[0]); - orig[1] = this->ModMax(orig[1]); - if (!pred_is_in_bottom_left) { - const int32_t reverse_rotation_count = (4 - rotation_count) % 4; - orig = this->RotatePoint(orig, reverse_rotation_count); - } - if (!pred_is_in_diamond) { - this->InvertDiamond(&orig[0], &orig[1]); - } - orig = orig + t; - return orig; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_DECODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h deleted file mode 100644 index 0dc9696..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_ENCODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_ENCODING_TRANSFORM_H_ - -#include - -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/macros.h" -#include "draco/core/vector_d.h" - -namespace draco { - -// The transform works on octahedral coordinates for normals. The square is -// subdivided into four inner triangles (diamond) and four outer triangles. The -// inner triangles are associated with the upper part of the octahedron and the -// outer triangles are associated with the lower part. -// Given a prediction value P and the actual value Q that should be encoded, -// this transform first checks if P is outside the diamond. If so, the outer -// triangles are flipped towards the inside and vice versa. Then it checks if p -// is in the bottom left quadrant. If it is not, it rotates p and q accordingly. -// The actual correction value is then based on the mapped and rotated P and Q -// values. The inversion tends to result in shorter correction vectors and the -// rotation makes it so that all long correction values are positive, reducing -// the possible value range of the correction values and increasing the -// occurrences of positive large correction values, which helps the entropy -// encoder. This is possible since P is also known by the decoder, see also -// ComputeCorrection and ComputeOriginalValue functions. -// Note that the tile is not periodic, which implies that the outer edges can -// not be identified, which requires us to use an odd number of values on each -// axis. -// DataTypeT is expected to be some integral type. -// -template -class PredictionSchemeNormalOctahedronCanonicalizedEncodingTransform - : public PredictionSchemeNormalOctahedronCanonicalizedTransformBase< - DataTypeT> { - public: - typedef PredictionSchemeNormalOctahedronCanonicalizedTransformBase - Base; - typedef VectorD Point2; - typedef DataTypeT CorrType; - typedef DataTypeT DataType; - - // We expect the mod value to be of the form 2^b-1. - explicit PredictionSchemeNormalOctahedronCanonicalizedEncodingTransform( - DataType max_quantized_value) - : Base(max_quantized_value) {} - - // Dummy function to fulfill concept. - void Init(const DataTypeT *orig_data, int size, int num_components) {} - - bool EncodeTransformData(EncoderBuffer *buffer) { - buffer->Encode(this->max_quantized_value()); - buffer->Encode(this->center_value()); - return true; - } - - inline void ComputeCorrection(const DataType *orig_vals, - const DataType *pred_vals, - CorrType *out_corr_vals) const { - DRACO_DCHECK_LE(pred_vals[0], this->center_value() * 2); - DRACO_DCHECK_LE(pred_vals[1], this->center_value() * 2); - DRACO_DCHECK_LE(orig_vals[0], this->center_value() * 2); - DRACO_DCHECK_LE(orig_vals[1], this->center_value() * 2); - DRACO_DCHECK_LE(0, pred_vals[0]); - DRACO_DCHECK_LE(0, pred_vals[1]); - DRACO_DCHECK_LE(0, orig_vals[0]); - DRACO_DCHECK_LE(0, orig_vals[1]); - - const Point2 orig = Point2(orig_vals[0], orig_vals[1]); - const Point2 pred = Point2(pred_vals[0], pred_vals[1]); - const Point2 corr = ComputeCorrection(orig, pred); - - out_corr_vals[0] = corr[0]; - out_corr_vals[1] = corr[1]; - } - - private: - Point2 ComputeCorrection(Point2 orig, Point2 pred) const { - const Point2 t(this->center_value(), this->center_value()); - orig = orig - t; - pred = pred - t; - if (!this->IsInDiamond(pred[0], pred[1])) { - this->InvertDiamond(&orig[0], &orig[1]); - this->InvertDiamond(&pred[0], &pred[1]); - } - if (!this->IsInBottomLeft(pred)) { - const int32_t rotation_count = this->GetRotationCount(pred); - orig = this->RotatePoint(orig, rotation_count); - pred = this->RotatePoint(pred, rotation_count); - } - Point2 corr = orig - pred; - corr[0] = this->MakePositive(corr[0]); - corr[1] = this->MakePositive(corr[1]); - return corr; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_ENCODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h deleted file mode 100644 index 9810772..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_TRANSFORM_BASE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_TRANSFORM_BASE_H_ - -#include - -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/core/bit_utils.h" -#include "draco/core/macros.h" -#include "draco/core/vector_d.h" - -namespace draco { - -// Base class containing shared functionality used by both encoding and decoding -// canonicalized normal octahedron prediction scheme transforms. See the -// encoding transform for more details about the method. -template -class PredictionSchemeNormalOctahedronCanonicalizedTransformBase - : public PredictionSchemeNormalOctahedronTransformBase { - public: - typedef PredictionSchemeNormalOctahedronTransformBase Base; - typedef VectorD Point2; - typedef DataTypeT DataType; - - PredictionSchemeNormalOctahedronCanonicalizedTransformBase() : Base() {} - // We expect the mod value to be of the form 2^b-1. - explicit PredictionSchemeNormalOctahedronCanonicalizedTransformBase( - DataType mod_value) - : Base(mod_value) {} - - static constexpr PredictionSchemeTransformType GetType() { - return PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON_CANONICALIZED; - } - - int32_t GetRotationCount(Point2 pred) const { - const DataType sign_x = pred[0]; - const DataType sign_y = pred[1]; - - int32_t rotation_count = 0; - if (sign_x == 0) { - if (sign_y == 0) { - rotation_count = 0; - } else if (sign_y > 0) { - rotation_count = 3; - } else { - rotation_count = 1; - } - } else if (sign_x > 0) { - if (sign_y >= 0) { - rotation_count = 2; - } else { - rotation_count = 1; - } - } else { - if (sign_y <= 0) { - rotation_count = 0; - } else { - rotation_count = 3; - } - } - return rotation_count; - } - - Point2 RotatePoint(Point2 p, int32_t rotation_count) const { - switch (rotation_count) { - case 1: - return Point2(p[1], -p[0]); - case 2: - return Point2(-p[0], -p[1]); - case 3: - return Point2(-p[1], p[0]); - default: - return p; - } - } - - bool IsInBottomLeft(const Point2 &p) const { - if (p[0] == 0 && p[1] == 0) - return true; - return (p[0] < 0 && p[1] <= 0); - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_CANONICALIZED_TRANSFORM_BASE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h deleted file mode 100644 index dbb788a..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_DECODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_DECODING_TRANSFORM_H_ - -#include - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" -#include "draco/core/decoder_buffer.h" -#include "draco/core/macros.h" -#include "draco/core/vector_d.h" - -namespace draco { - -// Class for converting correction values transformed by the octahedral normal -// transform back to the original values. See the corresponding encoder for more -// details. -template -class PredictionSchemeNormalOctahedronDecodingTransform - : public PredictionSchemeNormalOctahedronTransformBase { - public: - typedef VectorD Point2; - typedef DataTypeT CorrType; - typedef DataTypeT DataType; - - PredictionSchemeNormalOctahedronDecodingTransform() {} - - // Dummy function to fulfill concept. - void Init(int num_components) {} - bool DecodeTransformData(DecoderBuffer *buffer) { - DataTypeT max_quantized_value, center_value; - if (!buffer->Decode(&max_quantized_value)) - return false; - if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - if (!buffer->Decode(¢er_value)) - return false; - } - (void)center_value; - return this->set_max_quantized_value(max_quantized_value); - } - - inline void ComputeOriginalValue(const DataType *pred_vals, - const CorrType *corr_vals, - DataType *out_orig_vals) const { - DRACO_DCHECK_LE(pred_vals[0], 2 * this->center_value()); - DRACO_DCHECK_LE(pred_vals[1], 2 * this->center_value()); - DRACO_DCHECK_LE(corr_vals[0], 2 * this->center_value()); - DRACO_DCHECK_LE(corr_vals[1], 2 * this->center_value()); - - DRACO_DCHECK_LE(0, pred_vals[0]); - DRACO_DCHECK_LE(0, pred_vals[1]); - DRACO_DCHECK_LE(0, corr_vals[0]); - DRACO_DCHECK_LE(0, corr_vals[1]); - - const Point2 pred = Point2(pred_vals[0], pred_vals[1]); - const Point2 corr = Point2(corr_vals[0], corr_vals[1]); - const Point2 orig = ComputeOriginalValue(pred, corr); - - out_orig_vals[0] = orig[0]; - out_orig_vals[1] = orig[1]; - } - - private: - Point2 ComputeOriginalValue(Point2 pred, const Point2 &corr) const { - const Point2 t(this->center_value(), this->center_value()); - pred = pred - t; - - const bool pred_is_in_diamond = this->IsInDiamond(pred[0], pred[1]); - if (!pred_is_in_diamond) { - this->InvertDiamond(&pred[0], &pred[1]); - } - Point2 orig = pred + corr; - orig[0] = this->ModMax(orig[0]); - orig[1] = this->ModMax(orig[1]); - if (!pred_is_in_diamond) { - this->InvertDiamond(&orig[0], &orig[1]); - } - orig = orig + t; - return orig; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_DECODING_TRANSFORM_H_ -#endif diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h deleted file mode 100644 index 4abfef6..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_ENCODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_ENCODING_TRANSFORM_H_ - -#include - -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/macros.h" -#include "draco/core/vector_d.h" - -namespace draco { - -// The transform works on octahedral coordinates for normals. The square is -// subdivided into four inner triangles (diamond) and four outer triangles. The -// inner triangles are associated with the upper part of the octahedron and the -// outer triangles are associated with the lower part. -// Given a prediction value P and the actual value Q that should be encoded, -// this transform first checks if P is outside the diamond. If so, the outer -// triangles are flipped towards the inside and vice versa. The actual -// correction value is then based on the mapped P and Q values. This tends to -// result in shorter correction vectors. -// This is possible since the P value is also known by the decoder, see also -// ComputeCorrection and ComputeOriginalValue functions. -// Note that the tile is not periodic, which implies that the outer edges can -// not be identified, which requires us to use an odd number of values on each -// axis. -// DataTypeT is expected to be some integral type. -// -template -class PredictionSchemeNormalOctahedronEncodingTransform - : public PredictionSchemeNormalOctahedronTransformBase { - public: - typedef PredictionSchemeNormalOctahedronTransformBase Base; - typedef VectorD Point2; - typedef DataTypeT CorrType; - typedef DataTypeT DataType; - - // We expect the mod value to be of the form 2^b-1. - explicit PredictionSchemeNormalOctahedronEncodingTransform( - DataType max_quantized_value) - : Base(max_quantized_value) {} - - void Init(const DataTypeT *orig_data, int size, int num_components) {} - - bool EncodeTransformData(EncoderBuffer *buffer) { - buffer->Encode(this->max_quantized_value()); - return true; - } - - inline void ComputeCorrection(const DataType *orig_vals, - const DataType *pred_vals, - CorrType *out_corr_vals) const { - DRACO_DCHECK_LE(pred_vals[0], this->center_value() * 2); - DRACO_DCHECK_LE(pred_vals[1], this->center_value() * 2); - DRACO_DCHECK_LE(orig_vals[0], this->center_value() * 2); - DRACO_DCHECK_LE(orig_vals[1], this->center_value() * 2); - DRACO_DCHECK_LE(0, pred_vals[0]); - DRACO_DCHECK_LE(0, pred_vals[1]); - DRACO_DCHECK_LE(0, orig_vals[0]); - DRACO_DCHECK_LE(0, orig_vals[1]); - - const Point2 orig = Point2(orig_vals[0], orig_vals[1]); - const Point2 pred = Point2(pred_vals[0], pred_vals[1]); - const Point2 corr = ComputeCorrection(orig, pred); - - out_corr_vals[0] = corr[0]; - out_corr_vals[1] = corr[1]; - } - - private: - Point2 ComputeCorrection(Point2 orig, Point2 pred) const { - const Point2 t(this->center_value(), this->center_value()); - orig = orig - t; - pred = pred - t; - - if (!this->IsInDiamond(pred[0], pred[1])) { - this->InvertDiamond(&orig[0], &orig[1]); - this->InvertDiamond(&pred[0], &pred[1]); - } - - Point2 corr = orig - pred; - corr[0] = this->MakePositive(corr[0]); - corr[1] = this->MakePositive(corr[1]); - return corr; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_ENCODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h deleted file mode 100644 index ff71fe8..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_TRANSFORM_BASE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_TRANSFORM_BASE_H_ - -#include - -#include "draco/compression/attributes/normal_compression_utils.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/core/bit_utils.h" -#include "draco/core/macros.h" -#include "draco/core/vector_d.h" - -namespace draco { - -// Base class containing shared functionality used by both encoding and decoding -// octahedral normal prediction scheme transforms. See the encoding transform -// for more details about the method. -template -class PredictionSchemeNormalOctahedronTransformBase { - public: - typedef VectorD Point2; - typedef DataTypeT DataType; - - PredictionSchemeNormalOctahedronTransformBase() {} - // We expect the mod value to be of the form 2^b-1. - explicit PredictionSchemeNormalOctahedronTransformBase( - DataType max_quantized_value) { - this->set_max_quantized_value(max_quantized_value); - } - - static constexpr PredictionSchemeTransformType GetType() { - return PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON; - } - - // We can return true as we keep correction values positive. - bool AreCorrectionsPositive() const { return true; } - - inline DataTypeT max_quantized_value() const { - return octahedron_tool_box_.max_quantized_value(); - } - inline DataTypeT center_value() const { - return octahedron_tool_box_.center_value(); - } - inline int32_t quantization_bits() const { - return octahedron_tool_box_.quantization_bits(); - } - - protected: - inline bool set_max_quantized_value(DataTypeT max_quantized_value) { - if (max_quantized_value % 2 == 0) - return false; - int q = MostSignificantBit(max_quantized_value) + 1; - return octahedron_tool_box_.SetQuantizationBits(q); - } - - bool IsInDiamond(DataTypeT s, DataTypeT t) const { - return octahedron_tool_box_.IsInDiamond(s, t); - } - void InvertDiamond(DataTypeT *s, DataTypeT *t) const { - return octahedron_tool_box_.InvertDiamond(s, t); - } - - int32_t ModMax(int32_t x) const { return octahedron_tool_box_.ModMax(x); } - - // For correction values. - int32_t MakePositive(int32_t x) const { - return octahedron_tool_box_.MakePositive(x); - } - - private: - OctahedronToolBox octahedron_tool_box_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_NORMAL_OCTAHEDRON_TRANSFORM_BASE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h deleted file mode 100644 index bd40df8..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_DECODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_DECODING_TRANSFORM_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h" -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// PredictionSchemeWrapDecodingTransform unwraps values encoded with the -// PredictionSchemeWrapEncodingTransform. -// See prediction_scheme_wrap_transform_base.h for more details about the -// method. -template -class PredictionSchemeWrapDecodingTransform - : public PredictionSchemeWrapTransformBase { - public: - typedef CorrTypeT CorrType; - PredictionSchemeWrapDecodingTransform() {} - - // Computes the original value from the input predicted value and the decoded - // corrections. Values out of the bounds of the input values are unwrapped. - inline void ComputeOriginalValue(const DataTypeT *predicted_vals, - const CorrTypeT *corr_vals, - DataTypeT *out_original_vals) const { - predicted_vals = this->ClampPredictedValue(predicted_vals); - for (int i = 0; i < this->num_components(); ++i) { - out_original_vals[i] = predicted_vals[i] + corr_vals[i]; - if (out_original_vals[i] > this->max_value()) - out_original_vals[i] -= this->max_dif(); - else if (out_original_vals[i] < this->min_value()) - out_original_vals[i] += this->max_dif(); - } - } - - bool DecodeTransformData(DecoderBuffer *buffer) { - DataTypeT min_value, max_value; - if (!buffer->Decode(&min_value)) - return false; - if (!buffer->Decode(&max_value)) - return false; - if (min_value > max_value) - return false; - this->set_min_value(min_value); - this->set_max_value(max_value); - if (!this->InitCorrectionBounds()) - return false; - return true; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_DECODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h deleted file mode 100644 index 8cd241f..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_ENCODING_TRANSFORM_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_ENCODING_TRANSFORM_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// PredictionSchemeWrapEncodingTransform wraps input values using the wrapping -// scheme described in: prediction_scheme_wrap_transform_base.h . -template -class PredictionSchemeWrapEncodingTransform - : public PredictionSchemeWrapTransformBase { - public: - typedef CorrTypeT CorrType; - PredictionSchemeWrapEncodingTransform() {} - - void Init(const DataTypeT *orig_data, int size, int num_components) { - PredictionSchemeWrapTransformBase::Init(num_components); - // Go over the original values and compute the bounds. - if (size == 0) - return; - DataTypeT min_value = orig_data[0]; - DataTypeT max_value = min_value; - for (int i = 1; i < size; ++i) { - if (orig_data[i] < min_value) - min_value = orig_data[i]; - else if (orig_data[i] > max_value) - max_value = orig_data[i]; - } - this->set_min_value(min_value); - this->set_max_value(max_value); - this->InitCorrectionBounds(); - } - - // Computes the corrections based on the input original value and the - // predicted value. Out of bound correction values are wrapped around the max - // range of input values. - inline void ComputeCorrection(const DataTypeT *original_vals, - const DataTypeT *predicted_vals, - CorrTypeT *out_corr_vals) const { - for (int i = 0; i < this->num_components(); ++i) { - predicted_vals = this->ClampPredictedValue(predicted_vals); - out_corr_vals[i] = original_vals[i] - predicted_vals[i]; - // Wrap around if needed. - DataTypeT &corr_val = out_corr_vals[i]; - if (corr_val < this->min_correction()) - corr_val += this->max_dif(); - else if (corr_val > this->max_correction()) - corr_val -= this->max_dif(); - } - } - - bool EncodeTransformData(EncoderBuffer *buffer) { - // Store the input value range as it is needed by the decoder. - buffer->Encode(this->min_value()); - buffer->Encode(this->max_value()); - return true; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_ENCODING_TRANSFORM_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h b/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h deleted file mode 100644 index cf52226..0000000 --- a/cloudreg_env/include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ - -#include - -#include "draco/compression/config/compression_shared.h" -#include "draco/core/macros.h" - -namespace draco { - -// PredictionSchemeWrapTransform uses the min and max bounds of the original -// data to wrap stored correction values around these bounds centered at 0, -// i.e., when the range of the original values O is between and -// N = MAX-MIN, we can then store any correction X = O - P, as: -// X + N, if X < -N / 2 -// X - N, if X > N / 2 -// X otherwise -// To unwrap this value, the decoder then simply checks whether the final -// corrected value F = P + X is out of the bounds of the input values. -// All out of bounds values are unwrapped using -// F + N, if F < MIN -// F - N, if F > MAX -// This wrapping can reduce the number of unique values, which translates to a -// better entropy of the stored values and better compression rates. -template -class PredictionSchemeWrapTransformBase { - public: - PredictionSchemeWrapTransformBase() - : num_components_(0), - min_value_(0), - max_value_(0), - max_dif_(0), - max_correction_(0), - min_correction_(0) {} - - static constexpr PredictionSchemeTransformType GetType() { - return PREDICTION_TRANSFORM_WRAP; - } - - void Init(int num_components) { - num_components_ = num_components; - clamped_value_.resize(num_components); - } - - bool AreCorrectionsPositive() const { return false; } - - inline const DataTypeT *ClampPredictedValue( - const DataTypeT *predicted_val) const { - for (int i = 0; i < this->num_components(); ++i) { - if (predicted_val[i] > max_value_) - clamped_value_[i] = max_value_; - else if (predicted_val[i] < min_value_) - clamped_value_[i] = min_value_; - else - clamped_value_[i] = predicted_val[i]; - } - return &clamped_value_[0]; - } - - // TODO(hemmer): Consider refactoring to avoid this dummy. - int quantization_bits() const { - DRACO_DCHECK(false); - return -1; - } - - protected: - bool InitCorrectionBounds() { - const int64_t dif = - static_cast(max_value_) - static_cast(min_value_); - if (dif < 0 || dif >= std::numeric_limits::max()) - return false; - max_dif_ = 1 + static_cast(dif); - max_correction_ = max_dif_ / 2; - min_correction_ = -max_correction_; - if ((max_dif_ & 1) == 0) - max_correction_ -= 1; - return true; - } - - inline int num_components() const { return num_components_; } - inline DataTypeT min_value() const { return min_value_; } - inline void set_min_value(const DataTypeT &v) { min_value_ = v; } - inline DataTypeT max_value() const { return max_value_; } - inline void set_max_value(const DataTypeT &v) { max_value_ = v; } - inline DataTypeT max_dif() const { return max_dif_; } - inline DataTypeT min_correction() const { return min_correction_; } - inline DataTypeT max_correction() const { return max_correction_; } - - private: - int num_components_; - DataTypeT min_value_; - DataTypeT max_value_; - DataTypeT max_dif_; - DataTypeT max_correction_; - DataTypeT min_correction_; - // This is in fact just a tmp variable to avoid reallocation. - mutable std::vector clamped_value_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_PREDICTION_SCHEME_WRAP_TRANSFORM_BASE_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_decoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_attribute_decoder.h deleted file mode 100644 index 721a587..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_decoder.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h" -#include "draco/compression/point_cloud/point_cloud_decoder.h" - -namespace draco { - -// A base class for decoding attribute values encoded by the -// SequentialAttributeEncoder. -class SequentialAttributeDecoder { - public: - SequentialAttributeDecoder(); - virtual ~SequentialAttributeDecoder() = default; - - virtual bool Init(PointCloudDecoder *decoder, int attribute_id); - - // Initialization for a specific attribute. This can be used mostly for - // standalone decoding of an attribute without an PointCloudDecoder. - virtual bool InitializeStandalone(PointAttribute *attribute); - - // Performs lossless decoding of the portable attribute data. - virtual bool DecodePortableAttribute(const std::vector &point_ids, - DecoderBuffer *in_buffer); - - // Decodes any data needed to revert portable transform of the decoded - // attribute. - virtual bool DecodeDataNeededByPortableTransform( - const std::vector &point_ids, DecoderBuffer *in_buffer); - - // Reverts transformation performed by encoder in - // SequentialAttributeEncoder::TransformAttributeToPortableFormat() method. - virtual bool TransformAttributeToOriginalFormat( - const std::vector &point_ids); - - const PointAttribute *GetPortableAttribute(); - - const PointAttribute *attribute() const { return attribute_; } - PointAttribute *attribute() { return attribute_; } - int attribute_id() const { return attribute_id_; } - PointCloudDecoder *decoder() const { return decoder_; } - - protected: - // Should be used to initialize newly created prediction scheme. - // Returns false when the initialization failed (in which case the scheme - // cannot be used). - virtual bool InitPredictionScheme(PredictionSchemeInterface *ps); - - // The actual implementation of the attribute decoding. Should be overridden - // for specialized decoders. - virtual bool DecodeValues(const std::vector &point_ids, - DecoderBuffer *in_buffer); - - void SetPortableAttribute(std::unique_ptr att) { - portable_attribute_ = std::move(att); - } - - PointAttribute *portable_attribute() { return portable_attribute_.get(); } - - private: - PointCloudDecoder *decoder_; - PointAttribute *attribute_; - int attribute_id_; - - // Storage for decoded portable attribute (after lossless decoding). - std::unique_ptr portable_attribute_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_decoders_controller.h b/cloudreg_env/include/draco/compression/attributes/sequential_attribute_decoders_controller.h deleted file mode 100644 index 9fd5e49..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_decoders_controller.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_H_ - -#include "draco/compression/attributes/attributes_decoder.h" -#include "draco/compression/attributes/points_sequencer.h" -#include "draco/compression/attributes/sequential_attribute_decoder.h" - -namespace draco { - -// A basic implementation of an attribute decoder that decodes data encoded by -// the SequentialAttributeEncodersController class. The -// SequentialAttributeDecodersController creates a single -// AttributeIndexedValuesDecoder for each of the decoded attribute, where the -// type of the values decoder is determined by the unique identifier that was -// encoded by the encoder. -class SequentialAttributeDecodersController : public AttributesDecoder { - public: - explicit SequentialAttributeDecodersController( - std::unique_ptr sequencer); - - bool DecodeAttributesDecoderData(DecoderBuffer *buffer) override; - bool DecodeAttributes(DecoderBuffer *buffer) override; - const PointAttribute *GetPortableAttribute( - int32_t point_attribute_id) override { - const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id); - if (loc_id < 0) - return nullptr; - return sequential_decoders_[loc_id]->GetPortableAttribute(); - } - - protected: - bool DecodePortableAttributes(DecoderBuffer *in_buffer) override; - bool DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer) override; - bool TransformAttributesToOriginalFormat() override; - virtual std::unique_ptr CreateSequentialDecoder( - uint8_t decoder_type); - - private: - std::vector> sequential_decoders_; - std::vector point_ids_; - std::unique_ptr sequencer_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_DECODERS_CONTROLLER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_encoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_attribute_encoder.h deleted file mode 100644 index 540ba94..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_encoder.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h" -#include "draco/compression/point_cloud/point_cloud_encoder.h" - -namespace draco { - -// A base class for encoding attribute values of a single attribute using a -// given sequence of point ids. The default implementation encodes all attribute -// values directly to the buffer but derived classes can perform any custom -// encoding (such as quantization) by overriding the EncodeValues() method. -class SequentialAttributeEncoder { - public: - SequentialAttributeEncoder(); - virtual ~SequentialAttributeEncoder() = default; - - // Method that can be used for custom initialization of an attribute encoder, - // such as creation of prediction schemes and initialization of attribute - // encoder dependencies. - // |encoder| is the parent PointCloudEncoder, - // |attribute_id| is the id of the attribute that is being encoded by this - // encoder. - // This method is automatically called by the PointCloudEncoder after all - // attribute encoders are created and it should not be called explicitly from - // other places. - virtual bool Init(PointCloudEncoder *encoder, int attribute_id); - - // Initialization for a specific attribute. This can be used mostly for - // standalone encoding of an attribute without an PointCloudEncoder. - virtual bool InitializeStandalone(PointAttribute *attribute); - - // Transforms attribute data into format that is going to be encoded - // losslessly. The transform itself can be lossy. - virtual bool TransformAttributeToPortableFormat( - const std::vector &point_ids); - - // Performs lossless encoding of the transformed attribute data. - virtual bool EncodePortableAttribute(const std::vector &point_ids, - EncoderBuffer *out_buffer); - - // Encodes any data related to the portable attribute transform. - virtual bool EncodeDataNeededByPortableTransform(EncoderBuffer *out_buffer); - - virtual bool IsLossyEncoder() const { return false; } - - int NumParentAttributes() const { - return static_cast(parent_attributes_.size()); - } - int GetParentAttributeId(int i) const { return parent_attributes_[i]; } - - const PointAttribute *GetPortableAttribute() const { - if (portable_attribute_ != nullptr) - return portable_attribute_.get(); - return attribute(); - } - - // Called when this attribute encoder becomes a parent encoder of another - // encoder. - void MarkParentAttribute(); - - virtual uint8_t GetUniqueId() const { - return SEQUENTIAL_ATTRIBUTE_ENCODER_GENERIC; - } - - const PointAttribute *attribute() const { return attribute_; } - int attribute_id() const { return attribute_id_; } - PointCloudEncoder *encoder() const { return encoder_; } - - protected: - // Should be used to initialize newly created prediction scheme. - // Returns false when the initialization failed (in which case the scheme - // cannot be used). - virtual bool InitPredictionScheme(PredictionSchemeInterface *ps); - - // Sets parent attributes for a given prediction scheme. Must be called - // after all prediction schemes are initialized, but before the prediction - // scheme is used. - virtual bool SetPredictionSchemeParentAttributes( - PredictionSchemeInterface *ps); - - // Encodes all attribute values in the specified order. Should be overridden - // for specialized encoders. - virtual bool EncodeValues(const std::vector &point_ids, - EncoderBuffer *out_buffer); - - bool is_parent_encoder() const { return is_parent_encoder_; } - - void SetPortableAttribute(std::unique_ptr att) { - portable_attribute_ = std::move(att); - } - - // Returns a mutable attribute that should be filled by derived encoders with - // the transformed version of the attribute data. To get a public const - // version, use the GetPortableAttribute() method. - PointAttribute *portable_attribute() { return portable_attribute_.get(); } - - private: - PointCloudEncoder *encoder_; - const PointAttribute *attribute_; - int attribute_id_; - - // List of attribute encoders that need to be encoded before this attribute. - // E.g. The parent attributes may be used to predict values used by this - // attribute encoder. - std::vector parent_attributes_; - - bool is_parent_encoder_; - - // Attribute that stores transformed data from the source attribute after it - // is processed through the ApplyTransform() method. Attribute data stored - // within this attribute is guaranteed to be encoded losslessly and it can be - // safely used for prediction of other attributes. - std::unique_ptr portable_attribute_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_encoders_controller.h b/cloudreg_env/include/draco/compression/attributes/sequential_attribute_encoders_controller.h deleted file mode 100644 index d5574ab..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_attribute_encoders_controller.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_H_ - -#include "draco/compression/attributes/attributes_encoder.h" -#include "draco/compression/attributes/points_sequencer.h" -#include "draco/compression/attributes/sequential_attribute_encoder.h" - -namespace draco { - -// A basic implementation of an attribute encoder that can be used to encode -// an arbitrary set of attributes. The encoder creates a sequential attribute -// encoder for each encoded attribute (see sequential_attribute_encoder.h) and -// then it encodes all attribute values in an order defined by a point sequence -// generated in the GeneratePointSequence() method. The default implementation -// generates a linear sequence of all points, but derived classes can generate -// any custom sequence. -class SequentialAttributeEncodersController : public AttributesEncoder { - public: - explicit SequentialAttributeEncodersController( - std::unique_ptr sequencer); - SequentialAttributeEncodersController( - std::unique_ptr sequencer, int point_attrib_id); - - bool Init(PointCloudEncoder *encoder, const PointCloud *pc) override; - bool EncodeAttributesEncoderData(EncoderBuffer *out_buffer) override; - bool EncodeAttributes(EncoderBuffer *buffer) override; - uint8_t GetUniqueId() const override { return BASIC_ATTRIBUTE_ENCODER; } - - int NumParentAttributes(int32_t point_attribute_id) const override { - const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id); - if (loc_id < 0) - return 0; - return sequential_encoders_[loc_id]->NumParentAttributes(); - } - - int GetParentAttributeId(int32_t point_attribute_id, - int32_t parent_i) const override { - const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id); - if (loc_id < 0) - return -1; - return sequential_encoders_[loc_id]->GetParentAttributeId(parent_i); - } - - bool MarkParentAttribute(int32_t point_attribute_id) override { - const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id); - if (loc_id < 0) - return false; - // Mark the attribute encoder as parent (even when if it is not created - // yet). - if (sequential_encoder_marked_as_parent_.size() <= loc_id) { - sequential_encoder_marked_as_parent_.resize(loc_id + 1, false); - } - sequential_encoder_marked_as_parent_[loc_id] = true; - - if (sequential_encoders_.size() <= loc_id) - return true; // Sequential encoders not generated yet. - sequential_encoders_[loc_id]->MarkParentAttribute(); - return true; - } - - const PointAttribute *GetPortableAttribute( - int32_t point_attribute_id) override { - const int32_t loc_id = GetLocalIdForPointAttribute(point_attribute_id); - if (loc_id < 0) - return nullptr; - return sequential_encoders_[loc_id]->GetPortableAttribute(); - } - - protected: - bool TransformAttributesToPortableFormat() override; - bool EncodePortableAttributes(EncoderBuffer *out_buffer) override; - bool EncodeDataNeededByPortableTransforms(EncoderBuffer *out_buffer) override; - - // Creates all sequential encoders (one for each attribute associated with the - // encoder). - virtual bool CreateSequentialEncoders(); - - // Create a sequential encoder for a given attribute based on the attribute - // type - // and the provided encoder options. - virtual std::unique_ptr CreateSequentialEncoder( - int i); - - private: - std::vector> sequential_encoders_; - - // Flag for each sequential attribute encoder indicating whether it was marked - // as parent attribute or not. - std::vector sequential_encoder_marked_as_parent_; - std::vector point_ids_; - std::unique_ptr sequencer_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_ATTRIBUTE_ENCODERS_CONTROLLER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_integer_attribute_decoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_integer_attribute_decoder.h deleted file mode 100644 index 150ae1f..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_integer_attribute_decoder.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h" -#include "draco/compression/attributes/sequential_attribute_decoder.h" - -namespace draco { - -// Decoder for attributes encoded with the SequentialIntegerAttributeEncoder. -class SequentialIntegerAttributeDecoder : public SequentialAttributeDecoder { - public: - SequentialIntegerAttributeDecoder(); - bool Init(PointCloudDecoder *decoder, int attribute_id) override; - - bool TransformAttributeToOriginalFormat( - const std::vector &point_ids) override; - - protected: - bool DecodeValues(const std::vector &point_ids, - DecoderBuffer *in_buffer) override; - virtual bool DecodeIntegerValues(const std::vector &point_ids, - DecoderBuffer *in_buffer); - - // Returns a prediction scheme that should be used for decoding of the - // integer values. - virtual std::unique_ptr> - CreateIntPredictionScheme(PredictionSchemeMethod method, - PredictionSchemeTransformType transform_type); - - // Returns the number of integer attribute components. In general, this - // can be different from the number of components of the input attribute. - virtual int32_t GetNumValueComponents() const { - return attribute()->num_components(); - } - - // Called after all integer values are decoded. The implementation should - // use this method to store the values into the attribute. - virtual bool StoreValues(uint32_t num_values); - - void PreparePortableAttribute(int num_entries, int num_components); - - int32_t *GetPortableAttributeData() { - if (portable_attribute()->size() == 0) - return nullptr; - return reinterpret_cast( - portable_attribute()->GetAddress(AttributeValueIndex(0))); - } - - private: - // Stores decoded values into the attribute with a data type AttributeTypeT. - template - void StoreTypedValues(uint32_t num_values); - - std::unique_ptr> - prediction_scheme_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_integer_attribute_encoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_integer_attribute_encoder.h deleted file mode 100644 index c1d6222..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_integer_attribute_encoder.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_H_ - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h" -#include "draco/compression/attributes/sequential_attribute_encoder.h" - -namespace draco { - -// Attribute encoder designed for lossless encoding of integer attributes. The -// attribute values can be pre-processed by a prediction scheme and compressed -// with a built-in entropy coder. -class SequentialIntegerAttributeEncoder : public SequentialAttributeEncoder { - public: - SequentialIntegerAttributeEncoder(); - uint8_t GetUniqueId() const override { - return SEQUENTIAL_ATTRIBUTE_ENCODER_INTEGER; - } - - bool Init(PointCloudEncoder *encoder, int attribute_id) override; - bool TransformAttributeToPortableFormat( - const std::vector &point_ids) override; - - protected: - bool EncodeValues(const std::vector &point_ids, - EncoderBuffer *out_buffer) override; - - // Returns a prediction scheme that should be used for encoding of the - // integer values. - virtual std::unique_ptr> - CreateIntPredictionScheme(PredictionSchemeMethod method); - - // Prepares the integer values that are going to be encoded. - virtual bool PrepareValues(const std::vector &point_ids, - int num_points); - - void PreparePortableAttribute(int num_entries, int num_components, - int num_points); - - int32_t *GetPortableAttributeData() { - return reinterpret_cast( - portable_attribute()->GetAddress(AttributeValueIndex(0))); - } - - private: - // Optional prediction scheme can be used to modify the integer values in - // order to make them easier to compress. - std::unique_ptr> - prediction_scheme_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_INTEGER_ATTRIBUTE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_normal_attribute_decoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_normal_attribute_decoder.h deleted file mode 100644 index d6439fc..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_normal_attribute_decoder.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h" -#include "draco/compression/attributes/sequential_integer_attribute_decoder.h" - -namespace draco { - -// Decoder for attributes encoded with SequentialNormalAttributeEncoder. -class SequentialNormalAttributeDecoder - : public SequentialIntegerAttributeDecoder { - public: - SequentialNormalAttributeDecoder(); - bool Init(PointCloudDecoder *decoder, int attribute_id) override; - - protected: - int32_t GetNumValueComponents() const override { - return 2; // We quantize everything into two components. - } - bool DecodeIntegerValues(const std::vector &point_ids, - DecoderBuffer *in_buffer) override; - bool DecodeDataNeededByPortableTransform( - const std::vector &point_ids, - DecoderBuffer *in_buffer) override; - bool StoreValues(uint32_t num_points) override; - - private: - int32_t quantization_bits_; - - std::unique_ptr> - CreateIntPredictionScheme( - PredictionSchemeMethod method, - PredictionSchemeTransformType transform_type) override { - switch (transform_type) { -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - case PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON: { - typedef PredictionSchemeNormalOctahedronDecodingTransform - Transform; - // At this point the decoder has not read the quantization bits, - // which is why we must construct the transform by default. - // See Transform.DecodeTransformData for more details. - return CreatePredictionSchemeForDecoder( - method, attribute_id(), decoder()); - } -#endif - case PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON_CANONICALIZED: { - typedef PredictionSchemeNormalOctahedronCanonicalizedDecodingTransform< - int32_t> - Transform; - // At this point the decoder has not read the quantization bits, - // which is why we must construct the transform by default. - // See Transform.DecodeTransformData for more details. - return CreatePredictionSchemeForDecoder( - method, attribute_id(), decoder()); - } - default: - return nullptr; // Currently, we support only octahedron transform and - // octahedron transform canonicalized. - } - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_normal_attribute_encoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_normal_attribute_encoder.h deleted file mode 100644 index 53705c5..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_normal_attribute_encoder.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_H_ - -#include "draco/attributes/attribute_octahedron_transform.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h" -#include "draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h" -#include "draco/compression/attributes/sequential_integer_attribute_encoder.h" -#include "draco/compression/config/compression_shared.h" - -namespace draco { - -// Class for encoding normal vectors using an octahedral encoding, see Cigolle -// et al.'14 “A Survey of Efficient Representations for Independent Unit -// Vectors”. Compared to the basic quantization encoder, this encoder results -// in a better compression rate under the same accuracy settings. Note that this -// encoder doesn't preserve the lengths of input vectors, therefore it will not -// work correctly when the input values are not normalized. -class SequentialNormalAttributeEncoder - : public SequentialIntegerAttributeEncoder { - public: - uint8_t GetUniqueId() const override { - return SEQUENTIAL_ATTRIBUTE_ENCODER_NORMALS; - } - bool IsLossyEncoder() const override { return true; } - - bool EncodeDataNeededByPortableTransform(EncoderBuffer *out_buffer) override; - - protected: - bool Init(PointCloudEncoder *encoder, int attribute_id) override; - - // Put quantized values in portable attribute for sequential encoding. - bool PrepareValues(const std::vector &point_ids, - int num_points) override; - - std::unique_ptr> - CreateIntPredictionScheme(PredictionSchemeMethod /* method */) override { - typedef PredictionSchemeNormalOctahedronCanonicalizedEncodingTransform< - int32_t> - Transform; - const int32_t quantization_bits = encoder()->options()->GetAttributeInt( - attribute_id(), "quantization_bits", -1); - const int32_t max_value = (1 << quantization_bits) - 1; - const Transform transform(max_value); - const PredictionSchemeMethod default_prediction_method = - SelectPredictionMethod(attribute_id(), encoder()); - const int32_t prediction_method = encoder()->options()->GetAttributeInt( - attribute_id(), "prediction_scheme", default_prediction_method); - - if (prediction_method == MESH_PREDICTION_GEOMETRIC_NORMAL) { - return CreatePredictionSchemeForEncoder( - MESH_PREDICTION_GEOMETRIC_NORMAL, attribute_id(), encoder(), - transform); - } - if (prediction_method == PREDICTION_DIFFERENCE) { - return CreatePredictionSchemeForEncoder( - PREDICTION_DIFFERENCE, attribute_id(), encoder(), transform); - } - DRACO_DCHECK(false); // Should never be reached. - return nullptr; - } - - // Used for the conversion to quantized normals in octahedral format. - AttributeOctahedronTransform attribute_octahedron_transform_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_NORMAL_ATTRIBUTE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_quantization_attribute_decoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_quantization_attribute_decoder.h deleted file mode 100644 index 27d88be..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_quantization_attribute_decoder.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/sequential_integer_attribute_decoder.h" - -namespace draco { - -// Decoder for attribute values encoded with the -// SequentialQuantizationAttributeEncoder. -class SequentialQuantizationAttributeDecoder - : public SequentialIntegerAttributeDecoder { - public: - SequentialQuantizationAttributeDecoder(); - bool Init(PointCloudDecoder *decoder, int attribute_id) override; - - protected: - bool DecodeIntegerValues(const std::vector &point_ids, - DecoderBuffer *in_buffer) override; - bool DecodeDataNeededByPortableTransform( - const std::vector &point_ids, - DecoderBuffer *in_buffer) override; - bool StoreValues(uint32_t num_points) override; - - // Decodes data necessary for dequantizing the encoded values. - virtual bool DecodeQuantizedDataInfo(); - - // Dequantizes all values and stores them into the output attribute. - virtual bool DequantizeValues(uint32_t num_values); - - private: - // Max number of quantization bits used to encode each component of the - // attribute. - int32_t quantization_bits_; - - std::unique_ptr min_value_; - float max_value_dif_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_QUANTIZATION_ATTRIBUTE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/attributes/sequential_quantization_attribute_encoder.h b/cloudreg_env/include/draco/compression/attributes/sequential_quantization_attribute_encoder.h deleted file mode 100644 index e9762bd..0000000 --- a/cloudreg_env/include/draco/compression/attributes/sequential_quantization_attribute_encoder.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_H_ -#define DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_H_ - -#include "draco/attributes/attribute_quantization_transform.h" -#include "draco/compression/attributes/sequential_integer_attribute_encoder.h" - -namespace draco { - -class MeshEncoder; - -// Attribute encoder that quantizes floating point attribute values. The -// quantized values can be optionally compressed using an entropy coding. -class SequentialQuantizationAttributeEncoder - : public SequentialIntegerAttributeEncoder { - public: - SequentialQuantizationAttributeEncoder(); - uint8_t GetUniqueId() const override { - return SEQUENTIAL_ATTRIBUTE_ENCODER_QUANTIZATION; - } - bool Init(PointCloudEncoder *encoder, int attribute_id) override; - - bool IsLossyEncoder() const override { return true; } - - bool EncodeDataNeededByPortableTransform(EncoderBuffer *out_buffer) override; - - protected: - // Put quantized values in portable attribute for sequential encoding. - bool PrepareValues(const std::vector &point_ids, - int num_points) override; - - private: - // Used for the quantization. - AttributeQuantizationTransform attribute_quantization_transform_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ATTRIBUTES_SEQUENTIAL_QUANTIZATION_ATTRIBUTE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h b/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h deleted file mode 100644 index faacbd5..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides shared functions for adaptive rANS bit coding. -#ifndef DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_CODING_SHARED_H_ -#define DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_CODING_SHARED_H_ - -#include "draco/core/macros.h" - -namespace draco { - -// Clamp the probability p to a uint8_t in the range [1,255]. -inline uint8_t clamp_probability(double p) { - DRACO_DCHECK_LE(p, 1.0); - DRACO_DCHECK_LE(0.0, p); - uint32_t p_int = static_cast((p * 256) + 0.5); - p_int -= (p_int == 256); - p_int += (p_int == 0); - return static_cast(p_int); -} - -// Update the probability according to new incoming bit. -inline double update_probability(double old_p, bool bit) { - static constexpr double w = 128.0; - static constexpr double w0 = (w - 1.0) / w; - static constexpr double w1 = 1.0 / w; - return old_p * w0 + (!bit) * w1; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_CODING_SHARED_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h b/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h deleted file mode 100644 index a1ea011..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides basic classes and functions for rANS bit decoding. -#ifndef DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_DECODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_DECODER_H_ - -#include - -#include "draco/compression/entropy/ans.h" -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// Class for decoding a sequence of bits that were encoded with -// AdaptiveRAnsBitEncoder. -class AdaptiveRAnsBitDecoder { - public: - AdaptiveRAnsBitDecoder(); - ~AdaptiveRAnsBitDecoder(); - - // Sets |source_buffer| as the buffer to decode bits from. - bool StartDecoding(DecoderBuffer *source_buffer); - - // Decode one bit. Returns true if the bit is a 1, otherwise false. - bool DecodeNextBit(); - - // Decode the next |nbits| and return the sequence in |value|. |nbits| must be - // > 0 and <= 32. - void DecodeLeastSignificantBits32(int nbits, uint32_t *value); - - void EndDecoding() {} - - private: - void Clear(); - - AnsDecoder ans_decoder_; - double p0_f_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h b/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h deleted file mode 100644 index 9b18328..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides basic classes and functions for rANS bit encoding. -#ifndef DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_ENCODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_ENCODER_H_ - -#include - -#include "draco/compression/entropy/ans.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// Class for adaptive encoding a sequence of bits using rANS. -class AdaptiveRAnsBitEncoder { - public: - AdaptiveRAnsBitEncoder(); - ~AdaptiveRAnsBitEncoder(); - - // Must be called before any Encode* function is called. - void StartEncoding(); - - // Encode one bit. If |bit| is true encode a 1, otherwise encode a 0. - void EncodeBit(bool bit) { bits_.push_back(bit); } - - // Encode |nbits| of |value|, starting from the least significant bit. - // |nbits| must be > 0 and <= 32. - void EncodeLeastSignificantBits32(int nbits, uint32_t value) { - DRACO_DCHECK_EQ(true, nbits <= 32); - DRACO_DCHECK_EQ(true, nbits > 0); - uint32_t selector = (1 << (nbits - 1)); - while (selector) { - EncodeBit(value & selector); - selector = selector >> 1; - } - } - - // Ends the bit encoding and stores the result into the target_buffer. - void EndEncoding(EncoderBuffer *target_buffer); - - private: - void Clear(); - - std::vector bits_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_ADAPTIVE_RANS_BIT_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/direct_bit_decoder.h b/cloudreg_env/include/draco/compression/bit_coders/direct_bit_decoder.h deleted file mode 100644 index b9fbc2d..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/direct_bit_decoder.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides direct encoding of bits with arithmetic encoder interface. -#ifndef DRACO_COMPRESSION_BIT_CODERS_DIRECT_BIT_DECODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_DIRECT_BIT_DECODER_H_ - -#include - -#include "draco/core/decoder_buffer.h" - -namespace draco { - -class DirectBitDecoder { - public: - DirectBitDecoder(); - ~DirectBitDecoder(); - - // Sets |source_buffer| as the buffer to decode bits from. - bool StartDecoding(DecoderBuffer *source_buffer); - - // Decode one bit. Returns true if the bit is a 1, otherwise false. - bool DecodeNextBit() { - const uint32_t selector = 1 << (31 - num_used_bits_); - if (pos_ == bits_.end()) { - return false; - } - const bool bit = *pos_ & selector; - ++num_used_bits_; - if (num_used_bits_ == 32) { - ++pos_; - num_used_bits_ = 0; - } - return bit; - } - - // Decode the next |nbits| and return the sequence in |value|. |nbits| must be - // > 0 and <= 32. - void DecodeLeastSignificantBits32(int nbits, uint32_t *value) { - DRACO_DCHECK_EQ(true, nbits <= 32); - DRACO_DCHECK_EQ(true, nbits > 0); - const int remaining = 32 - num_used_bits_; - if (nbits <= remaining) { - if (pos_ == bits_.end()) { - *value = 0; - return; - } - *value = (*pos_ << num_used_bits_) >> (32 - nbits); - num_used_bits_ += nbits; - if (num_used_bits_ == 32) { - ++pos_; - num_used_bits_ = 0; - } - } else { - if (pos_ + 1 == bits_.end()) { - *value = 0; - return; - } - const uint32_t value_l = ((*pos_) << num_used_bits_); - num_used_bits_ = nbits - remaining; - ++pos_; - const uint32_t value_r = (*pos_) >> (32 - num_used_bits_); - *value = (value_l >> (32 - num_used_bits_ - remaining)) | value_r; - } - } - - void EndDecoding() {} - - private: - void Clear(); - - std::vector bits_; - std::vector::const_iterator pos_; - uint32_t num_used_bits_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_DIRECT_BIT_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/direct_bit_encoder.h b/cloudreg_env/include/draco/compression/bit_coders/direct_bit_encoder.h deleted file mode 100644 index 705b2ca..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/direct_bit_encoder.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides direct encoding of bits with arithmetic encoder interface. -#ifndef DRACO_COMPRESSION_BIT_CODERS_DIRECT_BIT_ENCODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_DIRECT_BIT_ENCODER_H_ - -#include - -#include "draco/core/encoder_buffer.h" - -namespace draco { - -class DirectBitEncoder { - public: - DirectBitEncoder(); - ~DirectBitEncoder(); - - // Must be called before any Encode* function is called. - void StartEncoding(); - - // Encode one bit. If |bit| is true encode a 1, otherwise encode a 0. - void EncodeBit(bool bit) { - if (bit) { - local_bits_ |= 1 << (31 - num_local_bits_); - } - num_local_bits_++; - if (num_local_bits_ == 32) { - bits_.push_back(local_bits_); - num_local_bits_ = 0; - local_bits_ = 0; - } - } - - // Encode |nbits| of |value|, starting from the least significant bit. - // |nbits| must be > 0 and <= 32. - void EncodeLeastSignificantBits32(int nbits, uint32_t value) { - DRACO_DCHECK_EQ(true, nbits <= 32); - DRACO_DCHECK_EQ(true, nbits > 0); - - const int remaining = 32 - num_local_bits_; - - // Make sure there are no leading bits that should not be encoded and - // start from here. - value = value << (32 - nbits); - if (nbits <= remaining) { - value = value >> num_local_bits_; - local_bits_ = local_bits_ | value; - num_local_bits_ += nbits; - if (num_local_bits_ == 32) { - bits_.push_back(local_bits_); - local_bits_ = 0; - num_local_bits_ = 0; - } - } else { - value = value >> (32 - nbits); - num_local_bits_ = nbits - remaining; - const uint32_t value_l = value >> num_local_bits_; - local_bits_ = local_bits_ | value_l; - bits_.push_back(local_bits_); - local_bits_ = value << (32 - num_local_bits_); - } - } - - // Ends the bit encoding and stores the result into the target_buffer. - void EndEncoding(EncoderBuffer *target_buffer); - - private: - void Clear(); - - std::vector bits_; - uint32_t local_bits_; - uint32_t num_local_bits_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_DIRECT_BIT_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/folded_integer_bit_decoder.h b/cloudreg_env/include/draco/compression/bit_coders/folded_integer_bit_decoder.h deleted file mode 100644 index 9f8bedd..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/folded_integer_bit_decoder.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides direct encoding of bits with arithmetic encoder interface. -#ifndef DRACO_COMPRESSION_BIT_CODERS_FOLDED_INTEGER_BIT_DECODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_FOLDED_INTEGER_BIT_DECODER_H_ - -#include - -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// See FoldedBit32Encoder for more details. -template -class FoldedBit32Decoder { - public: - FoldedBit32Decoder() {} - ~FoldedBit32Decoder() {} - - // Sets |source_buffer| as the buffer to decode bits from. - bool StartDecoding(DecoderBuffer *source_buffer) { - for (int i = 0; i < 32; i++) { - if (!folded_number_decoders_[i].StartDecoding(source_buffer)) - return false; - } - return bit_decoder_.StartDecoding(source_buffer); - } - - // Decode one bit. Returns true if the bit is a 1, otherwise false. - bool DecodeNextBit() { return bit_decoder_.DecodeNextBit(); } - - // Decode the next |nbits| and return the sequence in |value|. |nbits| must be - // > 0 and <= 32. - void DecodeLeastSignificantBits32(int nbits, uint32_t *value) { - uint32_t result = 0; - for (int i = 0; i < nbits; ++i) { - const bool bit = folded_number_decoders_[i].DecodeNextBit(); - result = (result << 1) + bit; - } - *value = result; - } - - void EndDecoding() { - for (int i = 0; i < 32; i++) { - folded_number_decoders_[i].EndDecoding(); - } - bit_decoder_.EndDecoding(); - } - - private: - void Clear() { - for (int i = 0; i < 32; i++) { - folded_number_decoders_[i].Clear(); - } - bit_decoder_.Clear(); - } - - std::array folded_number_decoders_; - BitDecoderT bit_decoder_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_FOLDED_INTEGER_BIT_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/folded_integer_bit_encoder.h b/cloudreg_env/include/draco/compression/bit_coders/folded_integer_bit_encoder.h deleted file mode 100644 index 375b38a..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/folded_integer_bit_encoder.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides direct encoding of bits with arithmetic encoder interface. -#ifndef DRACO_COMPRESSION_BIT_CODERS_FOLDED_INTEGER_BIT_ENCODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_FOLDED_INTEGER_BIT_ENCODER_H_ - -#include - -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// This coding scheme considers every bit of an (up to) 32bit integer as a -// separate context. This can be a significant advantage when encoding numbers -// where it is more likely that the front bits are zero. -// The behavior is essentially the same as other arithmetic encoding schemes, -// the only difference is that encoding and decoding of bits must be absolutely -// symmetric, bits handed in by EncodeBit32 must be also decoded in this way. -// This is the FoldedBit32Encoder, see also FoldedBit32Decoder. -template -class FoldedBit32Encoder { - public: - FoldedBit32Encoder() {} - ~FoldedBit32Encoder() {} - - // Must be called before any Encode* function is called. - void StartEncoding() { - for (int i = 0; i < 32; i++) { - folded_number_encoders_[i].StartEncoding(); - } - bit_encoder_.StartEncoding(); - } - - // Encode one bit. If |bit| is true encode a 1, otherwise encode a 0. - void EncodeBit(bool bit) { bit_encoder_.EncodeBit(bit); } - - // Encode |nbits| of |value|, starting from the least significant bit. - // |nbits| must be > 0 and <= 32. - void EncodeLeastSignificantBits32(int nbits, uint32_t value) { - uint32_t selector = 1 << (nbits - 1); - for (int i = 0; i < nbits; i++) { - const bool bit = (value & selector); - folded_number_encoders_[i].EncodeBit(bit); - selector = selector >> 1; - } - } - - // Ends the bit encoding and stores the result into the target_buffer. - void EndEncoding(EncoderBuffer *target_buffer) { - for (int i = 0; i < 32; i++) { - folded_number_encoders_[i].EndEncoding(target_buffer); - } - bit_encoder_.EndEncoding(target_buffer); - } - - private: - void Clear() { - for (int i = 0; i < 32; i++) { - folded_number_encoders_[i].Clear(); - } - bit_encoder_.Clear(); - } - - std::array folded_number_encoders_; - BitEncoderT bit_encoder_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_FOLDED_INTEGER_BIT_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/rans_bit_decoder.h b/cloudreg_env/include/draco/compression/bit_coders/rans_bit_decoder.h deleted file mode 100644 index 1fbf6a1..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/rans_bit_decoder.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides basic classes and functions for rANS coding. -#ifndef DRACO_COMPRESSION_BIT_CODERS_RANS_BIT_DECODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_RANS_BIT_DECODER_H_ - -#include - -#include "draco/draco_features.h" - -#include "draco/compression/entropy/ans.h" -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// Class for decoding a sequence of bits that were encoded with RAnsBitEncoder. -class RAnsBitDecoder { - public: - RAnsBitDecoder(); - ~RAnsBitDecoder(); - - // Sets |source_buffer| as the buffer to decode bits from. - // Returns false when the data is invalid. - bool StartDecoding(DecoderBuffer *source_buffer); - - // Decode one bit. Returns true if the bit is a 1, otherwise false. - bool DecodeNextBit(); - - // Decode the next |nbits| and return the sequence in |value|. |nbits| must be - // > 0 and <= 32. - void DecodeLeastSignificantBits32(int nbits, uint32_t *value); - - void EndDecoding() {} - - private: - void Clear(); - - AnsDecoder ans_decoder_; - uint8_t prob_zero_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_RANS_BIT_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/rans_bit_encoder.h b/cloudreg_env/include/draco/compression/bit_coders/rans_bit_encoder.h deleted file mode 100644 index 1993dd3..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/rans_bit_encoder.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides basic classes and functions for rANS coding. -#ifndef DRACO_COMPRESSION_BIT_CODERS_RANS_BIT_ENCODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_RANS_BIT_ENCODER_H_ - -#include - -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// Class for encoding a sequence of bits using rANS. The probability table used -// to encode the bits is based off the total counts of bits. -// TODO(fgalligan): Investigate using an adaptive table for more compression. -class RAnsBitEncoder { - public: - RAnsBitEncoder(); - ~RAnsBitEncoder(); - - // Must be called before any Encode* function is called. - void StartEncoding(); - - // Encode one bit. If |bit| is true encode a 1, otherwise encode a 0. - void EncodeBit(bool bit); - - // Encode |nbits| of |value|, starting from the least significant bit. - // |nbits| must be > 0 and <= 32. - void EncodeLeastSignificantBits32(int nbits, uint32_t value); - - // Ends the bit encoding and stores the result into the target_buffer. - void EndEncoding(EncoderBuffer *target_buffer); - - private: - void Clear(); - - std::vector bit_counts_; - std::vector bits_; - uint32_t local_bits_; - uint32_t num_local_bits_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_RANS_BIT_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/symbol_bit_decoder.h b/cloudreg_env/include/draco/compression/bit_coders/symbol_bit_decoder.h deleted file mode 100644 index 909d717..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/symbol_bit_decoder.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_DECODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_DECODER_H_ - -#include -#include - -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// Class for decoding bits using the symbol entropy encoding. Wraps -// |DecodeSymbols|. Note that this uses a symbol-based encoding scheme for -// encoding bits. -class SymbolBitDecoder { - public: - // Sets |source_buffer| as the buffer to decode bits from. - bool StartDecoding(DecoderBuffer *source_buffer); - - // Decode one bit. Returns true if the bit is a 1, otherwise false. - bool DecodeNextBit(); - - // Decode the next |nbits| and return the sequence in |value|. |nbits| must be - // > 0 and <= 32. - void DecodeLeastSignificantBits32(int nbits, uint32_t *value); - - void EndDecoding() { Clear(); } - - private: - void Clear(); - - std::vector symbols_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/bit_coders/symbol_bit_encoder.h b/cloudreg_env/include/draco/compression/bit_coders/symbol_bit_encoder.h deleted file mode 100644 index 7f1570c..0000000 --- a/cloudreg_env/include/draco/compression/bit_coders/symbol_bit_encoder.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_ENCODER_H_ -#define DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_ENCODER_H_ - -#include -#include - -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// Class for encoding bits using the symbol entropy encoding. Wraps -// |EncodeSymbols|. Note that this uses a symbol-based encoding scheme for -// encoding bits. -class SymbolBitEncoder { - public: - // Must be called before any Encode* function is called. - void StartEncoding() { Clear(); } - - // Encode one bit. If |bit| is true encode a 1, otherwise encode a 0. - void EncodeBit(bool bit) { EncodeLeastSignificantBits32(1, bit ? 1 : 0); } - - // Encode |nbits| LSBs of |value| as a symbol. |nbits| must be > 0 and <= 32. - void EncodeLeastSignificantBits32(int nbits, uint32_t value); - - // Ends the bit encoding and stores the result into the target_buffer. - void EndEncoding(EncoderBuffer *target_buffer); - - private: - void Clear(); - - std::vector symbols_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_BIT_CODERS_SYMBOL_BIT_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/config/compression_shared.h b/cloudreg_env/include/draco/compression/config/compression_shared.h deleted file mode 100644 index 5204fbc..0000000 --- a/cloudreg_env/include/draco/compression/config/compression_shared.h +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_CONFIG_COMPRESSION_SHARED_H_ -#define DRACO_COMPRESSION_CONFIG_COMPRESSION_SHARED_H_ - -#include - -#include "draco/core/macros.h" - -#include "draco/draco_features.h" - -namespace draco { - -// Latest Draco bit-stream version. -static constexpr uint8_t kDracoPointCloudBitstreamVersionMajor = 2; -static constexpr uint8_t kDracoPointCloudBitstreamVersionMinor = 3; -static constexpr uint8_t kDracoMeshBitstreamVersionMajor = 2; -static constexpr uint8_t kDracoMeshBitstreamVersionMinor = 2; - -// Concatenated latest bit-stream version. -static constexpr uint16_t kDracoPointCloudBitstreamVersion = - DRACO_BITSTREAM_VERSION(kDracoPointCloudBitstreamVersionMajor, - kDracoPointCloudBitstreamVersionMinor); - -static constexpr uint16_t kDracoMeshBitstreamVersion = DRACO_BITSTREAM_VERSION( - kDracoMeshBitstreamVersionMajor, kDracoMeshBitstreamVersionMinor); - -// Currently, we support point cloud and triangular mesh encoding. -// TODO(draco-eng) Convert enum to enum class (safety, not performance). -enum EncodedGeometryType { - INVALID_GEOMETRY_TYPE = -1, - POINT_CLOUD = 0, - TRIANGULAR_MESH, -}; - -// List of encoding methods for point clouds. -enum PointCloudEncodingMethod { - POINT_CLOUD_SEQUENTIAL_ENCODING = 0, - POINT_CLOUD_KD_TREE_ENCODING -}; - -// List of encoding methods for meshes. -enum MeshEncoderMethod { - MESH_SEQUENTIAL_ENCODING = 0, - MESH_EDGEBREAKER_ENCODING, -}; - -// List of various attribute encoders supported by our framework. The entries -// are used as unique identifiers of the encoders and their values should not -// be changed! -enum AttributeEncoderType { - BASIC_ATTRIBUTE_ENCODER = 0, - MESH_TRAVERSAL_ATTRIBUTE_ENCODER, - KD_TREE_ATTRIBUTE_ENCODER, -}; - -// List of various sequential attribute encoder/decoders that can be used in our -// pipeline. The values represent unique identifiers used by the decoder and -// they should not be changed. -enum SequentialAttributeEncoderType { - SEQUENTIAL_ATTRIBUTE_ENCODER_GENERIC = 0, - SEQUENTIAL_ATTRIBUTE_ENCODER_INTEGER, - SEQUENTIAL_ATTRIBUTE_ENCODER_QUANTIZATION, - SEQUENTIAL_ATTRIBUTE_ENCODER_NORMALS, -}; - -// List of all prediction methods currently supported by our framework. -enum PredictionSchemeMethod { - // Special value indicating that no prediction scheme was used. - PREDICTION_NONE = -2, - // Used when no specific prediction scheme is required. - PREDICTION_UNDEFINED = -1, - PREDICTION_DIFFERENCE = 0, - MESH_PREDICTION_PARALLELOGRAM = 1, - MESH_PREDICTION_MULTI_PARALLELOGRAM = 2, - MESH_PREDICTION_TEX_COORDS_DEPRECATED = 3, - MESH_PREDICTION_CONSTRAINED_MULTI_PARALLELOGRAM = 4, - MESH_PREDICTION_TEX_COORDS_PORTABLE = 5, - MESH_PREDICTION_GEOMETRIC_NORMAL = 6, - NUM_PREDICTION_SCHEMES -}; - -// List of all prediction scheme transforms used by our framework. -enum PredictionSchemeTransformType { - PREDICTION_TRANSFORM_NONE = -1, - // Basic delta transform where the prediction is computed as difference the - // predicted and original value. - PREDICTION_TRANSFORM_DELTA = 0, - // An improved delta transform where all computed delta values are wrapped - // around a fixed interval which lowers the entropy. - PREDICTION_TRANSFORM_WRAP = 1, - // Specialized transform for normal coordinates using inverted tiles. - PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON = 2, - // Specialized transform for normal coordinates using canonicalized inverted - // tiles. - PREDICTION_TRANSFORM_NORMAL_OCTAHEDRON_CANONICALIZED = 3, -}; - -// List of all mesh traversal methods supported by Draco framework. -enum MeshTraversalMethod { - MESH_TRAVERSAL_DEPTH_FIRST = 0, - MESH_TRAVERSAL_PREDICTION_DEGREE = 1, - NUM_TRAVERSAL_METHODS -}; - -// List of all variant of the edgebreaker method that is used for compression -// of mesh connectivity. -enum MeshEdgebreakerConnectivityEncodingMethod { - MESH_EDGEBREAKER_STANDARD_ENCODING = 0, - MESH_EDGEBREAKER_PREDICTIVE_ENCODING = 1, // Deprecated. - MESH_EDGEBREAKER_VALENCE_ENCODING = 2, -}; - -// Draco header V1 -struct DracoHeader { - int8_t draco_string[5]; - uint8_t version_major; - uint8_t version_minor; - uint8_t encoder_type; - uint8_t encoder_method; - uint16_t flags; -}; - -enum NormalPredictionMode { - ONE_TRIANGLE = 0, // To be deprecated. - TRIANGLE_AREA = 1, -}; - -// Different methods used for symbol entropy encoding. -enum SymbolCodingMethod { - SYMBOL_CODING_TAGGED = 0, - SYMBOL_CODING_RAW = 1, - NUM_SYMBOL_CODING_METHODS, -}; - -// Mask for setting and getting the bit for metadata in |flags| of header. -#define METADATA_FLAG_MASK 0x8000 - -} // namespace draco - -#endif // DRACO_COMPRESSION_CONFIG_COMPRESSION_SHARED_H_ diff --git a/cloudreg_env/include/draco/compression/config/decoder_options.h b/cloudreg_env/include/draco/compression/config/decoder_options.h deleted file mode 100644 index 3b38899..0000000 --- a/cloudreg_env/include/draco/compression/config/decoder_options.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_CONFIG_DECODER_OPTIONS_H_ -#define DRACO_COMPRESSION_CONFIG_DECODER_OPTIONS_H_ - -#include -#include - -#include "draco/attributes/geometry_attribute.h" -#include "draco/compression/config/draco_options.h" - -namespace draco { - -// Class containing options that can be passed to PointCloudDecoder to control -// decoding of the input geometry. The options can be specified either for the -// whole geometry or for a specific attribute type. Each option is identified -// by a unique name stored as an std::string. -typedef DracoOptions DecoderOptions; - -} // namespace draco - -#endif // DRACO_COMPRESSION_CONFIG_DECODER_OPTIONS_H_ diff --git a/cloudreg_env/include/draco/compression/config/draco_options.h b/cloudreg_env/include/draco/compression/config/draco_options.h deleted file mode 100644 index c77f5df..0000000 --- a/cloudreg_env/include/draco/compression/config/draco_options.h +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_SRC_DRACO_COMPRESSION_CONFIG_DRACO_OPTIONS_H_ -#define DRACO_SRC_DRACO_COMPRESSION_CONFIG_DRACO_OPTIONS_H_ - -#include -#include - -#include "draco/core/options.h" - -namespace draco { - -// Base option class used to control encoding and decoding. The geometry coding -// can be controlled through the following options: -// 1. Global options - Options specific to overall geometry or options common -// for all attributes -// 2. Per attribute options - Options specific to a given attribute. -// Each attribute is identified by the template -// argument AttributeKeyT that can be for example -// the attribute type or the attribute id. -// -// Example: -// -// DracoOptions options; -// -// // Set an option common for all attributes. -// options.SetGlobalInt("some_option_name", 2); -// -// // Geometry with two attributes. -// AttributeKey att_key0 = in_key0; -// AttributeKey att_key1 = in_key1; -// -// options.SetAttributeInt(att_key0, "some_option_name", 3); -// -// options.GetAttributeInt(att_key0, "some_option_name"); // Returns 3 -// options.GetAttributeInt(att_key1, "some_option_name"); // Returns 2 -// options.GetGlobalInt("some_option_name"); // Returns 2 -// -template -class DracoOptions { - public: - typedef AttributeKeyT AttributeKey; - - // Get an option for a specific attribute key. If the option is not found in - // an attribute specific storage, the implementation will return a global - // option of the given name (if available). If the option is not found, the - // provided default value |default_val| is returned instead. - int GetAttributeInt(const AttributeKey &att_key, const std::string &name, - int default_val) const; - - // Sets an option for a specific attribute key. - void SetAttributeInt(const AttributeKey &att_key, const std::string &name, - int val); - - float GetAttributeFloat(const AttributeKey &att_key, const std::string &name, - float default_val) const; - void SetAttributeFloat(const AttributeKey &att_key, const std::string &name, - float val); - bool GetAttributeBool(const AttributeKey &att_key, const std::string &name, - bool default_val) const; - void SetAttributeBool(const AttributeKey &att_key, const std::string &name, - bool val); - template - bool GetAttributeVector(const AttributeKey &att_key, const std::string &name, - int num_dims, DataTypeT *val) const; - template - void SetAttributeVector(const AttributeKey &att_key, const std::string &name, - int num_dims, const DataTypeT *val); - - bool IsAttributeOptionSet(const AttributeKey &att_key, - const std::string &name) const; - - // Gets/sets a global option that is not specific to any attribute. - int GetGlobalInt(const std::string &name, int default_val) const { - return global_options_.GetInt(name, default_val); - } - void SetGlobalInt(const std::string &name, int val) { - global_options_.SetInt(name, val); - } - float GetGlobalFloat(const std::string &name, float default_val) const { - return global_options_.GetFloat(name, default_val); - } - void SetGlobalFloat(const std::string &name, float val) { - global_options_.SetFloat(name, val); - } - bool GetGlobalBool(const std::string &name, bool default_val) const { - return global_options_.GetBool(name, default_val); - } - void SetGlobalBool(const std::string &name, bool val) { - global_options_.SetBool(name, val); - } - template - bool GetGlobalVector(const std::string &name, int num_dims, - DataTypeT *val) const { - return global_options_.GetVector(name, num_dims, val); - } - template - void SetGlobalVector(const std::string &name, int num_dims, - const DataTypeT *val) { - global_options_.SetVector(name, val, num_dims); - } - bool IsGlobalOptionSet(const std::string &name) const { - return global_options_.IsOptionSet(name); - } - - // Sets or replaces attribute options with the provided |options|. - void SetAttributeOptions(const AttributeKey &att_key, const Options &options); - void SetGlobalOptions(const Options &options) { global_options_ = options; } - - // Returns |Options| instance for the specified options class if it exists. - const Options *FindAttributeOptions(const AttributeKeyT &att_key) const; - const Options &GetGlobalOptions() const { return global_options_; } - - private: - Options *GetAttributeOptions(const AttributeKeyT &att_key); - - Options global_options_; - - // Storage for options related to geometry attributes. - std::map attribute_options_; -}; - -template -const Options *DracoOptions::FindAttributeOptions( - const AttributeKeyT &att_key) const { - auto it = attribute_options_.find(att_key); - if (it == attribute_options_.end()) { - return nullptr; - } - return &it->second; -} - -template -Options *DracoOptions::GetAttributeOptions( - const AttributeKeyT &att_key) { - auto it = attribute_options_.find(att_key); - if (it != attribute_options_.end()) { - return &it->second; - } - Options new_options; - it = attribute_options_.insert(std::make_pair(att_key, new_options)).first; - return &it->second; -} - -template -int DracoOptions::GetAttributeInt(const AttributeKeyT &att_key, - const std::string &name, - int default_val) const { - const Options *const att_options = FindAttributeOptions(att_key); - if (att_options && att_options->IsOptionSet(name)) - return att_options->GetInt(name, default_val); - return global_options_.GetInt(name, default_val); -} - -template -void DracoOptions::SetAttributeInt(const AttributeKeyT &att_key, - const std::string &name, - int val) { - GetAttributeOptions(att_key)->SetInt(name, val); -} - -template -float DracoOptions::GetAttributeFloat( - const AttributeKeyT &att_key, const std::string &name, - float default_val) const { - const Options *const att_options = FindAttributeOptions(att_key); - if (att_options && att_options->IsOptionSet(name)) - return att_options->GetFloat(name, default_val); - return global_options_.GetFloat(name, default_val); -} - -template -void DracoOptions::SetAttributeFloat( - const AttributeKeyT &att_key, const std::string &name, float val) { - GetAttributeOptions(att_key)->SetFloat(name, val); -} - -template -bool DracoOptions::GetAttributeBool(const AttributeKeyT &att_key, - const std::string &name, - bool default_val) const { - const Options *const att_options = FindAttributeOptions(att_key); - if (att_options && att_options->IsOptionSet(name)) - return att_options->GetBool(name, default_val); - return global_options_.GetBool(name, default_val); -} - -template -void DracoOptions::SetAttributeBool(const AttributeKeyT &att_key, - const std::string &name, - bool val) { - GetAttributeOptions(att_key)->SetBool(name, val); -} - -template -template -bool DracoOptions::GetAttributeVector( - const AttributeKey &att_key, const std::string &name, int num_dims, - DataTypeT *val) const { - const Options *const att_options = FindAttributeOptions(att_key); - if (att_options && att_options->IsOptionSet(name)) - return att_options->GetVector(name, num_dims, val); - return global_options_.GetVector(name, num_dims, val); -} - -template -template -void DracoOptions::SetAttributeVector( - const AttributeKey &att_key, const std::string &name, int num_dims, - const DataTypeT *val) { - GetAttributeOptions(att_key)->SetVector(name, val, num_dims); -} - -template -bool DracoOptions::IsAttributeOptionSet( - const AttributeKey &att_key, const std::string &name) const { - const Options *const att_options = FindAttributeOptions(att_key); - if (att_options) - return att_options->IsOptionSet(name); - return global_options_.IsOptionSet(name); -} - -template -void DracoOptions::SetAttributeOptions( - const AttributeKey &att_key, const Options &options) { - Options *att_options = GetAttributeOptions(att_key); - *att_options = options; -} - -} // namespace draco - -#endif // DRACO_SRC_DRACO_COMPRESSION_CONFIG_DRACO_OPTIONS_H_ diff --git a/cloudreg_env/include/draco/compression/config/encoder_options.h b/cloudreg_env/include/draco/compression/config/encoder_options.h deleted file mode 100644 index aacd58e..0000000 --- a/cloudreg_env/include/draco/compression/config/encoder_options.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_CONFIG_ENCODER_OPTIONS_H_ -#define DRACO_COMPRESSION_CONFIG_ENCODER_OPTIONS_H_ - -#include "draco/draco_features.h" - -#include "draco/attributes/geometry_attribute.h" -#include "draco/compression/config/draco_options.h" -#include "draco/compression/config/encoding_features.h" - -namespace draco { - -// EncoderOptions allow users to specify so called feature options that are used -// to inform the encoder which encoding features can be used (i.e. which -// features are going to be available to the decoder). -template -class EncoderOptionsBase : public DracoOptions { - public: - static EncoderOptionsBase CreateDefaultOptions() { - EncoderOptionsBase options; -#ifdef DRACO_STANDARD_EDGEBREAKER_SUPPORTED - options.SetSupportedFeature(features::kEdgebreaker, true); -#endif -#ifdef DRACO_PREDICTIVE_EDGEBREAKER_SUPPORTED - options.SetSupportedFeature(features::kPredictiveEdgebreaker, true); -#endif - return options; - } - static EncoderOptionsBase CreateEmptyOptions() { - return EncoderOptionsBase(); - } - - // Returns speed options with default value of 5. - int GetEncodingSpeed() const { - return this->GetGlobalInt("encoding_speed", 5); - } - int GetDecodingSpeed() const { - return this->GetGlobalInt("decoding_speed", 5); - } - - // Returns the maximum speed for both encoding/decoding. - int GetSpeed() const { - const int encoding_speed = this->GetGlobalInt("encoding_speed", -1); - const int decoding_speed = this->GetGlobalInt("decoding_speed", -1); - const int max_speed = std::max(encoding_speed, decoding_speed); - if (max_speed == -1) - return 5; // Default value. - return max_speed; - } - - void SetSpeed(int encoding_speed, int decoding_speed) { - this->SetGlobalInt("encoding_speed", encoding_speed); - this->SetGlobalInt("decoding_speed", decoding_speed); - } - - // Sets a given feature as supported or unsupported by the target decoder. - // Encoder will always use only supported features when encoding the input - // geometry. - void SetSupportedFeature(const std::string &name, bool supported) { - feature_options_.SetBool(name, supported); - } - bool IsFeatureSupported(const std::string &name) const { - return feature_options_.GetBool(name); - } - - void SetFeatureOptions(const Options &options) { feature_options_ = options; } - const Options &GetFeaturelOptions() const { return feature_options_; } - - private: - // Use helper methods to construct the encoder options. - // See CreateDefaultOptions(); - EncoderOptionsBase() {} - - // List of supported/unsupported features that can be used by the encoder. - Options feature_options_; -}; - -// Encoder options where attributes are identified by their attribute id. -// Used to set options that are specific to a given geometry. -typedef EncoderOptionsBase EncoderOptions; - -} // namespace draco - -#endif // DRACO_COMPRESSION_CONFIG_ENCODER_OPTIONS_H_ diff --git a/cloudreg_env/include/draco/compression/config/encoding_features.h b/cloudreg_env/include/draco/compression/config/encoding_features.h deleted file mode 100644 index d6a8b71..0000000 --- a/cloudreg_env/include/draco/compression/config/encoding_features.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File provides helpful macros that define features available for encoding -// the input of the input geometry. These macros can be used as an input in -// the EncoderOptions::SetSupportedFeature() method instead of the text. -// The most recent set of features supported -// by the default implementation is: -// -// kEdgebreaker -// - edgebreaker method for encoding meshes. -// kPredictiveEdgebreaker -// - advanced version of the edgebreaker method (slower but better -// compression). -// -#ifndef DRACO_COMPRESSION_CONFIG_ENCODING_FEATURES_H_ -#define DRACO_COMPRESSION_CONFIG_ENCODING_FEATURES_H_ - -namespace draco { -namespace features { - -constexpr const char *kEdgebreaker = "standard_edgebreaker"; -constexpr const char *kPredictiveEdgebreaker = "predictive_edgebreaker"; - -} // namespace features -} // namespace draco - -#endif // DRACO_COMPRESSION_CONFIG_ENCODING_FEATURES_H_ diff --git a/cloudreg_env/include/draco/compression/decode.h b/cloudreg_env/include/draco/compression/decode.h deleted file mode 100644 index 0216d72..0000000 --- a/cloudreg_env/include/draco/compression/decode.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_DECODE_H_ -#define DRACO_COMPRESSION_DECODE_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/decoder_options.h" -#include "draco/core/decoder_buffer.h" -#include "draco/core/status_or.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Class responsible for decoding of meshes and point clouds that were -// compressed by a Draco encoder. -class Decoder { - public: - // Returns the geometry type encoded in the input |in_buffer|. - // The return value is one of POINT_CLOUD, MESH or INVALID_GEOMETRY in case - // the input data is invalid. - // The decoded geometry type can be used to choose an appropriate decoding - // function for a given geometry type (see below). - static StatusOr GetEncodedGeometryType( - DecoderBuffer *in_buffer); - - // Decodes point cloud from the provided buffer. The buffer must be filled - // with data that was encoded with either the EncodePointCloudToBuffer or - // EncodeMeshToBuffer methods in encode.h. In case the input buffer contains - // mesh, the returned instance can be down-casted to Mesh. - StatusOr> DecodePointCloudFromBuffer( - DecoderBuffer *in_buffer); - - // Decodes a triangular mesh from the provided buffer. The mesh must be filled - // with data that was encoded using the EncodeMeshToBuffer method in encode.h. - // The function will return nullptr in case the input is invalid or if it was - // encoded with the EncodePointCloudToBuffer method. - StatusOr> DecodeMeshFromBuffer( - DecoderBuffer *in_buffer); - - // Decodes the buffer into a provided geometry. If the geometry is - // incompatible with the encoded data. For example, when |out_geometry| is - // draco::Mesh while the data contains a point cloud, the function will return - // an error status. - Status DecodeBufferToGeometry(DecoderBuffer *in_buffer, - PointCloud *out_geometry); - Status DecodeBufferToGeometry(DecoderBuffer *in_buffer, Mesh *out_geometry); - - // When set, the decoder is going to skip attribute transform for a given - // attribute type. For example for quantized attributes, the decoder would - // skip the dequantization step and the returned geometry would contain an - // attribute with quantized values. The attribute would also contain an - // instance of AttributeTransform class that is used to describe the skipped - // transform, including all parameters that are needed to perform the - // transform manually. - void SetSkipAttributeTransform(GeometryAttribute::Type att_type); - - // Returns the options instance used by the decoder that can be used by users - // to control the decoding process. - DecoderOptions *options() { return &options_; } - - private: - DecoderOptions options_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_DECODE_H_ diff --git a/cloudreg_env/include/draco/compression/encode.h b/cloudreg_env/include/draco/compression/encode.h deleted file mode 100644 index bce8b34..0000000 --- a/cloudreg_env/include/draco/compression/encode.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ENCODE_H_ -#define DRACO_COMPRESSION_ENCODE_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/encoder_options.h" -#include "draco/compression/encode_base.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/status.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Basic helper class for encoding geometry using the Draco compression library. -// The class provides various methods that can be used to control several common -// options used during the encoding, such as the number of quantization bits for -// a given attribute. All these options are defined per attribute type, i.e., -// if there are more attributes of the same type (such as multiple texture -// coordinate attributes), the same options are going to be used for all of the -// attributes of this type. If different attributes of the same type need to -// use different options, use ExpertEncoder in expert_encode.h. -class Encoder - : public EncoderBase> { - public: - typedef EncoderBase> Base; - - Encoder(); - virtual ~Encoder() {} - - // Encodes a point cloud to the provided buffer. - virtual Status EncodePointCloudToBuffer(const PointCloud &pc, - EncoderBuffer *out_buffer); - - // Encodes a mesh to the provided buffer. - virtual Status EncodeMeshToBuffer(const Mesh &m, EncoderBuffer *out_buffer); - - // Set encoder options used during the geometry encoding. Note that this call - // overwrites any modifications to the options done with the functions below, - // i.e., it resets the encoder. - void Reset(const EncoderOptionsBase &options); - void Reset(); - - // Sets the desired encoding and decoding speed for the given options. - // - // 0 = slowest speed, but the best compression. - // 10 = fastest, but the worst compression. - // -1 = undefined. - // - // Note that both speed options affect the encoder choice of used methods and - // algorithms. For example, a requirement for fast decoding may prevent the - // encoder from using the best compression methods even if the encoding speed - // is set to 0. In general, the faster of the two options limits the choice of - // features that can be used by the encoder. Additionally, setting - // |decoding_speed| to be faster than the |encoding_speed| may allow the - // encoder to choose the optimal method out of the available features for the - // given |decoding_speed|. - void SetSpeedOptions(int encoding_speed, int decoding_speed); - - // Sets the quantization compression options for a named attribute. The - // attribute values will be quantized in a box defined by the maximum extent - // of the attribute values. I.e., the actual precision of this option depends - // on the scale of the attribute values. - void SetAttributeQuantization(GeometryAttribute::Type type, - int quantization_bits); - - // Sets the explicit quantization compression for a named attribute. The - // attribute values will be quantized in a coordinate system defined by the - // provided origin and range (the input values should be within interval: - // ). - void SetAttributeExplicitQuantization(GeometryAttribute::Type type, - int quantization_bits, int num_dims, - const float *origin, float range); - - // Sets the desired prediction method for a given attribute. By default, - // prediction scheme is selected automatically by the encoder using other - // provided options (such as speed) and input geometry type (mesh, point - // cloud). This function should be called only when a specific prediction is - // preferred (e.g., when it is known that the encoder would select a less - // optimal prediction for the given input data). - // - // |prediction_scheme_method| should be one of the entries defined in - // compression/config/compression_shared.h : - // - // PREDICTION_NONE - use no prediction. - // PREDICTION_DIFFERENCE - delta coding - // MESH_PREDICTION_PARALLELOGRAM - parallelogram prediction for meshes. - // MESH_PREDICTION_CONSTRAINED_PARALLELOGRAM - // - better and more costly version of the parallelogram prediction. - // MESH_PREDICTION_TEX_COORDS_PORTABLE - // - specialized predictor for tex coordinates. - // MESH_PREDICTION_GEOMETRIC_NORMAL - // - specialized predictor for normal coordinates. - // - // Note that in case the desired prediction cannot be used, the default - // prediction will be automatically used instead. - Status SetAttributePredictionScheme(GeometryAttribute::Type type, - int prediction_scheme_method); - - // Sets the desired encoding method for a given geometry. By default, encoding - // method is selected based on the properties of the input geometry and based - // on the other options selected in the used EncoderOptions (such as desired - // encoding and decoding speed). This function should be called only when a - // specific method is required. - // - // |encoding_method| can be one of the values defined in - // compression/config/compression_shared.h based on the type of the input - // geometry that is going to be encoded. For point clouds, allowed entries are - // POINT_CLOUD_SEQUENTIAL_ENCODING - // POINT_CLOUD_KD_TREE_ENCODING - // - // For meshes the input can be - // MESH_SEQUENTIAL_ENCODING - // MESH_EDGEBREAKER_ENCODING - // - // If the selected method cannot be used for the given input, the subsequent - // call of EncodePointCloudToBuffer or EncodeMeshToBuffer is going to fail. - void SetEncodingMethod(int encoding_method); - - protected: - // Creates encoder options for the expert encoder used during the actual - // encoding. - EncoderOptions CreateExpertEncoderOptions(const PointCloud &pc) const; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENCODE_H_ diff --git a/cloudreg_env/include/draco/compression/encode_base.h b/cloudreg_env/include/draco/compression/encode_base.h deleted file mode 100644 index 4b790be..0000000 --- a/cloudreg_env/include/draco/compression/encode_base.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_SRC_DRACO_COMPRESSION_ENCODE_BASE_H_ -#define DRACO_SRC_DRACO_COMPRESSION_ENCODE_BASE_H_ - -#include "draco/attributes/geometry_attribute.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/core/status.h" - -namespace draco { - -// Base class for our geometry encoder classes. |EncoderOptionsT| specifies -// options class used by the encoder. Please, see encode.h and expert_encode.h -// for more details and method descriptions. -template -class EncoderBase { - public: - typedef EncoderOptionsT OptionsType; - - EncoderBase() - : options_(EncoderOptionsT::CreateDefaultOptions()), - num_encoded_points_(0), - num_encoded_faces_(0) {} - virtual ~EncoderBase() {} - - const EncoderOptionsT &options() const { return options_; } - EncoderOptionsT &options() { return options_; } - - // If enabled, it tells the encoder to keep track of the number of encoded - // points and faces (default = false). - // Note that this can slow down encoding for certain encoders. - void SetTrackEncodedProperties(bool flag); - - // Returns the number of encoded points and faces during the last encoding - // operation. Returns 0 if SetTrackEncodedProperties() was not set. - size_t num_encoded_points() const { return num_encoded_points_; } - size_t num_encoded_faces() const { return num_encoded_faces_; } - - protected: - void Reset(const EncoderOptionsT &options) { options_ = options; } - - void Reset() { options_ = EncoderOptionsT::CreateDefaultOptions(); } - - void SetSpeedOptions(int encoding_speed, int decoding_speed) { - options_.SetSpeed(encoding_speed, decoding_speed); - } - - void SetEncodingMethod(int encoding_method) { - options_.SetGlobalInt("encoding_method", encoding_method); - } - - void SetEncodingSubmethod(int encoding_submethod) { - options_.SetGlobalInt("encoding_submethod", encoding_submethod); - } - - Status CheckPredictionScheme(GeometryAttribute::Type att_type, - int prediction_scheme) const { - // Out of bound checks: - if (prediction_scheme < PREDICTION_NONE) - return Status(Status::ERROR, "Invalid prediction scheme requested."); - if (prediction_scheme >= NUM_PREDICTION_SCHEMES) - return Status(Status::ERROR, "Invalid prediction scheme requested."); - // Deprecated prediction schemes: - if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_DEPRECATED) - return Status(Status::ERROR, - "MESH_PREDICTION_TEX_COORDS_DEPRECATED is deprecated."); - if (prediction_scheme == MESH_PREDICTION_MULTI_PARALLELOGRAM) - return Status(Status::ERROR, - "MESH_PREDICTION_MULTI_PARALLELOGRAM is deprecated."); - // Attribute specific checks: - if (prediction_scheme == MESH_PREDICTION_TEX_COORDS_PORTABLE) { - if (att_type != GeometryAttribute::TEX_COORD) - return Status(Status::ERROR, - "Invalid prediction scheme for attribute type."); - } - if (prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL) { - if (att_type != GeometryAttribute::NORMAL) { - return Status(Status::ERROR, - "Invalid prediction scheme for attribute type."); - } - } - // TODO(hemmer): Try to enable more prediction schemes for normals. - if (att_type == GeometryAttribute::NORMAL) { - if (!(prediction_scheme == PREDICTION_DIFFERENCE || - prediction_scheme == MESH_PREDICTION_GEOMETRIC_NORMAL)) { - return Status(Status::ERROR, - "Invalid prediction scheme for attribute type."); - } - } - return OkStatus(); - } - - protected: - void set_num_encoded_points(size_t num) { num_encoded_points_ = num; } - void set_num_encoded_faces(size_t num) { num_encoded_faces_ = num; } - - private: - EncoderOptionsT options_; - - size_t num_encoded_points_; - size_t num_encoded_faces_; -}; - -template -void EncoderBase::SetTrackEncodedProperties(bool flag) { - options_.SetGlobalBool("store_number_of_encoded_points", flag); - options_.SetGlobalBool("store_number_of_encoded_faces", flag); -} - -} // namespace draco - -#endif // DRACO_SRC_DRACO_COMPRESSION_ENCODE_BASE_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/ans.h b/cloudreg_env/include/draco/compression/entropy/ans.h deleted file mode 100644 index 310ae25..0000000 --- a/cloudreg_env/include/draco/compression/entropy/ans.h +++ /dev/null @@ -1,517 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_ANS_H_ -#define DRACO_CORE_ANS_H_ -// An implementation of Asymmetric Numeral Systems (rANS). -// See http://arxiv.org/abs/1311.2540v2 for more information on rANS. -// This file is based off libvpx's ans.h. - -#include - -#define DRACO_ANS_DIVIDE_BY_MULTIPLY 1 -#if DRACO_ANS_DIVIDE_BY_MULTIPLY -#include "draco/core/divide.h" -#endif -#include "draco/core/macros.h" - -namespace draco { - -#if DRACO_ANS_DIVIDE_BY_MULTIPLY - -#define DRACO_ANS_DIVREM(quotient, remainder, dividend, divisor) \ - do { \ - quotient = fastdiv(dividend, divisor); \ - remainder = dividend - quotient * divisor; \ - } while (0) -#define DRACO_ANS_DIV(dividend, divisor) fastdiv(dividend, divisor) -#else -#define DRACO_ANS_DIVREM(quotient, remainder, dividend, divisor) \ - do { \ - quotient = dividend / divisor; \ - remainder = dividend % divisor; \ - } while (0) -#define DRACO_ANS_DIV(dividend, divisor) ((dividend) / (divisor)) -#endif - -struct AnsCoder { - AnsCoder() : buf(nullptr), buf_offset(0), state(0) {} - uint8_t *buf; - int buf_offset; - uint32_t state; -}; - -struct AnsDecoder { - AnsDecoder() : buf(nullptr), buf_offset(0), state(0) {} - const uint8_t *buf; - int buf_offset; - uint32_t state; -}; - -typedef uint8_t AnsP8; -#define DRACO_ANS_P8_PRECISION 256u -#define DRACO_ANS_L_BASE (4096u) -#define DRACO_ANS_IO_BASE 256 - -static uint32_t mem_get_le16(const void *vmem) { - uint32_t val; - const uint8_t *mem = (const uint8_t *)vmem; - - val = mem[1] << 8; - val |= mem[0]; - return val; -} - -static uint32_t mem_get_le24(const void *vmem) { - uint32_t val; - const uint8_t *mem = (const uint8_t *)vmem; - - val = mem[2] << 16; - val |= mem[1] << 8; - val |= mem[0]; - return val; -} - -static inline uint32_t mem_get_le32(const void *vmem) { - uint32_t val; - const uint8_t *mem = (const uint8_t *)vmem; - - val = mem[3] << 24; - val |= mem[2] << 16; - val |= mem[1] << 8; - val |= mem[0]; - return val; -} - -static inline void mem_put_le16(void *vmem, uint32_t val) { - uint8_t *mem = reinterpret_cast(vmem); - - mem[0] = (val >> 0) & 0xff; - mem[1] = (val >> 8) & 0xff; -} - -static inline void mem_put_le24(void *vmem, uint32_t val) { - uint8_t *mem = reinterpret_cast(vmem); - - mem[0] = (val >> 0) & 0xff; - mem[1] = (val >> 8) & 0xff; - mem[2] = (val >> 16) & 0xff; -} - -static inline void mem_put_le32(void *vmem, uint32_t val) { - uint8_t *mem = reinterpret_cast(vmem); - - mem[0] = (val >> 0) & 0xff; - mem[1] = (val >> 8) & 0xff; - mem[2] = (val >> 16) & 0xff; - mem[3] = (val >> 24) & 0xff; -} - -static inline void ans_write_init(struct AnsCoder *const ans, - uint8_t *const buf) { - ans->buf = buf; - ans->buf_offset = 0; - ans->state = DRACO_ANS_L_BASE; -} - -static inline int ans_write_end(struct AnsCoder *const ans) { - uint32_t state; - DRACO_DCHECK_GE(ans->state, DRACO_ANS_L_BASE); - DRACO_DCHECK_LT(ans->state, DRACO_ANS_L_BASE * DRACO_ANS_IO_BASE); - state = ans->state - DRACO_ANS_L_BASE; - if (state < (1 << 6)) { - ans->buf[ans->buf_offset] = (0x00 << 6) + state; - return ans->buf_offset + 1; - } else if (state < (1 << 14)) { - mem_put_le16(ans->buf + ans->buf_offset, (0x01 << 14) + state); - return ans->buf_offset + 2; - } else if (state < (1 << 22)) { - mem_put_le24(ans->buf + ans->buf_offset, (0x02 << 22) + state); - return ans->buf_offset + 3; - } else { - DRACO_DCHECK(0 && "State is too large to be serialized"); - return ans->buf_offset; - } -} - -// rABS with descending spread. -// p or p0 takes the place of l_s from the paper. -// DRACO_ANS_P8_PRECISION is m. -static inline void rabs_desc_write(struct AnsCoder *ans, int val, AnsP8 p0) { - const AnsP8 p = DRACO_ANS_P8_PRECISION - p0; - const unsigned l_s = val ? p : p0; - unsigned quot, rem; - if (ans->state >= - DRACO_ANS_L_BASE / DRACO_ANS_P8_PRECISION * DRACO_ANS_IO_BASE * l_s) { - ans->buf[ans->buf_offset++] = ans->state % DRACO_ANS_IO_BASE; - ans->state /= DRACO_ANS_IO_BASE; - } - DRACO_ANS_DIVREM(quot, rem, ans->state, l_s); - ans->state = quot * DRACO_ANS_P8_PRECISION + rem + (val ? 0 : p); -} - -#define DRACO_ANS_IMPL1 0 -#define UNPREDICTABLE(x) x -static inline int rabs_desc_read(struct AnsDecoder *ans, AnsP8 p0) { - int val; -#if DRACO_ANS_IMPL1 - unsigned l_s; -#else - unsigned quot, rem, x, xn; -#endif - const AnsP8 p = DRACO_ANS_P8_PRECISION - p0; - if (ans->state < DRACO_ANS_L_BASE && ans->buf_offset > 0) { - ans->state = ans->state * DRACO_ANS_IO_BASE + ans->buf[--ans->buf_offset]; - } -#if DRACO_ANS_IMPL1 - val = ans->state % DRACO_ANS_P8_PRECISION < p; - l_s = val ? p : p0; - ans->state = (ans->state / DRACO_ANS_P8_PRECISION) * l_s + - ans->state % DRACO_ANS_P8_PRECISION - (!val * p); -#else - x = ans->state; - quot = x / DRACO_ANS_P8_PRECISION; - rem = x % DRACO_ANS_P8_PRECISION; - xn = quot * p; - val = rem < p; - if (UNPREDICTABLE(val)) { - ans->state = xn + rem; - } else { - // ans->state = quot * p0 + rem - p; - ans->state = x - xn - p; - } -#endif - return val; -} - -// rABS with ascending spread. -// p or p0 takes the place of l_s from the paper. -// DRACO_ANS_P8_PRECISION is m. -static inline void rabs_asc_write(struct AnsCoder *ans, int val, AnsP8 p0) { - const AnsP8 p = DRACO_ANS_P8_PRECISION - p0; - const unsigned l_s = val ? p : p0; - unsigned quot, rem; - if (ans->state >= - DRACO_ANS_L_BASE / DRACO_ANS_P8_PRECISION * DRACO_ANS_IO_BASE * l_s) { - ans->buf[ans->buf_offset++] = ans->state % DRACO_ANS_IO_BASE; - ans->state /= DRACO_ANS_IO_BASE; - } - DRACO_ANS_DIVREM(quot, rem, ans->state, l_s); - ans->state = quot * DRACO_ANS_P8_PRECISION + rem + (val ? p0 : 0); -} - -static inline int rabs_asc_read(struct AnsDecoder *ans, AnsP8 p0) { - int val; -#if DRACO_ANS_IMPL1 - unsigned l_s; -#else - unsigned quot, rem, x, xn; -#endif - const AnsP8 p = DRACO_ANS_P8_PRECISION - p0; - if (ans->state < DRACO_ANS_L_BASE) { - ans->state = ans->state * DRACO_ANS_IO_BASE + ans->buf[--ans->buf_offset]; - } -#if DRACO_ANS_IMPL1 - val = ans->state % DRACO_ANS_P8_PRECISION < p; - l_s = val ? p : p0; - ans->state = (ans->state / DRACO_ANS_P8_PRECISION) * l_s + - ans->state % DRACO_ANS_P8_PRECISION - (!val * p); -#else - x = ans->state; - quot = x / DRACO_ANS_P8_PRECISION; - rem = x % DRACO_ANS_P8_PRECISION; - xn = quot * p; - val = rem >= p0; - if (UNPREDICTABLE(val)) { - ans->state = xn + rem - p0; - } else { - // ans->state = quot * p0 + rem - p0; - ans->state = x - xn; - } -#endif - return val; -} - -#define rabs_read rabs_desc_read -#define rabs_write rabs_desc_write - -// uABS with normalization. -static inline void uabs_write(struct AnsCoder *ans, int val, AnsP8 p0) { - AnsP8 p = DRACO_ANS_P8_PRECISION - p0; - const unsigned l_s = val ? p : p0; - while (ans->state >= - DRACO_ANS_L_BASE / DRACO_ANS_P8_PRECISION * DRACO_ANS_IO_BASE * l_s) { - ans->buf[ans->buf_offset++] = ans->state % DRACO_ANS_IO_BASE; - ans->state /= DRACO_ANS_IO_BASE; - } - if (!val) - ans->state = DRACO_ANS_DIV(ans->state * DRACO_ANS_P8_PRECISION, p0); - else - ans->state = - DRACO_ANS_DIV((ans->state + 1) * DRACO_ANS_P8_PRECISION + p - 1, p) - 1; -} - -static inline int uabs_read(struct AnsDecoder *ans, AnsP8 p0) { - AnsP8 p = DRACO_ANS_P8_PRECISION - p0; - int s; - // unsigned int xp1; - unsigned xp, sp; - unsigned state = ans->state; - while (state < DRACO_ANS_L_BASE && ans->buf_offset > 0) { - state = state * DRACO_ANS_IO_BASE + ans->buf[--ans->buf_offset]; - } - sp = state * p; - // xp1 = (sp + p) / DRACO_ANS_P8_PRECISION; - xp = sp / DRACO_ANS_P8_PRECISION; - // s = xp1 - xp; - s = (sp & 0xFF) >= p0; - if (UNPREDICTABLE(s)) - ans->state = xp; - else - ans->state = state - xp; - return s; -} - -static inline int uabs_read_bit(struct AnsDecoder *ans) { - int s; - unsigned state = ans->state; - while (state < DRACO_ANS_L_BASE && ans->buf_offset > 0) { - state = state * DRACO_ANS_IO_BASE + ans->buf[--ans->buf_offset]; - } - s = static_cast(state & 1); - ans->state = state >> 1; - return s; -} - -static inline int ans_read_init(struct AnsDecoder *const ans, - const uint8_t *const buf, int offset) { - unsigned x; - if (offset < 1) - return 1; - ans->buf = buf; - x = buf[offset - 1] >> 6; - if (x == 0) { - ans->buf_offset = offset - 1; - ans->state = buf[offset - 1] & 0x3F; - } else if (x == 1) { - if (offset < 2) - return 1; - ans->buf_offset = offset - 2; - ans->state = mem_get_le16(buf + offset - 2) & 0x3FFF; - } else if (x == 2) { - if (offset < 3) - return 1; - ans->buf_offset = offset - 3; - ans->state = mem_get_le24(buf + offset - 3) & 0x3FFFFF; - } else { - return 1; - } - ans->state += DRACO_ANS_L_BASE; - if (ans->state >= DRACO_ANS_L_BASE * DRACO_ANS_IO_BASE) - return 1; - return 0; -} - -static inline int ans_read_end(struct AnsDecoder *const ans) { - return ans->state == DRACO_ANS_L_BASE; -} - -static inline int ans_reader_has_error(const struct AnsDecoder *const ans) { - return ans->state < DRACO_ANS_L_BASE && ans->buf_offset == 0; -} - -struct rans_sym { - uint32_t prob; - uint32_t cum_prob; // not-inclusive. -}; - -// Class for performing rANS encoding using a desired number of precision bits. -// The max number of precision bits is currently 19. The actual number of -// symbols in the input alphabet should be (much) smaller than that, otherwise -// the compression rate may suffer. -template -class RAnsEncoder { - public: - RAnsEncoder() {} - - // Provides the input buffer where the data is going to be stored. - inline void write_init(uint8_t *const buf) { - ans_.buf = buf; - ans_.buf_offset = 0; - ans_.state = l_rans_base; - } - - // Needs to be called after all symbols are encoded. - inline int write_end() { - uint32_t state; - DRACO_DCHECK_GE(ans_.state, l_rans_base); - DRACO_DCHECK_LT(ans_.state, l_rans_base * DRACO_ANS_IO_BASE); - state = ans_.state - l_rans_base; - if (state < (1 << 6)) { - ans_.buf[ans_.buf_offset] = (0x00 << 6) + state; - return ans_.buf_offset + 1; - } else if (state < (1 << 14)) { - mem_put_le16(ans_.buf + ans_.buf_offset, (0x01 << 14) + state); - return ans_.buf_offset + 2; - } else if (state < (1 << 22)) { - mem_put_le24(ans_.buf + ans_.buf_offset, (0x02 << 22) + state); - return ans_.buf_offset + 3; - } else if (state < (1 << 30)) { - mem_put_le32(ans_.buf + ans_.buf_offset, (0x03u << 30u) + state); - return ans_.buf_offset + 4; - } else { - DRACO_DCHECK(0 && "State is too large to be serialized"); - return ans_.buf_offset; - } - } - - // rANS with normalization. - // sym->prob takes the place of l_s from the paper. - // rans_precision is m. - inline void rans_write(const struct rans_sym *const sym) { - const uint32_t p = sym->prob; - while (ans_.state >= l_rans_base / rans_precision * DRACO_ANS_IO_BASE * p) { - ans_.buf[ans_.buf_offset++] = ans_.state % DRACO_ANS_IO_BASE; - ans_.state /= DRACO_ANS_IO_BASE; - } - // TODO(ostava): The division and multiplication should be optimized. - ans_.state = - (ans_.state / p) * rans_precision + ans_.state % p + sym->cum_prob; - } - - private: - static constexpr int rans_precision = 1 << rans_precision_bits_t; - static constexpr int l_rans_base = rans_precision * 4; - AnsCoder ans_; -}; - -struct rans_dec_sym { - uint32_t val; - uint32_t prob; - uint32_t cum_prob; // not-inclusive. -}; - -// Class for performing rANS decoding using a desired number of precision bits. -// The number of precision bits needs to be the same as with the RAnsEncoder -// that was used to encode the input data. -template -class RAnsDecoder { - public: - RAnsDecoder() {} - - // Initializes the decoder from the input buffer. The |offset| specifies the - // number of bytes encoded by the encoder. A non zero return value is an - // error. - inline int read_init(const uint8_t *const buf, int offset) { - unsigned x; - if (offset < 1) - return 1; - ans_.buf = buf; - x = buf[offset - 1] >> 6; - if (x == 0) { - ans_.buf_offset = offset - 1; - ans_.state = buf[offset - 1] & 0x3F; - } else if (x == 1) { - if (offset < 2) - return 1; - ans_.buf_offset = offset - 2; - ans_.state = mem_get_le16(buf + offset - 2) & 0x3FFF; - } else if (x == 2) { - if (offset < 3) - return 1; - ans_.buf_offset = offset - 3; - ans_.state = mem_get_le24(buf + offset - 3) & 0x3FFFFF; - } else if (x == 3) { - ans_.buf_offset = offset - 4; - ans_.state = mem_get_le32(buf + offset - 4) & 0x3FFFFFFF; - } else { - return 1; - } - ans_.state += l_rans_base; - if (ans_.state >= l_rans_base * DRACO_ANS_IO_BASE) - return 1; - return 0; - } - - inline int read_end() { return ans_.state == l_rans_base; } - - inline int reader_has_error() { - return ans_.state < l_rans_base && ans_.buf_offset == 0; - } - - inline int rans_read() { - unsigned rem; - unsigned quo; - struct rans_dec_sym sym; - while (ans_.state < l_rans_base && ans_.buf_offset > 0) { - ans_.state = ans_.state * DRACO_ANS_IO_BASE + ans_.buf[--ans_.buf_offset]; - } - // |rans_precision| is a power of two compile time constant, and the below - // division and modulo are going to be optimized by the compiler. - quo = ans_.state / rans_precision; - rem = ans_.state % rans_precision; - fetch_sym(&sym, rem); - ans_.state = quo * sym.prob + rem - sym.cum_prob; - return sym.val; - } - - // Construct a lookup table with |rans_precision| number of entries. - // Returns false if the table couldn't be built (because of wrong input data). - inline bool rans_build_look_up_table(const uint32_t token_probs[], - uint32_t num_symbols) { - lut_table_.resize(rans_precision); - probability_table_.resize(num_symbols); - uint32_t cum_prob = 0; - uint32_t act_prob = 0; - for (uint32_t i = 0; i < num_symbols; ++i) { - probability_table_[i].prob = token_probs[i]; - probability_table_[i].cum_prob = cum_prob; - cum_prob += token_probs[i]; - if (cum_prob > rans_precision) { - return false; - } - for (uint32_t j = act_prob; j < cum_prob; ++j) { - lut_table_[j] = i; - } - act_prob = cum_prob; - } - if (cum_prob != rans_precision) { - return false; - } - return true; - } - - private: - inline void fetch_sym(struct rans_dec_sym *out, uint32_t rem) { - uint32_t symbol = lut_table_[rem]; - out->val = symbol; - out->prob = probability_table_[symbol].prob; - out->cum_prob = probability_table_[symbol].cum_prob; - } - - static constexpr int rans_precision = 1 << rans_precision_bits_t; - static constexpr int l_rans_base = rans_precision * 4; - std::vector lut_table_; - std::vector probability_table_; - AnsDecoder ans_; -}; - -#undef DRACO_ANS_DIVREM -#undef DRACO_ANS_P8_PRECISION -#undef DRACO_ANS_L_BASE -#undef DRACO_ANS_IO_BASE - -} // namespace draco - -#endif // DRACO_CORE_ANS_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/rans_symbol_coding.h b/cloudreg_env/include/draco/compression/entropy/rans_symbol_coding.h deleted file mode 100644 index 0a68e29..0000000 --- a/cloudreg_env/include/draco/compression/entropy/rans_symbol_coding.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File providing shared functionality for RAnsSymbolEncoder and -// RAnsSymbolDecoder (see rans_symbol_encoder.h / rans_symbol_decoder.h). -#ifndef DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_CODING_H_ -#define DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_CODING_H_ - -#include "draco/compression/entropy/ans.h" - -namespace draco { - -// Computes the desired precision of the rANS method for the specified number of -// unique symbols the input data (defined by their bit_length). -constexpr int ComputeRAnsUnclampedPrecision(int symbols_bit_length) { - return (3 * symbols_bit_length) / 2; -} - -// Computes the desired precision clamped to guarantee a valid functionality of -// our rANS library (which is between 12 to 20 bits). -constexpr int ComputeRAnsPrecisionFromUniqueSymbolsBitLength( - int symbols_bit_length) { - return ComputeRAnsUnclampedPrecision(symbols_bit_length) < 12 - ? 12 - : ComputeRAnsUnclampedPrecision(symbols_bit_length) > 20 - ? 20 - : ComputeRAnsUnclampedPrecision(symbols_bit_length); -} - -// Compute approximate frequency table size needed for storing the provided -// symbols. -static inline int64_t ApproximateRAnsFrequencyTableBits( - int32_t max_value, int num_unique_symbols) { - // Approximate number of bits for storing zero frequency entries using the - // run length encoding (with max length of 64). - const int64_t table_zero_frequency_bits = - 8 * (num_unique_symbols + (max_value - num_unique_symbols) / 64); - return 8 * num_unique_symbols + table_zero_frequency_bits; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_CODING_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/rans_symbol_decoder.h b/cloudreg_env/include/draco/compression/entropy/rans_symbol_decoder.h deleted file mode 100644 index 1b5f1c8..0000000 --- a/cloudreg_env/include/draco/compression/entropy/rans_symbol_decoder.h +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_DECODER_H_ -#define DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/entropy/rans_symbol_coding.h" -#include "draco/core/decoder_buffer.h" -#include "draco/core/varint_decoding.h" - -namespace draco { - -// A helper class for decoding symbols using the rANS algorithm (see ans.h). -// The class can be used to decode the probability table and the data encoded -// by the RAnsSymbolEncoder. |unique_symbols_bit_length_t| must be the same as -// the one used for the corresponding RAnsSymbolEncoder. -template -class RAnsSymbolDecoder { - public: - RAnsSymbolDecoder() : num_symbols_(0) {} - - // Initialize the decoder and decode the probability table. - bool Create(DecoderBuffer *buffer); - - uint32_t num_symbols() const { return num_symbols_; } - - // Starts decoding from the buffer. The buffer will be advanced past the - // encoded data after this call. - bool StartDecoding(DecoderBuffer *buffer); - uint32_t DecodeSymbol() { return ans_.rans_read(); } - void EndDecoding(); - - private: - static constexpr int rans_precision_bits_ = - ComputeRAnsPrecisionFromUniqueSymbolsBitLength( - unique_symbols_bit_length_t); - static constexpr int rans_precision_ = 1 << rans_precision_bits_; - - std::vector probability_table_; - uint32_t num_symbols_; - RAnsDecoder ans_; -}; - -template -bool RAnsSymbolDecoder::Create( - DecoderBuffer *buffer) { - // Check that the DecoderBuffer version is set. - if (buffer->bitstream_version() == 0) - return false; - // Decode the number of alphabet symbols. -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 0)) { - if (!buffer->Decode(&num_symbols_)) - return false; - - } else -#endif - { - if (!DecodeVarint(&num_symbols_, buffer)) - return false; - } - probability_table_.resize(num_symbols_); - if (num_symbols_ == 0) - return true; - // Decode the table. - for (uint32_t i = 0; i < num_symbols_; ++i) { - uint8_t prob_data = 0; - // Decode the first byte and extract the number of extra bytes we need to - // get, or the offset to the next symbol with non-zero probability. - if (!buffer->Decode(&prob_data)) - return false; - // Token is stored in the first two bits of the first byte. Values 0-2 are - // used to indicate the number of extra bytes, and value 3 is a special - // symbol used to denote run-length coding of zero probability entries. - // See rans_symbol_encoder.h for more details. - const int token = prob_data & 3; - if (token == 3) { - const uint32_t offset = prob_data >> 2; - if (i + offset >= num_symbols_) - return false; - // Set zero probability for all symbols in the specified range. - for (uint32_t j = 0; j < offset + 1; ++j) { - probability_table_[i + j] = 0; - } - i += offset; - } else { - const int extra_bytes = token; - uint32_t prob = prob_data >> 2; - for (int b = 0; b < extra_bytes; ++b) { - uint8_t eb; - if (!buffer->Decode(&eb)) - return false; - // Shift 8 bits for each extra byte and subtract 2 for the two first - // bits. - prob |= static_cast(eb) << (8 * (b + 1) - 2); - } - probability_table_[i] = prob; - } - } - if (!ans_.rans_build_look_up_table(&probability_table_[0], num_symbols_)) - return false; - return true; -} - -template -bool RAnsSymbolDecoder::StartDecoding( - DecoderBuffer *buffer) { - uint64_t bytes_encoded; - // Decode the number of bytes encoded by the encoder. -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 0)) { - if (!buffer->Decode(&bytes_encoded)) - return false; - - } else -#endif - { - if (!DecodeVarint(&bytes_encoded, buffer)) - return false; - } - if (bytes_encoded > static_cast(buffer->remaining_size())) - return false; - const uint8_t *const data_head = - reinterpret_cast(buffer->data_head()); - // Advance the buffer past the rANS data. - buffer->Advance(bytes_encoded); - if (ans_.read_init(data_head, static_cast(bytes_encoded)) != 0) - return false; - return true; -} - -template -void RAnsSymbolDecoder::EndDecoding() { - ans_.read_end(); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/rans_symbol_encoder.h b/cloudreg_env/include/draco/compression/entropy/rans_symbol_encoder.h deleted file mode 100644 index 4b0ed09..0000000 --- a/cloudreg_env/include/draco/compression/entropy/rans_symbol_encoder.h +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_ENCODER_H_ -#define DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_ENCODER_H_ - -#include -#include -#include - -#include "draco/compression/entropy/ans.h" -#include "draco/compression/entropy/rans_symbol_coding.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/varint_encoding.h" - -namespace draco { - -// A helper class for encoding symbols using the rANS algorithm (see ans.h). -// The class can be used to initialize and encode probability table needed by -// rANS, and to perform encoding of symbols into the provided EncoderBuffer. -template -class RAnsSymbolEncoder { - public: - RAnsSymbolEncoder() - : num_symbols_(0), num_expected_bits_(0), buffer_offset_(0) {} - - // Creates a probability table needed by the rANS library and encode it into - // the provided buffer. - bool Create(const uint64_t *frequencies, int num_symbols, - EncoderBuffer *buffer); - - void StartEncoding(EncoderBuffer *buffer); - void EncodeSymbol(uint32_t symbol) { - ans_.rans_write(&probability_table_[symbol]); - } - void EndEncoding(EncoderBuffer *buffer); - - // rANS requires to encode the input symbols in the reverse order. - static constexpr bool needs_reverse_encoding() { return true; } - - private: - // Functor used for sorting symbol ids according to their probabilities. - // The functor sorts symbol indices that index an underlying map between - // symbol ids and their probabilities. We don't sort the probability table - // directly, because that would require an additional indirection during the - // EncodeSymbol() function. - struct ProbabilityLess { - explicit ProbabilityLess(const std::vector *probs) - : probabilities(probs) {} - bool operator()(int i, int j) const { - return probabilities->at(i).prob < probabilities->at(j).prob; - } - const std::vector *probabilities; - }; - - // Encodes the probability table into the output buffer. - bool EncodeTable(EncoderBuffer *buffer); - - static constexpr int rans_precision_bits_ = - ComputeRAnsPrecisionFromUniqueSymbolsBitLength( - unique_symbols_bit_length_t); - static constexpr int rans_precision_ = 1 << rans_precision_bits_; - - std::vector probability_table_; - // The number of symbols in the input alphabet. - uint32_t num_symbols_; - // Expected number of bits that is needed to encode the input. - uint64_t num_expected_bits_; - - RAnsEncoder ans_; - // Initial offset of the encoder buffer before any ans data was encoded. - uint64_t buffer_offset_; -}; - -template -bool RAnsSymbolEncoder::Create( - const uint64_t *frequencies, int num_symbols, EncoderBuffer *buffer) { - // Compute the total of the input frequencies. - uint64_t total_freq = 0; - int max_valid_symbol = 0; - for (int i = 0; i < num_symbols; ++i) { - total_freq += frequencies[i]; - if (frequencies[i] > 0) - max_valid_symbol = i; - } - num_symbols = max_valid_symbol + 1; - num_symbols_ = num_symbols; - probability_table_.resize(num_symbols); - const double total_freq_d = static_cast(total_freq); - const double rans_precision_d = static_cast(rans_precision_); - // Compute probabilities by rescaling the normalized frequencies into interval - // [1, rans_precision - 1]. The total probability needs to be equal to - // rans_precision. - int total_rans_prob = 0; - for (int i = 0; i < num_symbols; ++i) { - const uint64_t freq = frequencies[i]; - - // Normalized probability. - const double prob = static_cast(freq) / total_freq_d; - - // RAns probability in range of [1, rans_precision - 1]. - uint32_t rans_prob = static_cast(prob * rans_precision_d + 0.5f); - if (rans_prob == 0 && freq > 0) - rans_prob = 1; - probability_table_[i].prob = rans_prob; - total_rans_prob += rans_prob; - } - // Because of rounding errors, the total precision may not be exactly accurate - // and we may need to adjust the entries a little bit. - if (total_rans_prob != rans_precision_) { - std::vector sorted_probabilities(num_symbols); - for (int i = 0; i < num_symbols; ++i) { - sorted_probabilities[i] = i; - } - std::sort(sorted_probabilities.begin(), sorted_probabilities.end(), - ProbabilityLess(&probability_table_)); - if (total_rans_prob < rans_precision_) { - // This happens rather infrequently, just add the extra needed precision - // to the most frequent symbol. - probability_table_[sorted_probabilities.back()].prob += - rans_precision_ - total_rans_prob; - } else { - // We have over-allocated the precision, which is quite common. - // Rescale the probabilities of all symbols. - int32_t error = total_rans_prob - rans_precision_; - while (error > 0) { - const double act_total_prob_d = static_cast(total_rans_prob); - const double act_rel_error_d = rans_precision_d / act_total_prob_d; - for (int j = num_symbols - 1; j > 0; --j) { - int symbol_id = sorted_probabilities[j]; - if (probability_table_[symbol_id].prob <= 1) { - if (j == num_symbols - 1) - return false; // Most frequent symbol would be empty. - break; - } - const int32_t new_prob = static_cast( - floor(act_rel_error_d * - static_cast(probability_table_[symbol_id].prob))); - int32_t fix = probability_table_[symbol_id].prob - new_prob; - if (fix == 0u) - fix = 1; - if (fix >= static_cast(probability_table_[symbol_id].prob)) - fix = probability_table_[symbol_id].prob - 1; - if (fix > error) - fix = error; - probability_table_[symbol_id].prob -= fix; - total_rans_prob -= fix; - error -= fix; - if (total_rans_prob == rans_precision_) - break; - } - } - } - } - - // Compute the cumulative probability (cdf). - uint32_t total_prob = 0; - for (int i = 0; i < num_symbols; ++i) { - probability_table_[i].cum_prob = total_prob; - total_prob += probability_table_[i].prob; - } - if (total_prob != rans_precision_) - return false; - - // Estimate the number of bits needed to encode the input. - // From Shannon entropy the total number of bits N is: - // N = -sum{i : all_symbols}(F(i) * log2(P(i))) - // where P(i) is the normalized probability of symbol i and F(i) is the - // symbol's frequency in the input data. - double num_bits = 0; - for (int i = 0; i < num_symbols; ++i) { - if (probability_table_[i].prob == 0) - continue; - const double norm_prob = - static_cast(probability_table_[i].prob) / rans_precision_d; - num_bits += static_cast(frequencies[i]) * log2(norm_prob); - } - num_expected_bits_ = static_cast(ceil(-num_bits)); - if (!EncodeTable(buffer)) - return false; - return true; -} - -template -bool RAnsSymbolEncoder::EncodeTable( - EncoderBuffer *buffer) { - EncodeVarint(num_symbols_, buffer); - // Use varint encoding for the probabilities (first two bits represent the - // number of bytes used - 1). - for (uint32_t i = 0; i < num_symbols_; ++i) { - const uint32_t prob = probability_table_[i].prob; - int num_extra_bytes = 0; - if (prob >= (1 << 6)) { - num_extra_bytes++; - if (prob >= (1 << 14)) { - num_extra_bytes++; - if (prob >= (1 << 22)) { - // The maximum number of precision bits is 20 so we should not really - // get to this point. - return false; - } - } - } - if (prob == 0) { - // When the probability of the symbol is 0, set the first two bits to 1 - // (unique identifier) and use the remaining 6 bits to store the offset - // to the next symbol with non-zero probability. - uint32_t offset = 0; - for (; offset < (1 << 6) - 1; ++offset) { - // Note: we don't have to check whether the next symbol id is larger - // than num_symbols_ because we know that the last symbol always has - // non-zero probability. - const uint32_t next_prob = probability_table_[i + offset + 1].prob; - if (next_prob > 0) { - break; - } - } - buffer->Encode(static_cast((offset << 2) | 3)); - i += offset; - } else { - // Encode the first byte (including the number of extra bytes). - buffer->Encode(static_cast((prob << 2) | (num_extra_bytes & 3))); - // Encode the extra bytes. - for (int b = 0; b < num_extra_bytes; ++b) { - buffer->Encode(static_cast(prob >> (8 * (b + 1) - 2))); - } - } - } - return true; -} - -template -void RAnsSymbolEncoder::StartEncoding( - EncoderBuffer *buffer) { - // Allocate extra storage just in case. - const uint64_t required_bits = 2 * num_expected_bits_ + 32; - - buffer_offset_ = buffer->size(); - const int64_t required_bytes = (required_bits + 7) / 8; - buffer->Resize(buffer_offset_ + required_bytes + sizeof(buffer_offset_)); - uint8_t *const data = - reinterpret_cast(const_cast(buffer->data())); - ans_.write_init(data + buffer_offset_); -} - -template -void RAnsSymbolEncoder::EndEncoding( - EncoderBuffer *buffer) { - char *const src = const_cast(buffer->data()) + buffer_offset_; - - // TODO(fgalligan): Look into changing this to uint32_t as write_end() - // returns an int. - const uint64_t bytes_written = static_cast(ans_.write_end()); - EncoderBuffer var_size_buffer; - EncodeVarint(bytes_written, &var_size_buffer); - const uint32_t size_len = static_cast(var_size_buffer.size()); - char *const dst = src + size_len; - memmove(dst, src, bytes_written); - - // Store the size of the encoded data. - memcpy(src, var_size_buffer.data(), size_len); - - // Resize the buffer to match the number of encoded bytes. - buffer->Resize(buffer_offset_ + bytes_written + size_len); -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENTROPY_RANS_SYMBOL_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/shannon_entropy.h b/cloudreg_env/include/draco/compression/entropy/shannon_entropy.h deleted file mode 100644 index 85165f4..0000000 --- a/cloudreg_env/include/draco/compression/entropy/shannon_entropy.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ENTROPY_SHANNON_ENTROPY_H_ -#define DRACO_COMPRESSION_ENTROPY_SHANNON_ENTROPY_H_ - -#include - -#include - -namespace draco { - -// Computes an approximate Shannon entropy of symbols stored in the provided -// input array |symbols|. The entropy corresponds to the number of bits that is -// required to represent/store all the symbols using an optimal entropy coding -// algorithm. See for example "A mathematical theory of communication" by -// Shannon'48 (http://ieeexplore.ieee.org/document/6773024/). -// -// |max_value| is a required input that define the maximum value in the input -// |symbols| array. -// -// |out_num_unique_symbols| is an optional output argument that stores the -// number of unique symbols contained within the |symbols| array. -// TODO(ostava): This should be renamed or the return value should be changed to -// return the actual entropy and not the number of bits needed to represent the -// input symbols. -int64_t ComputeShannonEntropy(const uint32_t *symbols, int num_symbols, - int max_value, int *out_num_unique_symbols); - -// Computes the Shannon entropy of |num_values| Boolean entries, where -// |num_true_values| are set to true. -// Returns entropy between 0-1. -double ComputeBinaryShannonEntropy(uint32_t num_values, - uint32_t num_true_values); - -// Class that can be used to keep track of the Shannon entropy on streamed data. -// As new symbols are pushed to the tracker, the entropy is automatically -// recomputed. The class also support recomputing the entropy without actually -// pushing the symbols to the tracker through the Peek() method. -class ShannonEntropyTracker { - public: - ShannonEntropyTracker(); - - // Struct for holding entropy data about the symbols added to the tracker. - // It can be used to compute the number of bits needed to store the data using - // the method: - // ShannonEntropyTracker::GetNumberOfDataBits(entropy_data); - // or to compute the approximate size of the frequency table needed by the - // rans coding using method: - // ShannonEntropyTracker::GetNumberOfRAnsTableBits(entropy_data); - struct EntropyData { - double entropy_norm; - int num_values; - int max_symbol; - int num_unique_symbols; - EntropyData() - : entropy_norm(0.0), - num_values(0), - max_symbol(0), - num_unique_symbols(0) {} - }; - - // Adds new symbols to the tracker and recomputes the entropy accordingly. - EntropyData Push(const uint32_t *symbols, int num_symbols); - - // Returns new entropy data for the tracker as if |symbols| were added to the - // tracker without actually changing the status of the tracker. - EntropyData Peek(const uint32_t *symbols, int num_symbols); - - // Gets the number of bits needed for encoding symbols added to the tracker. - int64_t GetNumberOfDataBits() const { - return GetNumberOfDataBits(entropy_data_); - } - - // Gets the number of bits needed for encoding frequency table using the rans - // encoder. - int64_t GetNumberOfRAnsTableBits() const { - return GetNumberOfRAnsTableBits(entropy_data_); - } - - // Gets the number of bits needed for encoding given |entropy_data|. - static int64_t GetNumberOfDataBits(const EntropyData &entropy_data); - - // Gets the number of bits needed for encoding frequency table using the rans - // encoder for the given |entropy_data|. - static int64_t GetNumberOfRAnsTableBits(const EntropyData &entropy_data); - - private: - EntropyData UpdateSymbols(const uint32_t *symbols, int num_symbols, - bool push_changes); - - std::vector frequencies_; - - EntropyData entropy_data_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENTROPY_SHANNON_ENTROPY_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/symbol_decoding.h b/cloudreg_env/include/draco/compression/entropy/symbol_decoding.h deleted file mode 100644 index ea11165..0000000 --- a/cloudreg_env/include/draco/compression/entropy/symbol_decoding.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ENTROPY_SYMBOL_DECODING_H_ -#define DRACO_COMPRESSION_ENTROPY_SYMBOL_DECODING_H_ - -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// Decodes an array of symbols that was previously encoded with an entropy code. -// Returns false on error. -bool DecodeSymbols(uint32_t num_values, int num_components, - DecoderBuffer *src_buffer, uint32_t *out_values); - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENTROPY_SYMBOL_DECODING_H_ diff --git a/cloudreg_env/include/draco/compression/entropy/symbol_encoding.h b/cloudreg_env/include/draco/compression/entropy/symbol_encoding.h deleted file mode 100644 index 839b28b..0000000 --- a/cloudreg_env/include/draco/compression/entropy/symbol_encoding.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_ENTROPY_SYMBOL_ENCODING_H_ -#define DRACO_COMPRESSION_ENTROPY_SYMBOL_ENCODING_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/options.h" - -namespace draco { - -// Encodes an array of symbols using an entropy coding. This function -// automatically decides whether to encode the symbol values using bit -// length tags (see EncodeTaggedSymbols), or whether to encode them directly -// (see EncodeRawSymbols). The symbols can be grouped into separate components -// that can be used for better compression. |options| is an optional parameter -// that allows more direct control over various stages of the symbol encoding -// (see below for functions that are used to set valid options). -// Returns false on error. -bool EncodeSymbols(const uint32_t *symbols, int num_values, int num_components, - const Options *options, EncoderBuffer *target_buffer); - -// Sets an option that forces symbol encoder to use the specified encoding -// method. -void SetSymbolEncodingMethod(Options *options, SymbolCodingMethod method); - -// Sets the desired compression level for symbol encoding in range <0, 10> where -// 0 is the worst but fastest compression and 10 is the best but slowest -// compression. If the option is not set, default value of 7 is used. -// Returns false if an invalid level has been set. -bool SetSymbolEncodingCompressionLevel(Options *options, int compression_level); - -} // namespace draco - -#endif // DRACO_COMPRESSION_ENTROPY_SYMBOL_ENCODING_H_ diff --git a/cloudreg_env/include/draco/compression/expert_encode.h b/cloudreg_env/include/draco/compression/expert_encode.h deleted file mode 100644 index a1aa7b8..0000000 --- a/cloudreg_env/include/draco/compression/expert_encode.h +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_SRC_DRACO_COMPRESSION_EXPERT_ENCODE_H_ -#define DRACO_SRC_DRACO_COMPRESSION_EXPERT_ENCODE_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/encoder_options.h" -#include "draco/compression/encode_base.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/status.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Advanced helper class for encoding geometry using the Draco compression -// library. Unlike the basic Encoder (encode.h), this class allows users to -// specify options for each attribute individually using provided attribute ids. -// The drawback of this encoder is that it can be used to encode only one model -// at a time, and for each new model the options need to be set again, -class ExpertEncoder : public EncoderBase { - public: - typedef EncoderBase Base; - typedef EncoderOptions OptionsType; - - explicit ExpertEncoder(const PointCloud &point_cloud); - explicit ExpertEncoder(const Mesh &mesh); - - // Encodes the geometry provided in the constructor to the target buffer. - Status EncodeToBuffer(EncoderBuffer *out_buffer); - - // Set encoder options used during the geometry encoding. Note that this call - // overwrites any modifications to the options done with the functions below. - void Reset(const EncoderOptions &options); - void Reset(); - - // Sets the desired encoding and decoding speed for the given options. - // - // 0 = slowest speed, but the best compression. - // 10 = fastest, but the worst compression. - // -1 = undefined. - // - // Note that both speed options affect the encoder choice of used methods and - // algorithms. For example, a requirement for fast decoding may prevent the - // encoder from using the best compression methods even if the encoding speed - // is set to 0. In general, the faster of the two options limits the choice of - // features that can be used by the encoder. Additionally, setting - // |decoding_speed| to be faster than the |encoding_speed| may allow the - // encoder to choose the optimal method out of the available features for the - // given |decoding_speed|. - void SetSpeedOptions(int encoding_speed, int decoding_speed); - - // Sets the quantization compression options for a specific attribute. The - // attribute values will be quantized in a box defined by the maximum extent - // of the attribute values. I.e., the actual precision of this option depends - // on the scale of the attribute values. - void SetAttributeQuantization(int32_t attribute_id, int quantization_bits); - - // Sets the explicit quantization compression for a named attribute. The - // attribute values will be quantized in a coordinate system defined by the - // provided origin and range (the input values should be within interval: - // ). - void SetAttributeExplicitQuantization(int32_t attribute_id, - int quantization_bits, int num_dims, - const float *origin, float range); - - // Enables/disables built in entropy coding of attribute values. Disabling - // this option may be useful to improve the performance when third party - // compression is used on top of the Draco compression. Default: [true]. - void SetUseBuiltInAttributeCompression(bool enabled); - - // Sets the desired encoding method for a given geometry. By default, encoding - // method is selected based on the properties of the input geometry and based - // on the other options selected in the used EncoderOptions (such as desired - // encoding and decoding speed). This function should be called only when a - // specific method is required. - // - // |encoding_method| can be one of the values defined in - // compression/config/compression_shared.h based on the type of the input - // geometry that is going to be encoded. For point clouds, allowed entries are - // POINT_CLOUD_SEQUENTIAL_ENCODING - // POINT_CLOUD_KD_TREE_ENCODING - // - // For meshes the input can be - // MESH_SEQUENTIAL_ENCODING - // MESH_EDGEBREAKER_ENCODING - // - // If the selected method cannot be used for the given input, the subsequent - // call of EncodePointCloudToBuffer or EncodeMeshToBuffer is going to fail. - void SetEncodingMethod(int encoding_method); - - // Sets the desired encoding submethod, only for MESH_EDGEBREAKER_ENCODING. - // Valid values for |encoding_submethod| are: - // MESH_EDGEBREAKER_STANDARD_ENCODING - // MESH_EDGEBREAKER_VALENCE_ENCODING - // see also compression/config/compression_shared.h. - void SetEncodingSubmethod(int encoding_submethod); - - // Sets the desired prediction method for a given attribute. By default, - // prediction scheme is selected automatically by the encoder using other - // provided options (such as speed) and input geometry type (mesh, point - // cloud). This function should be called only when a specific prediction is - // preferred (e.g., when it is known that the encoder would select a less - // optimal prediction for the given input data). - // - // |prediction_scheme_method| should be one of the entries defined in - // compression/config/compression_shared.h : - // - // PREDICTION_NONE - use no prediction. - // PREDICTION_DIFFERENCE - delta coding - // MESH_PREDICTION_PARALLELOGRAM - parallelogram prediction for meshes. - // MESH_PREDICTION_CONSTRAINED_PARALLELOGRAM - // - better and more costly version of the parallelogram prediction. - // MESH_PREDICTION_TEX_COORDS_PORTABLE - // - specialized predictor for tex coordinates. - // MESH_PREDICTION_GEOMETRIC_NORMAL - // - specialized predictor for normal coordinates. - // - // Note that in case the desired prediction cannot be used, the default - // prediction will be automatically used instead. - Status SetAttributePredictionScheme(int32_t attribute_id, - int prediction_scheme_method); - - private: - Status EncodePointCloudToBuffer(const PointCloud &pc, - EncoderBuffer *out_buffer); - - Status EncodeMeshToBuffer(const Mesh &m, EncoderBuffer *out_buffer); - - const PointCloud *point_cloud_; - const Mesh *mesh_; -}; - -} // namespace draco - -#endif // DRACO_SRC_DRACO_COMPRESSION_EXPERT_ENCODE_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_decoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_decoder.h deleted file mode 100644 index 397a679..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_decoder.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_DECODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_DECODER_H_ - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/point_cloud/point_cloud_decoder.h" -#include "draco/mesh/mesh.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -// Class that reconstructs a 3D mesh from input data that was encoded by -// MeshEncoder. -class MeshDecoder : public PointCloudDecoder { - public: - MeshDecoder(); - - EncodedGeometryType GetGeometryType() const override { - return TRIANGULAR_MESH; - } - - // The main entry point for mesh decoding. - Status Decode(const DecoderOptions &options, DecoderBuffer *in_buffer, - Mesh *out_mesh); - - // Returns the base connectivity of the decoded mesh (or nullptr if it is not - // initialized). - virtual const CornerTable *GetCornerTable() const { return nullptr; } - - // Returns the attribute connectivity data or nullptr if it does not exist. - virtual const MeshAttributeCornerTable *GetAttributeCornerTable( - int /* att_id */) const { - return nullptr; - } - - // Returns the decoding data for a given attribute or nullptr when the data - // does not exist. - virtual const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int /* att_id */) const { - return nullptr; - } - - Mesh *mesh() const { return mesh_; } - - protected: - bool DecodeGeometryData() override; - virtual bool DecodeConnectivity() = 0; - - private: - Mesh *mesh_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_decoder_helpers.h b/cloudreg_env/include/draco/compression/mesh/mesh_decoder_helpers.h deleted file mode 100644 index 12ac46b..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_decoder_helpers.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_DECODER_HELPERS_H_ -#define DRACO_COMPRESSION_MESH_MESH_DECODER_HELPERS_H_ - -#include "draco/compression/mesh/mesh_decoder.h" - -namespace draco { - -// Function for decoding a stream previously encoded by a MeshEncoder. The -// result is stored into a stream of single precision floating point numbers -// in a XYZ|UV format, where one value is stored for every corner of each -// triangle. -// On error, the function sets the input stream "is" to an invalid state. -template -InStreamT &DecodePos3Tex2DataFromStream(InStreamT &&is, - std::vector *out_data) { - // Determine the size of the encoded data and write it into a vector. - const auto start_pos = is.tellg(); - is.seekg(0, std::ios::end); - const std::streampos is_size = is.tellg() - start_pos; - is.seekg(start_pos); - std::vector data(is_size); - is.read(&data[0], is_size); - - // Create a mesh from the data. - std::unique_ptr mesh = draco::DecodeMesh(&data[0], data.size()); - - if (mesh == nullptr) { - is.setstate(ios_base::badbit); - return is; - } - - const PointAttribute *pos_att = - mesh->GetNamedAttribute(GeometryAttribute::POSITION); - const PointAttribute *tex_att = - mesh->GetNamedAttribute(GeometryAttribute::TEX_COORD_0); - - // Both position and texture attributes must be present. - if (pos_att == nullptr || tex_att == nullptr) { - is.setstate(ios_base::badbit); - return is; - } - - // Copy the mesh data into the provided output. - constexpr int data_stride = 5; - // Prepare the output storage for 3 output values per face. - out_data->resize(mesh->num_faces() * 3 * data_stride); - - std::array pos_val; - std::array tex_val; - int out_it = 0; - for (int f = 0; f < mesh->num_faces(); ++f) { - const Mesh::Face &face = mesh->face(f); - for (int p = 0; p < 3; ++p) { - pos_att->ConvertValue(pos_att->mapped_index(face[p]), - &pos_val[0]); - memcpy(&out_data->at(0) + out_it, &pos_val[0], sizeof(pos_val)); - out_it += 3; - tex_att->ConvertValue(tex_att->mapped_index(face[p]), - &tex_val[0]); - memcpy(&out_data->at(0) + out_it, &tex_val[0], sizeof(tex_val)); - out_it += 2; - } - } - - return is; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_DECODER_HELPERS_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder.h deleted file mode 100644 index c356940..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/mesh/mesh_decoder.h" -#include "draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h" - -namespace draco { - -// Class for decoding data encoded by MeshEdgebreakerEncoder. -class MeshEdgebreakerDecoder : public MeshDecoder { - public: - MeshEdgebreakerDecoder(); - - const CornerTable *GetCornerTable() const override { - return impl_->GetCornerTable(); - } - - const MeshAttributeCornerTable *GetAttributeCornerTable( - int att_id) const override { - return impl_->GetAttributeCornerTable(att_id); - } - - const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int att_id) const override { - return impl_->GetAttributeEncodingData(att_id); - } - - protected: - bool InitializeDecoder() override; - bool CreateAttributesDecoder(int32_t att_decoder_id) override; - bool DecodeConnectivity() override; - bool OnAttributesDecoded() override; - - std::unique_ptr impl_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h deleted file mode 100644 index 5299a18..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_IMPL_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_IMPL_H_ - -#include -#include -#include "draco/compression/mesh/traverser/mesh_traversal_sequencer.h" - -#include "draco/draco_features.h" - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h" -#include "draco/compression/mesh/mesh_edgebreaker_shared.h" -#include "draco/core/decoder_buffer.h" -#include "draco/mesh/corner_table.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -// Implementation of the edgebreaker decoder that decodes data encoded with the -// MeshEdgebreakerEncoderImpl class. The implementation of the decoder is based -// on the algorithm presented in Isenburg et al'02 "Spirale Reversi: Reverse -// decoding of the Edgebreaker encoding". Note that the encoding is still based -// on the standard edgebreaker method as presented in "3D Compression -// Made Simple: Edgebreaker on a Corner-Table" by Rossignac at al.'01. -// http://www.cc.gatech.edu/~jarek/papers/CornerTableSMI.pdf. One difference is -// caused by the properties of the spirale reversi algorithm that decodes the -// symbols from the last one to the first one. To make the decoding more -// efficient, we encode all symbols in the reverse order, therefore the decoder -// can process them one by one. -// The main advantage of the spirale reversi method is that the partially -// decoded mesh has valid connectivity data at any time during the decoding -// process (valid with respect to the decoded portion of the mesh). The standard -// Edgebreaker decoder used two passes (forward decoding + zipping) which not -// only prevented us from having a valid connectivity but it was also slower. -// The main benefit of having the valid connectivity is that we can use the -// known connectivity to predict encoded symbols that can improve the -// compression rate. -template -class MeshEdgebreakerDecoderImpl : public MeshEdgebreakerDecoderImplInterface { - public: - MeshEdgebreakerDecoderImpl(); - bool Init(MeshEdgebreakerDecoder *decoder) override; - - const MeshAttributeCornerTable *GetAttributeCornerTable( - int att_id) const override; - const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int att_id) const override; - - bool CreateAttributesDecoder(int32_t att_decoder_id) override; - bool DecodeConnectivity() override; - bool OnAttributesDecoded() override; - MeshEdgebreakerDecoder *GetDecoder() const override { return decoder_; } - const CornerTable *GetCornerTable() const override { - return corner_table_.get(); - } - - private: - // Creates a vertex traversal sequencer for the specified |TraverserT| type. - template - std::unique_ptr CreateVertexTraversalSequencer( - MeshAttributeIndicesEncodingData *encoding_data); - - // Decodes connectivity between vertices (vertex indices). - // Returns the number of vertices created by the decoder or -1 on error. - int DecodeConnectivity(int num_symbols); - - // Returns true if the current symbol was part of a topology split event. This - // means that the current face was connected to the left edge of a face - // encoded with the TOPOLOGY_S symbol. |out_symbol_edge| can be used to - // identify which edge of the source symbol was connected to the TOPOLOGY_S - // symbol. - bool IsTopologySplit(int encoder_symbol_id, EdgeFaceName *out_face_edge, - int *out_encoder_split_symbol_id) { - if (topology_split_data_.size() == 0) - return false; - if (topology_split_data_.back().source_symbol_id > - static_cast(encoder_symbol_id)) { - // Something is wrong; if the desired source symbol is greater than the - // current encoder_symbol_id, we missed it, or the input was tampered - // (|encoder_symbol_id| keeps decreasing). - // Return invalid symbol id to notify the decoder that there was an - // error. - *out_encoder_split_symbol_id = -1; - return true; - } - if (topology_split_data_.back().source_symbol_id != encoder_symbol_id) - return false; - *out_face_edge = - static_cast(topology_split_data_.back().source_edge); - *out_encoder_split_symbol_id = topology_split_data_.back().split_symbol_id; - // Remove the latest split event. - topology_split_data_.pop_back(); - return true; - } - - // Decodes event data for hole and topology split events and stores them for - // future use. - // Returns the number of parsed bytes, or -1 on error. - int32_t DecodeHoleAndTopologySplitEvents(DecoderBuffer *decoder_buffer); - - // Decodes all non-position attribute connectivity on the currently - // processed face. -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - bool DecodeAttributeConnectivitiesOnFaceLegacy(CornerIndex corner); -#endif - bool DecodeAttributeConnectivitiesOnFace(CornerIndex corner); - - // Initializes mapping between corners and point ids. - bool AssignPointsToCorners(int num_connectivity_verts); - - bool IsFaceVisited(CornerIndex corner_id) const { - if (corner_id < 0) - return true; // Invalid corner signalizes that the face does not exist. - return visited_faces_[corner_table_->Face(corner_id).value()]; - } - - void SetOppositeCorners(CornerIndex corner_0, CornerIndex corner_1) { - corner_table_->SetOppositeCorner(corner_0, corner_1); - corner_table_->SetOppositeCorner(corner_1, corner_0); - } - - MeshEdgebreakerDecoder *decoder_; - - std::unique_ptr corner_table_; - - // Stack used for storing corners that need to be traversed when decoding - // mesh vertices. New corner is added for each initial face and a split - // symbol, and one corner is removed when the end symbol is reached. - // Stored as member variable to prevent frequent memory reallocations when - // handling meshes with lots of disjoint components. Originally, we used - // recursive functions to handle this behavior, but that can cause stack - // memory overflow when compressing huge meshes. - std::vector corner_traversal_stack_; - - // Array stores the number of visited visited for each mesh traversal. - std::vector vertex_traversal_length_; - - // List of decoded topology split events. - std::vector topology_split_data_; - - // List of decoded hole events. - std::vector hole_event_data_; - - // Configuration of the initial face for each mesh component. - std::vector init_face_configurations_; - - // Initial corner for each traversal. - std::vector init_corners_; - - // Id of the last processed input symbol. - int last_symbol_id_; - - // Id of the last decoded vertex. - int last_vert_id_; - - // Id of the last decoded face. - int last_face_id_; - - // Array for marking visited faces. - std::vector visited_faces_; - // Array for marking visited vertices. - std::vector visited_verts_; - // Array for marking vertices on open boundaries. - std::vector is_vert_hole_; - - // The number of new vertices added by the encoder (because of non-manifold - // vertices on the input mesh). - // If there are no non-manifold edges/vertices on the input mesh, this should - // be 0. - int num_new_vertices_; - // For every newly added vertex, this array stores it's mapping to the - // parent vertex id of the encoded mesh. - std::unordered_map new_to_parent_vertex_map_; - // The number of vertices that were encoded (can be different from the number - // of vertices of the input mesh). - int num_encoded_vertices_; - - // Array for storing the encoded corner ids in the order their associated - // vertices were decoded. - std::vector processed_corner_ids_; - - // Array storing corners in the order they were visited during the - // connectivity decoding (always storing the tip corner of each newly visited - // face). - std::vector processed_connectivity_corners_; - - MeshAttributeIndicesEncodingData pos_encoding_data_; - - // Id of an attributes decoder that uses |pos_encoding_data_|. - int pos_data_decoder_id_; - - // Data for non-position attributes used by the decoder. - struct AttributeData { - AttributeData() : decoder_id(-1), is_connectivity_used(true) {} - // Id of the attribute decoder that was used to decode this attribute data. - int decoder_id; - MeshAttributeCornerTable connectivity_data; - // Flag that can mark the connectivity_data invalid. In such case the base - // corner table of the mesh should be used instead. - bool is_connectivity_used; - MeshAttributeIndicesEncodingData encoding_data; - // Opposite corners to attribute seam edges. - std::vector attribute_seam_corners; - }; - std::vector attribute_data_; - - TraversalDecoderT traversal_decoder_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_IMPL_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h deleted file mode 100644 index 31fabf2..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_IMPL_INTERFACE_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_IMPL_INTERFACE_H_ - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -// Forward declaration is necessary here to avoid circular dependencies. -class MeshEdgebreakerDecoder; - -// Abstract interface used by MeshEdgebreakerDecoder to interact with the actual -// implementation of the edgebreaker decoding method. -class MeshEdgebreakerDecoderImplInterface { - public: - virtual ~MeshEdgebreakerDecoderImplInterface() = default; - virtual bool Init(MeshEdgebreakerDecoder *decoder) = 0; - - virtual const MeshAttributeCornerTable *GetAttributeCornerTable( - int att_id) const = 0; - virtual const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int att_id) const = 0; - virtual bool CreateAttributesDecoder(int32_t att_decoder_id) = 0; - virtual bool DecodeConnectivity() = 0; - virtual bool OnAttributesDecoded() = 0; - - virtual MeshEdgebreakerDecoder *GetDecoder() const = 0; - virtual const CornerTable *GetCornerTable() const = 0; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_DECODER_IMPL_INTERFACE_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder.h deleted file mode 100644 index 70d4d50..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_H_ - -#include - -#include "draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h" -#include "draco/compression/mesh/mesh_edgebreaker_shared.h" -#include "draco/compression/mesh/mesh_encoder.h" -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Class implements the edge breaker geometry compression method as described -// in "3D Compression Made Simple: Edgebreaker on a Corner-Table" by Rossignac -// at al.'01. http://www.cc.gatech.edu/~jarek/papers/CornerTableSMI.pdf -class MeshEdgebreakerEncoder : public MeshEncoder { - public: - MeshEdgebreakerEncoder(); - - const CornerTable *GetCornerTable() const override { - return impl_->GetCornerTable(); - } - - const MeshAttributeCornerTable *GetAttributeCornerTable( - int att_id) const override { - return impl_->GetAttributeCornerTable(att_id); - } - - const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int att_id) const override { - return impl_->GetAttributeEncodingData(att_id); - } - - uint8_t GetEncodingMethod() const override { - return MESH_EDGEBREAKER_ENCODING; - } - - protected: - bool InitializeEncoder() override; - Status EncodeConnectivity() override; - bool GenerateAttributesEncoder(int32_t att_id) override; - bool EncodeAttributesEncoderIdentifier(int32_t att_encoder_id) override; - void ComputeNumberOfEncodedPoints() override; - void ComputeNumberOfEncodedFaces() override; - - private: - // The actual implementation of the edge breaker method. The implementations - // are in general specializations of a template class - // MeshEdgebreakerEncoderImpl where the template arguments control encoding - // of the connectivity data. The actual implementation is selected in this - // class based on the provided encoding options. Because this choice is done - // in run-time, the actual implementation has to be hidden behind the - // abstract interface MeshEdgebreakerEncoderImplInterface. - std::unique_ptr impl_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h deleted file mode 100644 index fb33771..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_IMPL_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_IMPL_H_ - -#include - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h" -#include "draco/compression/mesh/mesh_edgebreaker_shared.h" -#include "draco/compression/mesh/traverser/mesh_traversal_sequencer.h" -#include "draco/core/encoder_buffer.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -// Class implementing the edgebreaker encoding as described in "3D Compression -// Made Simple: Edgebreaker on a Corner-Table" by Rossignac at al.'01. -// http://www.cc.gatech.edu/~jarek/papers/CornerTableSMI.pdf -template -class MeshEdgebreakerEncoderImpl : public MeshEdgebreakerEncoderImplInterface { - public: - MeshEdgebreakerEncoderImpl(); - explicit MeshEdgebreakerEncoderImpl( - const TraversalEncoderT &traversal_encoder); - bool Init(MeshEdgebreakerEncoder *encoder) override; - - const MeshAttributeCornerTable *GetAttributeCornerTable( - int att_id) const override; - const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int att_id) const override; - - bool GenerateAttributesEncoder(int32_t att_id) override; - bool EncodeAttributesEncoderIdentifier(int32_t att_encoder_id) override; - Status EncodeConnectivity() override; - - const CornerTable *GetCornerTable() const override { - return corner_table_.get(); - } - bool IsFaceEncoded(FaceIndex fi) const override { - return visited_faces_[fi.value()]; - } - MeshEdgebreakerEncoder *GetEncoder() const override { return encoder_; } - - private: - // Initializes data needed for encoding non-position attributes. - // Returns false on error. - bool InitAttributeData(); - - // Creates a vertex traversal sequencer for the specified |TraverserT| type. - template - std::unique_ptr CreateVertexTraversalSequencer( - MeshAttributeIndicesEncodingData *encoding_data); - - // Finds the configuration of the initial face that starts the traversal. - // Configurations are determined by location of holes around the init face - // and they are described in mesh_edgebreaker_shared.h. - // Returns true if the face configuration is interior and false if it is - // exterior. - bool FindInitFaceConfiguration(FaceIndex face_id, - CornerIndex *out_corner_id) const; - - // Encodes the connectivity between vertices. - bool EncodeConnectivityFromCorner(CornerIndex corner_id); - - // Encodes all vertices of a hole starting at start_corner_id. - // The vertex associated with the first corner is encoded only if - // |encode_first_vertex| is true. - // Returns the number of encoded hole vertices. - int EncodeHole(CornerIndex start_corner_id, bool encode_first_vertex); - - // Encodes topology split data. - // Returns nullptr on error. - bool EncodeSplitData(); - - CornerIndex GetRightCorner(CornerIndex corner_id) const; - CornerIndex GetLeftCorner(CornerIndex corner_id) const; - - bool IsRightFaceVisited(CornerIndex corner_id) const; - bool IsLeftFaceVisited(CornerIndex corner_id) const; - bool IsVertexVisited(VertexIndex vert_id) const { - return visited_vertex_ids_[vert_id.value()]; - } - - // Finds and stores data about all holes in the input mesh. - bool FindHoles(); - - // For faces encoded with symbol TOPOLOGY_S (split), this method returns - // the encoded symbol id or -1 if the face wasn't encoded by a split symbol. - int GetSplitSymbolIdOnFace(int face_id) const; - - // Checks whether there is a topology split event on a neighboring face and - // stores the event data if necessary. For more info about topology split - // events, see description of TopologySplitEventData in - // mesh_edgebreaker_shared.h. - void CheckAndStoreTopologySplitEvent(int src_symbol_id, int src_face_id, - EdgeFaceName src_edge, - int neighbor_face_id); - - // Encodes connectivity of all attributes on a newly traversed face. - bool EncodeAttributeConnectivitiesOnFace(CornerIndex corner); - - // This function is used to to assign correct encoding order of attributes - // to unprocessed corners. The encoding order is equal to the order in which - // the attributes are going to be processed by the decoder and it is necessary - // for proper prediction of attribute values. - bool AssignPositionEncodingOrderToAllCorners(); - - // This function is used to generate encoding order for all non-position - // attributes. - // Returns false when one or more attributes failed to be processed. - bool GenerateEncodingOrderForAttributes(); - - // The main encoder that owns this class. - MeshEdgebreakerEncoder *encoder_; - // Mesh that's being encoded. - const Mesh *mesh_; - // Corner table stores the mesh face connectivity data. - std::unique_ptr corner_table_; - // Stack used for storing corners that need to be traversed when encoding - // the connectivity. New corner is added for each initial face and a split - // symbol, and one corner is removed when the end symbol is reached. - // Stored as member variable to prevent frequent memory reallocations when - // handling meshes with lots of disjoint components. Originally, we used - // recursive functions to handle this behavior, but that can cause stack - // memory overflow when compressing huge meshes. - std::vector corner_traversal_stack_; - // Array for marking visited faces. - std::vector visited_faces_; - - // Attribute data for position encoding. - MeshAttributeIndicesEncodingData pos_encoding_data_; - - // Traversal method used for the position attribute. - MeshTraversalMethod pos_traversal_method_; - - // Array storing corners in the order they were visited during the - // connectivity encoding (always storing the tip corner of each newly visited - // face). - std::vector processed_connectivity_corners_; - - // Array for storing visited vertex ids of all input vertices. - std::vector visited_vertex_ids_; - - // For each traversal, this array stores the number of visited vertices. - std::vector vertex_traversal_length_; - // Array for storing all topology split events encountered during the mesh - // traversal. - std::vector topology_split_event_data_; - // Map between face_id and symbol_id. Contains entries only for faces that - // were encoded with TOPOLOGY_S symbol. - std::unordered_map face_to_split_symbol_map_; - - // Array for marking holes that has been reached during the traversal. - std::vector visited_holes_; - // Array for mapping vertices to hole ids. If a vertex is not on a hole, the - // stored value is -1. - std::vector vertex_hole_id_; - - // Id of the last encoded symbol. - int last_encoded_symbol_id_; - - // The number of encoded split symbols. - uint32_t num_split_symbols_; - - // Struct holding data used for encoding each non-position attribute. - // TODO(ostava): This should be probably renamed to something better. - struct AttributeData { - AttributeData() : attribute_index(-1), is_connectivity_used(true) {} - int attribute_index; - MeshAttributeCornerTable connectivity_data; - // Flag that can mark the connectivity_data invalid. In such case the base - // corner table of the mesh should be used instead. - bool is_connectivity_used; - // Data about attribute encoding order. - MeshAttributeIndicesEncodingData encoding_data; - // Traversal method used to generate the encoding data for this attribute. - MeshTraversalMethod traversal_method; - }; - std::vector attribute_data_; - - // Array storing mapping between attribute encoder id and attribute data id. - std::vector attribute_encoder_to_data_id_map_; - - TraversalEncoderT traversal_encoder_; - - // If set, the encoder is going to use the same connectivity for all - // attributes. This effectively breaks the mesh along all attribute seams. - // In general, this approach should be much faster compared to encoding each - // connectivity separately, but the decoded model may contain higher number of - // duplicate attribute values which may decrease the compression ratio. - bool use_single_connectivity_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_IMPL_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h deleted file mode 100644 index 627d512..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_IMPL_INTERFACE_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_IMPL_INTERFACE_H_ - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/mesh/corner_table.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -// Forward declaration is necessary here to avoid circular dependencies. -class MeshEdgebreakerEncoder; - -// Abstract interface used by MeshEdgebreakerEncoder to interact with the actual -// implementation of the edgebreaker method. The implementations are in general -// specializations of a template class MeshEdgebreakerEncoderImpl where the -// template arguments control encoding of the connectivity data. Because the -// choice of the implementation is done in run-time, we need to hide it behind -// the abstract interface MeshEdgebreakerEncoderImplInterface. -class MeshEdgebreakerEncoderImplInterface { - public: - virtual ~MeshEdgebreakerEncoderImplInterface() = default; - virtual bool Init(MeshEdgebreakerEncoder *encoder) = 0; - - virtual const MeshAttributeCornerTable *GetAttributeCornerTable( - int att_id) const = 0; - virtual const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int att_id) const = 0; - virtual bool GenerateAttributesEncoder(int32_t att_id) = 0; - virtual bool EncodeAttributesEncoderIdentifier(int32_t att_encoder_id) = 0; - virtual Status EncodeConnectivity() = 0; - - // Returns corner table of the encoded mesh. - virtual const CornerTable *GetCornerTable() const = 0; - - // Returns true if a given face has been already encoded. - virtual bool IsFaceEncoded(FaceIndex fi) const = 0; - - virtual MeshEdgebreakerEncoder *GetEncoder() const = 0; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_ENCODER_IMPL_INTERFACE_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_shared.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_shared.h deleted file mode 100644 index cb3c29d..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_shared.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_SHARED_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_SHARED_H_ - -#include - -namespace draco { - -// Shared declarations used by both edgebreaker encoder and decoder. - -// A variable length encoding for storing all possible topology configurations -// during traversal of mesh's surface. The configurations are based on visited -// state of neighboring triangles around a currently processed face corner. -// Note that about half of the encountered configurations is expected to be of -// type TOPOLOGY_C. It's guaranteed that the encoding will use at most 2 bits -// per triangle for meshes with no holes and up to 6 bits per triangle for -// general meshes. In addition, the encoding will take up to 4 bits per triangle -// for each non-position attribute attached to the mesh. -// -// *-------* *-------* *-------* -// / \ / \ / \ / \ / \ / \ -// / \ / \ / \ / \ / \ / \ -// / \ / \ / \ / \ / \ / \ -// *-------v-------* *-------v-------* *-------v-------* -// \ /x\ / /x\ / \ /x\ -// \ / \ / / \ / \ / \ -// \ / C \ / / L \ / \ / R \ -// *-------* *-------* *-------* -// -// * * -// / \ / \ -// / \ / \ -// / \ / \ -// *-------v-------* v -// \ /x\ / /x\ -// \ / \ / / \ -// \ / S \ / / E \ -// *-------* *-------* -// -// TODO(ostava): Get rid of the topology bit pattern. It's important only for -// encoding but the algorithms should use EdgebreakerSymbol instead. -enum EdgebreakerTopologyBitPattern { - TOPOLOGY_C = 0x0, // 0 - TOPOLOGY_S = 0x1, // 1 0 0 - TOPOLOGY_L = 0x3, // 1 1 0 - TOPOLOGY_R = 0x5, // 1 0 1 - TOPOLOGY_E = 0x7, // 1 1 1 - // A special symbol that's not actually encoded, but it can be used to mark - // the initial face that triggers the mesh encoding of a single connected - // component. - TOPOLOGY_INIT_FACE, - // A special value used to indicate an invalid symbol. - TOPOLOGY_INVALID -}; - -enum EdgebreakerSymbol { - EDGEBREAKER_SYMBOL_C = 0, - EDGEBREAKER_SYMBOL_S, - EDGEBREAKER_SYMBOL_L, - EDGEBREAKER_SYMBOL_R, - EDGEBREAKER_SYMBOL_E, - EDGEBREAKER_SYMBOL_INVALID -}; - -// Bit-length of symbols in the EdgebreakerTopologyBitPattern stored as a -// lookup table for faster indexing. -constexpr int32_t edge_breaker_topology_bit_pattern_length[] = {1, 3, 0, 3, - 0, 3, 0, 3}; - -// Zero-indexed symbol id for each of topology pattern. -constexpr EdgebreakerSymbol edge_breaker_topology_to_symbol_id[] = { - EDGEBREAKER_SYMBOL_C, EDGEBREAKER_SYMBOL_S, - EDGEBREAKER_SYMBOL_INVALID, EDGEBREAKER_SYMBOL_L, - EDGEBREAKER_SYMBOL_INVALID, EDGEBREAKER_SYMBOL_R, - EDGEBREAKER_SYMBOL_INVALID, EDGEBREAKER_SYMBOL_E}; - -// Reverse mapping between symbol id and topology pattern symbol. -constexpr EdgebreakerTopologyBitPattern edge_breaker_symbol_to_topology_id[] = { - TOPOLOGY_C, TOPOLOGY_S, TOPOLOGY_L, TOPOLOGY_R, TOPOLOGY_E}; - -// Types of edges used during mesh traversal relative to the tip vertex of a -// visited triangle. -enum EdgeFaceName : uint8_t { LEFT_FACE_EDGE = 0, RIGHT_FACE_EDGE = 1 }; - -// Struct used for storing data about a source face that connects to an -// already traversed face that was either the initial face or a face encoded -// with either topology S (split) symbol. Such connection can be only caused by -// topology changes on the traversed surface (if its genus != 0, i.e. when the -// surface has topological handles or holes). -// For each occurrence of such event we always encode the split symbol id, -// source symbol id and source edge id (left, or right). There will be always -// exactly two occurrences of this event for every topological handle on the -// traversed mesh and one occurrence for a hole. -struct TopologySplitEventData { - uint32_t split_symbol_id; - uint32_t source_symbol_id; - // We need to use uint32_t instead of EdgeFaceName because the most recent - // version of gcc does not allow that when optimizations are turned on. - uint32_t source_edge : 1; -}; - -// Hole event is used to store info about the first symbol that reached a -// vertex of so far unvisited hole. This can happen only on either the initial -// face or during a regular traversal when TOPOLOGY_S is encountered. -struct HoleEventData { - int32_t symbol_id; - HoleEventData() : symbol_id(0) {} - explicit HoleEventData(int32_t sym_id) : symbol_id(sym_id) {} -}; - -// List of supported modes for valence based edgebreaker coding. -enum EdgebreakerValenceCodingMode { - EDGEBREAKER_VALENCE_MODE_2_7 = 0, // Use contexts for valences in range 2-7. -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_SHARED_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h deleted file mode 100644 index 128d7f5..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_DECODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/bit_coders/rans_bit_decoder.h" -#include "draco/compression/mesh/mesh_edgebreaker_decoder.h" -#include "draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h" -#include "draco/compression/mesh/mesh_edgebreaker_shared.h" - -namespace draco { - -typedef RAnsBitDecoder BinaryDecoder; - -// Default implementation of the edgebreaker traversal decoder that reads the -// traversal data directly from a buffer. -class MeshEdgebreakerTraversalDecoder { - public: - MeshEdgebreakerTraversalDecoder() - : attribute_connectivity_decoders_(nullptr), - num_attribute_data_(0), - decoder_impl_(nullptr) {} - void Init(MeshEdgebreakerDecoderImplInterface *decoder) { - decoder_impl_ = decoder; - buffer_.Init(decoder->GetDecoder()->buffer()->data_head(), - decoder->GetDecoder()->buffer()->remaining_size(), - decoder->GetDecoder()->buffer()->bitstream_version()); - } - - // Returns the Draco bitstream version. - uint16_t BitstreamVersion() const { - return decoder_impl_->GetDecoder()->bitstream_version(); - } - - // Used to tell the decoder what is the number of expected decoded vertices. - // Ignored by default. - void SetNumEncodedVertices(int /* num_vertices */) {} - - // Set the number of non-position attribute data for which we need to decode - // the connectivity. - void SetNumAttributeData(int num_data) { num_attribute_data_ = num_data; } - - // Called before the traversal decoding is started. - // Returns a buffer decoder that points to data that was encoded after the - // traversal. - bool Start(DecoderBuffer *out_buffer) { - // Decode symbols from the main buffer decoder and face configurations from - // the start_face_buffer decoder. - if (!DecodeTraversalSymbols()) - return false; - - if (!DecodeStartFaces()) - return false; - - if (!DecodeAttributeSeams()) - return false; - *out_buffer = buffer_; - return true; - } - - // Returns the configuration of a new initial face. - inline bool DecodeStartFaceConfiguration() { - uint32_t face_configuration; -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer_.bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - start_face_buffer_.DecodeLeastSignificantBits32(1, &face_configuration); - - } else -#endif - { - face_configuration = start_face_decoder_.DecodeNextBit(); - } - return face_configuration; - } - - // Returns the next edgebreaker symbol that was reached during the traversal. - inline uint32_t DecodeSymbol() { - uint32_t symbol; - symbol_buffer_.DecodeLeastSignificantBits32(1, &symbol); - if (symbol == TOPOLOGY_C) { - return symbol; - } - // Else decode two additional bits. - uint32_t symbol_suffix; - symbol_buffer_.DecodeLeastSignificantBits32(2, &symbol_suffix); - symbol |= (symbol_suffix << 1); - return symbol; - } - - // Called whenever a new active corner is set in the decoder. - inline void NewActiveCornerReached(CornerIndex /* corner */) {} - - // Called whenever |source| vertex is about to be merged into the |dest| - // vertex. - inline void MergeVertices(VertexIndex /* dest */, VertexIndex /* source */) {} - - // Returns true if there is an attribute seam for the next processed pair - // of visited faces. - // |attribute| is used to mark the id of the non-position attribute (in range - // of <0, num_attributes - 1>). - inline bool DecodeAttributeSeam(int attribute) { - return attribute_connectivity_decoders_[attribute].DecodeNextBit(); - } - - // Called when the traversal is finished. - void Done() { - if (symbol_buffer_.bit_decoder_active()) - symbol_buffer_.EndBitDecoding(); -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer_.bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - start_face_buffer_.EndBitDecoding(); - - } else -#endif - { - start_face_decoder_.EndDecoding(); - } - } - - protected: - DecoderBuffer *buffer() { return &buffer_; } - - bool DecodeTraversalSymbols() { - uint64_t traversal_size; - symbol_buffer_ = buffer_; - if (!symbol_buffer_.StartBitDecoding(true, &traversal_size)) - return false; - buffer_ = symbol_buffer_; - if (traversal_size > static_cast(buffer_.remaining_size())) - return false; - buffer_.Advance(traversal_size); - return true; - } - - bool DecodeStartFaces() { - // Create a decoder that is set to the end of the encoded traversal data. -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (buffer_.bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) { - start_face_buffer_ = buffer_; - uint64_t traversal_size; - if (!start_face_buffer_.StartBitDecoding(true, &traversal_size)) - return false; - buffer_ = start_face_buffer_; - if (traversal_size > static_cast(buffer_.remaining_size())) - return false; - buffer_.Advance(traversal_size); - return true; - } -#endif - return start_face_decoder_.StartDecoding(&buffer_); - } - - bool DecodeAttributeSeams() { - // Prepare attribute decoding. - if (num_attribute_data_ > 0) { - attribute_connectivity_decoders_ = std::unique_ptr( - new BinaryDecoder[num_attribute_data_]); - for (int i = 0; i < num_attribute_data_; ++i) { - if (!attribute_connectivity_decoders_[i].StartDecoding(&buffer_)) - return false; - } - } - return true; - } - - private: - // Buffer that contains the encoded data. - DecoderBuffer buffer_; - DecoderBuffer symbol_buffer_; - BinaryDecoder start_face_decoder_; - DecoderBuffer start_face_buffer_; - std::unique_ptr attribute_connectivity_decoders_; - int num_attribute_data_; - const MeshEdgebreakerDecoderImplInterface *decoder_impl_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h deleted file mode 100644 index 08cb66e..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_ENCODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_ENCODER_H_ - -#include "draco/compression/bit_coders/rans_bit_encoder.h" -#include "draco/compression/mesh/mesh_edgebreaker_encoder.h" -#include "draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h" -#include "draco/core/macros.h" - -namespace draco { - -typedef RAnsBitEncoder BinaryEncoder; - -// Default implementation of the edgebreaker traversal encoder. Face -// configurations are stored directly into the output buffer and the symbols -// are first collected and then encoded in the reverse order to make the -// decoding faster. -class MeshEdgebreakerTraversalEncoder { - public: - MeshEdgebreakerTraversalEncoder() - : encoder_impl_(nullptr), - attribute_connectivity_encoders_(nullptr), - num_attribute_data_(0) {} - bool Init(MeshEdgebreakerEncoderImplInterface *encoder) { - encoder_impl_ = encoder; - return true; - } - - // Set the number of non-position attribute data for which we need to encode - // the connectivity. - void SetNumAttributeData(int num_data) { num_attribute_data_ = num_data; } - - // Called before the traversal encoding is started. - void Start() { - start_face_encoder_.StartEncoding(); - if (num_attribute_data_ > 0) { - // Init and start arithmetic encoders for storing configuration types - // of non-position attributes. - attribute_connectivity_encoders_ = std::unique_ptr( - new BinaryEncoder[num_attribute_data_]); - for (int i = 0; i < num_attribute_data_; ++i) { - attribute_connectivity_encoders_[i].StartEncoding(); - } - } - } - - // Called when a traversal starts from a new initial face. - inline void EncodeStartFaceConfiguration(bool interior) { - start_face_encoder_.EncodeBit(interior); - } - - // Called when a new corner is reached during the traversal. No-op for the - // default encoder. - inline void NewCornerReached(CornerIndex /* corner */) {} - - // Called whenever a new symbol is reached during the edgebreaker traversal. - inline void EncodeSymbol(EdgebreakerTopologyBitPattern symbol) { - // Store the symbol. It will be encoded after all symbols are processed. - symbols_.push_back(symbol); - } - - // Called for every pair of connected and visited faces. |is_seam| specifies - // whether there is an attribute seam between the two faces. - - inline void EncodeAttributeSeam(int attribute, bool is_seam) { - attribute_connectivity_encoders_[attribute].EncodeBit(is_seam ? 1 : 0); - } - - // Called when the traversal is finished. - void Done() { - EncodeTraversalSymbols(); - EncodeStartFaces(); - EncodeAttributeSeams(); - } - - // Returns the number of encoded symbols. - int NumEncodedSymbols() const { return static_cast(symbols_.size()); } - - const EncoderBuffer &buffer() const { return traversal_buffer_; } - - protected: - void EncodeTraversalSymbols() { - // Bit encode the collected symbols. - // Allocate enough storage for the bit encoder. - // It's guaranteed that each face will need only up to 3 bits. - traversal_buffer_.StartBitEncoding( - encoder_impl_->GetEncoder()->mesh()->num_faces() * 3, true); - for (int i = static_cast(symbols_.size() - 1); i >= 0; --i) { - traversal_buffer_.EncodeLeastSignificantBits32( - edge_breaker_topology_bit_pattern_length[symbols_[i]], symbols_[i]); - } - traversal_buffer_.EndBitEncoding(); - } - - void EncodeStartFaces() { - start_face_encoder_.EndEncoding(&traversal_buffer_); - } - - void EncodeAttributeSeams() { - if (attribute_connectivity_encoders_ != nullptr) { - for (int i = 0; i < num_attribute_data_; ++i) { - attribute_connectivity_encoders_[i].EndEncoding(&traversal_buffer_); - } - } - } - - EncoderBuffer *GetOutputBuffer() { return &traversal_buffer_; } - const MeshEdgebreakerEncoderImplInterface *encoder_impl() const { - return encoder_impl_; - } - - private: - BinaryEncoder start_face_encoder_; - EncoderBuffer traversal_buffer_; - const MeshEdgebreakerEncoderImplInterface *encoder_impl_; - // Symbols collected during the traversal. - std::vector symbols_; - // Arithmetic encoder for encoding attribute seams. - // One context for each non-position attribute. - std::unique_ptr attribute_connectivity_encoders_; - int num_attribute_data_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h deleted file mode 100644 index d3289e2..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_DECODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h" - -namespace draco { - -// Decoder for traversal encoded with the -// MeshEdgebreakerTraversalPredictiveEncoder. The decoder maintains valences -// of the decoded portion of the traversed mesh and it uses them to predict -// symbols that are about to be decoded. -class MeshEdgebreakerTraversalPredictiveDecoder - : public MeshEdgebreakerTraversalDecoder { - public: - MeshEdgebreakerTraversalPredictiveDecoder() - : corner_table_(nullptr), - num_vertices_(0), - last_symbol_(-1), - predicted_symbol_(-1) {} - void Init(MeshEdgebreakerDecoderImplInterface *decoder) { - MeshEdgebreakerTraversalDecoder::Init(decoder); - corner_table_ = decoder->GetCornerTable(); - } - void SetNumEncodedVertices(int num_vertices) { num_vertices_ = num_vertices; } - - bool Start(DecoderBuffer *out_buffer) { - if (!MeshEdgebreakerTraversalDecoder::Start(out_buffer)) - return false; - int32_t num_split_symbols; - if (!out_buffer->Decode(&num_split_symbols) || num_split_symbols < 0) - return false; - if (num_split_symbols >= num_vertices_) - return false; - // Set the valences of all initial vertices to 0. - vertex_valences_.resize(num_vertices_, 0); - if (!prediction_decoder_.StartDecoding(out_buffer)) - return false; - return true; - } - - inline uint32_t DecodeSymbol() { - // First check if we have a predicted symbol. - if (predicted_symbol_ != -1) { - // Double check that the predicted symbol was predicted correctly. - if (prediction_decoder_.DecodeNextBit()) { - last_symbol_ = predicted_symbol_; - return predicted_symbol_; - } - } - // We don't have a predicted symbol or the symbol was mis-predicted. - // Decode it directly. - last_symbol_ = MeshEdgebreakerTraversalDecoder::DecodeSymbol(); - return last_symbol_; - } - - inline void NewActiveCornerReached(CornerIndex corner) { - const CornerIndex next = corner_table_->Next(corner); - const CornerIndex prev = corner_table_->Previous(corner); - // Update valences. - switch (last_symbol_) { - case TOPOLOGY_C: - case TOPOLOGY_S: - vertex_valences_[corner_table_->Vertex(next).value()] += 1; - vertex_valences_[corner_table_->Vertex(prev).value()] += 1; - break; - case TOPOLOGY_R: - vertex_valences_[corner_table_->Vertex(corner).value()] += 1; - vertex_valences_[corner_table_->Vertex(next).value()] += 1; - vertex_valences_[corner_table_->Vertex(prev).value()] += 2; - break; - case TOPOLOGY_L: - vertex_valences_[corner_table_->Vertex(corner).value()] += 1; - vertex_valences_[corner_table_->Vertex(next).value()] += 2; - vertex_valences_[corner_table_->Vertex(prev).value()] += 1; - break; - case TOPOLOGY_E: - vertex_valences_[corner_table_->Vertex(corner).value()] += 2; - vertex_valences_[corner_table_->Vertex(next).value()] += 2; - vertex_valences_[corner_table_->Vertex(prev).value()] += 2; - break; - default: - break; - } - // Compute the new predicted symbol. - if (last_symbol_ == TOPOLOGY_C || last_symbol_ == TOPOLOGY_R) { - const VertexIndex pivot = - corner_table_->Vertex(corner_table_->Next(corner)); - if (vertex_valences_[pivot.value()] < 6) { - predicted_symbol_ = TOPOLOGY_R; - } else { - predicted_symbol_ = TOPOLOGY_C; - } - } else { - predicted_symbol_ = -1; - } - } - - inline void MergeVertices(VertexIndex dest, VertexIndex source) { - // Update valences on the merged vertices. - vertex_valences_[dest.value()] += vertex_valences_[source.value()]; - } - - private: - const CornerTable *corner_table_; - int num_vertices_; - std::vector vertex_valences_; - BinaryDecoder prediction_decoder_; - int last_symbol_; - int predicted_symbol_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_DECODER_H_ -#endif diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h deleted file mode 100644 index 118687c..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_ENCODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_ENCODER_H_ - -#include "draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h" - -namespace draco { - -// Encoder that tries to predict the edgebreaker traversal symbols based on the -// vertex valences of the unencoded portion of the mesh. The current prediction -// scheme assumes that each vertex has valence 6 which can be used to predict -// the symbol preceding the one that is currently encoded. Predictions are -// encoded using an arithmetic coding which can lead to less than 1 bit per -// triangle encoding for highly regular meshes. -class MeshEdgebreakerTraversalPredictiveEncoder - : public MeshEdgebreakerTraversalEncoder { - public: - MeshEdgebreakerTraversalPredictiveEncoder() - : corner_table_(nullptr), - prev_symbol_(-1), - num_split_symbols_(0), - last_corner_(kInvalidCornerIndex), - num_symbols_(0) {} - - bool Init(MeshEdgebreakerEncoderImplInterface *encoder) { - if (!MeshEdgebreakerTraversalEncoder::Init(encoder)) - return false; - corner_table_ = encoder->GetCornerTable(); - // Initialize valences of all vertices. - vertex_valences_.resize(corner_table_->num_vertices()); - for (uint32_t i = 0; i < vertex_valences_.size(); ++i) { - vertex_valences_[i] = corner_table_->Valence(VertexIndex(i)); - } - return true; - } - - inline void NewCornerReached(CornerIndex corner) { last_corner_ = corner; } - - inline int32_t ComputePredictedSymbol(VertexIndex pivot) { - const int valence = vertex_valences_[pivot.value()]; - if (valence < 0) { - // This situation can happen only for split vertices. Returning - // TOPOLOGY_INVALID always cases misprediction. - return TOPOLOGY_INVALID; - } - if (valence < 6) { - return TOPOLOGY_R; - } - return TOPOLOGY_C; - } - - inline void EncodeSymbol(EdgebreakerTopologyBitPattern symbol) { - ++num_symbols_; - // Update valences on the mesh. And compute the predicted preceding symbol. - // Note that the valences are computed for the so far unencoded part of the - // mesh. Adding a new symbol either reduces valences on the vertices or - // leaves the valence unchanged. - int32_t predicted_symbol = -1; - const CornerIndex next = corner_table_->Next(last_corner_); - const CornerIndex prev = corner_table_->Previous(last_corner_); - switch (symbol) { - case TOPOLOGY_C: - // Compute prediction. - predicted_symbol = ComputePredictedSymbol(corner_table_->Vertex(next)); - FALLTHROUGH_INTENDED; - case TOPOLOGY_S: - // Update valences. - vertex_valences_[corner_table_->Vertex(next).value()] -= 1; - vertex_valences_[corner_table_->Vertex(prev).value()] -= 1; - if (symbol == TOPOLOGY_S) { - // Whenever we reach a split symbol, mark its tip vertex as invalid by - // setting the valence to a negative value. Any prediction that will - // use this vertex will then cause a misprediction. This is currently - // necessary because the decoding works in the reverse direction and - // the decoder doesn't know about these vertices until the split - // symbol is decoded at which point two vertices are merged into one. - // This can be most likely solved on the encoder side by splitting the - // tip vertex into two, but since split symbols are relatively rare, - // it's probably not worth doing it. - vertex_valences_[corner_table_->Vertex(last_corner_).value()] = -1; - ++num_split_symbols_; - } - break; - case TOPOLOGY_R: - // Compute prediction. - predicted_symbol = ComputePredictedSymbol(corner_table_->Vertex(next)); - // Update valences. - vertex_valences_[corner_table_->Vertex(last_corner_).value()] -= 1; - vertex_valences_[corner_table_->Vertex(next).value()] -= 1; - vertex_valences_[corner_table_->Vertex(prev).value()] -= 2; - break; - case TOPOLOGY_L: - vertex_valences_[corner_table_->Vertex(last_corner_).value()] -= 1; - vertex_valences_[corner_table_->Vertex(next).value()] -= 2; - vertex_valences_[corner_table_->Vertex(prev).value()] -= 1; - break; - case TOPOLOGY_E: - vertex_valences_[corner_table_->Vertex(last_corner_).value()] -= 2; - vertex_valences_[corner_table_->Vertex(next).value()] -= 2; - vertex_valences_[corner_table_->Vertex(prev).value()] -= 2; - break; - default: - break; - } - // Flag used when it's necessary to explicitly store the previous symbol. - bool store_prev_symbol = true; - if (predicted_symbol != -1) { - if (predicted_symbol == prev_symbol_) { - predictions_.push_back(true); - store_prev_symbol = false; - } else if (prev_symbol_ != -1) { - predictions_.push_back(false); - } - } - if (store_prev_symbol && prev_symbol_ != -1) { - MeshEdgebreakerTraversalEncoder::EncodeSymbol( - static_cast(prev_symbol_)); - } - prev_symbol_ = symbol; - } - - void Done() { - // We still need to store the last encoded symbol. - if (prev_symbol_ != -1) { - MeshEdgebreakerTraversalEncoder::EncodeSymbol( - static_cast(prev_symbol_)); - } - // Store the init face configurations and the explicitly encoded symbols. - MeshEdgebreakerTraversalEncoder::Done(); - // Encode the number of split symbols. - GetOutputBuffer()->Encode(num_split_symbols_); - // Store the predictions. - BinaryEncoder prediction_encoder; - prediction_encoder.StartEncoding(); - for (int i = static_cast(predictions_.size()) - 1; i >= 0; --i) { - prediction_encoder.EncodeBit(predictions_[i]); - } - prediction_encoder.EndEncoding(GetOutputBuffer()); - } - - int NumEncodedSymbols() const { return num_symbols_; } - - private: - const CornerTable *corner_table_; - std::vector vertex_valences_; - std::vector predictions_; - // Previously encoded symbol. - int32_t prev_symbol_; - // The total number of encoded split symbols. - int32_t num_split_symbols_; - CornerIndex last_corner_; - // Explicitly count the number of encoded symbols. - int num_symbols_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_PREDICTIVE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h deleted file mode 100644 index 4da9d0e..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ - -#include "draco/draco_features.h" - -#include "draco/compression/entropy/symbol_decoding.h" -#include "draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h" -#include "draco/core/varint_decoding.h" - -namespace draco { - -// Decoder for traversal encoded with MeshEdgebreakerTraversalValenceEncoder. -// The decoder maintains valences of the decoded portion of the traversed mesh -// and it uses them to select entropy context used for decoding of the actual -// symbols. -class MeshEdgebreakerTraversalValenceDecoder - : public MeshEdgebreakerTraversalDecoder { - public: - MeshEdgebreakerTraversalValenceDecoder() - : corner_table_(nullptr), - num_vertices_(0), - last_symbol_(-1), - active_context_(-1), - min_valence_(2), - max_valence_(7) {} - void Init(MeshEdgebreakerDecoderImplInterface *decoder) { - MeshEdgebreakerTraversalDecoder::Init(decoder); - corner_table_ = decoder->GetCornerTable(); - } - void SetNumEncodedVertices(int num_vertices) { num_vertices_ = num_vertices; } - - bool Start(DecoderBuffer *out_buffer) { -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { - if (!MeshEdgebreakerTraversalDecoder::DecodeTraversalSymbols()) - return false; - } -#endif - if (!MeshEdgebreakerTraversalDecoder::DecodeStartFaces()) - return false; - if (!MeshEdgebreakerTraversalDecoder::DecodeAttributeSeams()) - return false; - *out_buffer = *buffer(); - -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { - uint32_t num_split_symbols; - if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 0)) { - if (!out_buffer->Decode(&num_split_symbols)) - return false; - } else { - if (!DecodeVarint(&num_split_symbols, out_buffer)) - return false; - } - if (num_split_symbols >= static_cast(num_vertices_)) - return false; - - int8_t mode; - if (!out_buffer->Decode(&mode)) - return false; - if (mode == EDGEBREAKER_VALENCE_MODE_2_7) { - min_valence_ = 2; - max_valence_ = 7; - } else { - // Unsupported mode. - return false; - } - - } else -#endif - { - min_valence_ = 2; - max_valence_ = 7; - } - - if (num_vertices_ < 0) - return false; - // Set the valences of all initial vertices to 0. - vertex_valences_.resize(num_vertices_, 0); - - const int num_unique_valences = max_valence_ - min_valence_ + 1; - - // Decode all symbols for all contexts. - context_symbols_.resize(num_unique_valences); - context_counters_.resize(context_symbols_.size()); - for (int i = 0; i < context_symbols_.size(); ++i) { - uint32_t num_symbols; - DecodeVarint(&num_symbols, out_buffer); - if (num_symbols > 0) { - context_symbols_[i].resize(num_symbols); - DecodeSymbols(num_symbols, 1, out_buffer, context_symbols_[i].data()); - // All symbols are going to be processed from the back. - context_counters_[i] = num_symbols; - } - } - return true; - } - - inline uint32_t DecodeSymbol() { - // First check if we have a valid context. - if (active_context_ != -1) { - const int context_counter = --context_counters_[active_context_]; - if (context_counter < 0) - return TOPOLOGY_INVALID; - const int symbol_id = context_symbols_[active_context_][context_counter]; - last_symbol_ = edge_breaker_symbol_to_topology_id[symbol_id]; - } else { -#ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED - if (BitstreamVersion() < DRACO_BITSTREAM_VERSION(2, 2)) { - // We don't have a predicted symbol or the symbol was mis-predicted. - // Decode it directly. - last_symbol_ = MeshEdgebreakerTraversalDecoder::DecodeSymbol(); - - } else -#endif - { - // The first symbol must be E. - last_symbol_ = TOPOLOGY_E; - } - } - return last_symbol_; - } - - inline void NewActiveCornerReached(CornerIndex corner) { - const CornerIndex next = corner_table_->Next(corner); - const CornerIndex prev = corner_table_->Previous(corner); - // Update valences. - switch (last_symbol_) { - case TOPOLOGY_C: - case TOPOLOGY_S: - vertex_valences_[corner_table_->Vertex(next)] += 1; - vertex_valences_[corner_table_->Vertex(prev)] += 1; - break; - case TOPOLOGY_R: - vertex_valences_[corner_table_->Vertex(corner)] += 1; - vertex_valences_[corner_table_->Vertex(next)] += 1; - vertex_valences_[corner_table_->Vertex(prev)] += 2; - break; - case TOPOLOGY_L: - vertex_valences_[corner_table_->Vertex(corner)] += 1; - vertex_valences_[corner_table_->Vertex(next)] += 2; - vertex_valences_[corner_table_->Vertex(prev)] += 1; - break; - case TOPOLOGY_E: - vertex_valences_[corner_table_->Vertex(corner)] += 2; - vertex_valences_[corner_table_->Vertex(next)] += 2; - vertex_valences_[corner_table_->Vertex(prev)] += 2; - break; - default: - break; - } - // Compute the new context that is going to be used to decode the next - // symbol. - const int active_valence = vertex_valences_[corner_table_->Vertex(next)]; - int clamped_valence; - if (active_valence < min_valence_) { - clamped_valence = min_valence_; - } else if (active_valence > max_valence_) { - clamped_valence = max_valence_; - } else { - clamped_valence = active_valence; - } - - active_context_ = (clamped_valence - min_valence_); - } - - inline void MergeVertices(VertexIndex dest, VertexIndex source) { - // Update valences on the merged vertices. - vertex_valences_[dest] += vertex_valences_[source]; - } - - private: - const CornerTable *corner_table_; - int num_vertices_; - IndexTypeVector vertex_valences_; - int last_symbol_; - int active_context_; - - int min_valence_; - int max_valence_; - std::vector> context_symbols_; - // Points to the active symbol in each context. - std::vector context_counters_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h deleted file mode 100644 index ef3a86b..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_ENCODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_ENCODER_H_ - -#include "draco/compression/entropy/symbol_encoding.h" -#include "draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h" -#include "draco/core/varint_encoding.h" - -namespace draco { - -// Predictive encoder for the Edgebreaker symbols based on valences of the -// previously encoded vertices, following the method described in: Szymczak'02, -// "Optimized Edgebreaker Encoding for Large and Regular Triangle Meshes". Each -// valence is used to specify a different entropy context for encoding of the -// symbols. -// Encoder can operate in various predefined modes that can be used to select -// the way in which the entropy contexts are computed (e.g. using different -// clamping for valences, or even using different inputs to compute the -// contexts), see EdgebreakerValenceCodingMode in mesh_edgebreaker_shared.h for -// a list of supported modes. -class MeshEdgebreakerTraversalValenceEncoder - : public MeshEdgebreakerTraversalEncoder { - public: - MeshEdgebreakerTraversalValenceEncoder() - : corner_table_(nullptr), - prev_symbol_(-1), - last_corner_(kInvalidCornerIndex), - num_symbols_(0), - min_valence_(2), - max_valence_(7) {} - - bool Init(MeshEdgebreakerEncoderImplInterface *encoder) { - if (!MeshEdgebreakerTraversalEncoder::Init(encoder)) - return false; - min_valence_ = 2; - max_valence_ = 7; - corner_table_ = encoder->GetCornerTable(); - - // Initialize valences of all vertices. - vertex_valences_.resize(corner_table_->num_vertices()); - for (VertexIndex i(0); i < static_cast(vertex_valences_.size()); - ++i) { - vertex_valences_[i] = corner_table_->Valence(VertexIndex(i)); - } - - // Replicate the corner to vertex map from the corner table. We need to do - // this because the map may get updated during encoding because we add new - // vertices when we encounter split symbols. - corner_to_vertex_map_.resize(corner_table_->num_corners()); - for (CornerIndex i(0); i < corner_table_->num_corners(); ++i) { - corner_to_vertex_map_[i] = corner_table_->Vertex(i); - } - const int32_t num_unique_valences = max_valence_ - min_valence_ + 1; - - context_symbols_.resize(num_unique_valences); - return true; - } - - inline void NewCornerReached(CornerIndex corner) { last_corner_ = corner; } - - inline void EncodeSymbol(EdgebreakerTopologyBitPattern symbol) { - ++num_symbols_; - // Update valences on the mesh and compute the context that is going to be - // used to encode the processed symbol. - // Note that the valences are computed for the so far unencoded part of the - // mesh (i.e. the decoding is reverse). Adding a new symbol either reduces - // valences on the vertices or leaves the valence unchanged. - - const CornerIndex next = corner_table_->Next(last_corner_); - const CornerIndex prev = corner_table_->Previous(last_corner_); - - // Get valence on the tip corner of the active edge (outgoing edge that is - // going to be used in reverse decoding of the connectivity to predict the - // next symbol). - const int active_valence = vertex_valences_[corner_to_vertex_map_[next]]; - switch (symbol) { - case TOPOLOGY_C: - // Compute prediction. - FALLTHROUGH_INTENDED; - case TOPOLOGY_S: - // Update valences. - vertex_valences_[corner_to_vertex_map_[next]] -= 1; - vertex_valences_[corner_to_vertex_map_[prev]] -= 1; - if (symbol == TOPOLOGY_S) { - // Whenever we reach a split symbol, we need to split the vertex into - // two and attach all corners on the left and right sides of the split - // vertex to the respective vertices (see image below). This is - // necessary since the decoder works in the reverse order and it - // merges the two vertices only after the split symbol is processed. - // - // * ----- - // / \-------- - // / \-------- - // / \------- - // *-------v-------* - // \ /c\ / - // \ / \ / - // \ /n S p\ / - // *.......* - // - - // Count the number of faces on the left side of the split vertex and - // update the valence on the "left vertex". - int num_left_faces = 0; - CornerIndex act_c = corner_table_->Opposite(prev); - while (act_c != kInvalidCornerIndex) { - if (encoder_impl()->IsFaceEncoded(corner_table_->Face(act_c))) - break; // Stop when we reach the first visited face. - ++num_left_faces; - act_c = corner_table_->Opposite(corner_table_->Next(act_c)); - } - vertex_valences_[corner_to_vertex_map_[last_corner_]] = - num_left_faces + 1; - - // Create a new vertex for the right side and count the number of - // faces that should be attached to this vertex. - const int new_vert_id = static_cast(vertex_valences_.size()); - int num_right_faces = 0; - - act_c = corner_table_->Opposite(next); - while (act_c != kInvalidCornerIndex) { - if (encoder_impl()->IsFaceEncoded(corner_table_->Face(act_c))) - break; // Stop when we reach the first visited face. - ++num_right_faces; - // Map corners on the right side to the newly created vertex. - corner_to_vertex_map_[corner_table_->Next(act_c)] = new_vert_id; - act_c = corner_table_->Opposite(corner_table_->Previous(act_c)); - } - vertex_valences_.push_back(num_right_faces + 1); - } - break; - case TOPOLOGY_R: - // Update valences. - vertex_valences_[corner_to_vertex_map_[last_corner_]] -= 1; - vertex_valences_[corner_to_vertex_map_[next]] -= 1; - vertex_valences_[corner_to_vertex_map_[prev]] -= 2; - break; - case TOPOLOGY_L: - - vertex_valences_[corner_to_vertex_map_[last_corner_]] -= 1; - vertex_valences_[corner_to_vertex_map_[next]] -= 2; - vertex_valences_[corner_to_vertex_map_[prev]] -= 1; - break; - case TOPOLOGY_E: - vertex_valences_[corner_to_vertex_map_[last_corner_]] -= 2; - vertex_valences_[corner_to_vertex_map_[next]] -= 2; - vertex_valences_[corner_to_vertex_map_[prev]] -= 2; - break; - default: - break; - } - - if (prev_symbol_ != -1) { - int clamped_valence; - if (active_valence < min_valence_) { - clamped_valence = min_valence_; - } else if (active_valence > max_valence_) { - clamped_valence = max_valence_; - } else { - clamped_valence = active_valence; - } - - const int context = clamped_valence - min_valence_; - context_symbols_[context].push_back( - edge_breaker_topology_to_symbol_id[prev_symbol_]); - } - - prev_symbol_ = symbol; - } - - void Done() { - // Store the init face configurations and attribute seam data - MeshEdgebreakerTraversalEncoder::EncodeStartFaces(); - MeshEdgebreakerTraversalEncoder::EncodeAttributeSeams(); - - // Store the contexts. - for (int i = 0; i < context_symbols_.size(); ++i) { - EncodeVarint(static_cast(context_symbols_[i].size()), - GetOutputBuffer()); - if (context_symbols_[i].size() > 0) { - EncodeSymbols(context_symbols_[i].data(), - static_cast(context_symbols_[i].size()), 1, nullptr, - GetOutputBuffer()); - } - } - } - - int NumEncodedSymbols() const { return num_symbols_; } - - private: - const CornerTable *corner_table_; - // Explicit map between corners and vertices. We cannot use the one stored - // in the |corner_table_| because we may need to add additional vertices to - // handle split symbols. - IndexTypeVector corner_to_vertex_map_; - IndexTypeVector vertex_valences_; - // Previously encoded symbol. - int32_t prev_symbol_; - CornerIndex last_corner_; - // Explicitly count the number of encoded symbols. - int num_symbols_; - - int min_valence_; - int max_valence_; - std::vector> context_symbols_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_EDGEBREAKER_TRAVERSAL_VALENCE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_encoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_encoder.h deleted file mode 100644 index 30ec4fa..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_encoder.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_ENCODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_ENCODER_H_ - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/point_cloud/point_cloud_encoder.h" -#include "draco/mesh/mesh.h" -#include "draco/mesh/mesh_attribute_corner_table.h" - -namespace draco { - -// Abstract base class for all mesh encoders. It provides some basic -// functionality that's shared between different encoders. -class MeshEncoder : public PointCloudEncoder { - public: - MeshEncoder(); - - // Sets the mesh that is going be encoded. Must be called before the Encode() - // method. - void SetMesh(const Mesh &m); - - EncodedGeometryType GetGeometryType() const override { - return TRIANGULAR_MESH; - } - - // Returns the number of faces that were encoded during the last Encode(). - // function call. Valid only if "store_number_of_encoded_faces" flag was set - // in the provided EncoderOptions. - size_t num_encoded_faces() const { return num_encoded_faces_; } - - // Returns the base connectivity of the encoded mesh (or nullptr if it is not - // initialized). - virtual const CornerTable *GetCornerTable() const { return nullptr; } - - // Returns the attribute connectivity data or nullptr if it does not exist. - virtual const MeshAttributeCornerTable *GetAttributeCornerTable( - int /* att_id */) const { - return nullptr; - } - - // Returns the encoding data for a given attribute or nullptr when the data - // does not exist. - virtual const MeshAttributeIndicesEncodingData *GetAttributeEncodingData( - int /* att_id */) const { - return nullptr; - } - - const Mesh *mesh() const { return mesh_; } - - protected: - Status EncodeGeometryData() override; - - // Needs to be implemented by the derived classes. - virtual Status EncodeConnectivity() = 0; - - // Computes and sets the num_encoded_faces_ for the encoder. - virtual void ComputeNumberOfEncodedFaces() = 0; - - void set_mesh(const Mesh *mesh) { mesh_ = mesh; } - void set_num_encoded_faces(size_t num_faces) { - num_encoded_faces_ = num_faces; - } - - private: - const Mesh *mesh_; - size_t num_encoded_faces_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_encoder_helpers.h b/cloudreg_env/include/draco/compression/mesh/mesh_encoder_helpers.h deleted file mode 100644 index d809a52..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_encoder_helpers.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_ENCODER_HELPERS_H_ -#define DRACO_COMPRESSION_MESH_MESH_ENCODER_HELPERS_H_ - -#include "draco/compression/mesh/mesh_encoder.h" -#include "draco/mesh/triangle_soup_mesh_builder.h" - -namespace draco { - -// Helper class for encoding data supplied in a stream of single precision -// floating point numbers formatted as XYZ|UV. The stream must contain three -// XYZ|UV values for every face of the mesh. -// The encoded data is written into the output stream "os". -// In case of error, the stream is set to an invalid state (ios_base::bad_bit). -template -OStreamT EncodePos3Tex2DataToStream( - const float *data, int num_faces, CompressionMethod method, - const MeshCompressionOptions &compression_options, - const MeshAttributeCompressionOptions &pos_options, - const MeshAttributeCompressionOptions &tex_options, OStreamT &&os) { - // Build the mesh. - TriangleSoupMeshBuilder mb; - mb.Start(num_faces); - const int pos_att_id = - mb.AddAttribute(GeometryAttribute::POSITION, 3, DT_FLOAT32); - const int tex_att_id = - mb.AddAttribute(GeometryAttribute::TEX_COORD_0, 2, DT_FLOAT32); - constexpr int data_stride = 5; - constexpr int tex_offset = 3; - for (int f = 0; f < num_faces; ++f) { - int offset = 3 * f * data_stride; - // Add position data for the face. - mb.SetAttributeValuesForFace(pos_att_id, f, data + offset, - data + offset + data_stride, - data + offset + 2 * data_stride); - // Add texture data for the face. - offset += tex_offset; - mb.SetAttributeValuesForFace(tex_att_id, f, data + offset, - data + offset + data_stride, - data + offset + 2 * data_stride); - } - std::unique_ptr mesh = mb.Finalize(); - if (mesh == nullptr) { - os.setstate(ios_base::badbit); - return os; - } - - // Set up the encoder. - std::unique_ptr encoder = - MeshEncoder::CreateEncoderForMethod(method); - encoder->SetGlobalOptions(compression_options); - encoder->SetAttributeOptions(GeometryAttribute::POSITION, pos_options); - encoder->SetAttributeOptions(GeometryAttribute::TEX_COORD_0, tex_options); - - if (!encoder->EncodeMesh(mesh.get())) { - os.setstate(ios_base::badbit); - return os; - } - - // Write the encoded data into the stream. - os.write(static_cast(encoder->buffer()->data()), - encoder->buffer()->size()); - return os; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_ENCODER_HELPERS_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_sequential_decoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_sequential_decoder.h deleted file mode 100644 index 3a86c75..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_sequential_decoder.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_MESH_SEQUENTIAL_DECODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_SEQUENTIAL_DECODER_H_ - -#include "draco/compression/mesh/mesh_decoder.h" - -namespace draco { - -// Class for decoding data encoded by MeshSequentialEncoder. -class MeshSequentialDecoder : public MeshDecoder { - public: - MeshSequentialDecoder(); - - protected: - bool DecodeConnectivity() override; - bool CreateAttributesDecoder(int32_t att_decoder_id) override; - - private: - // Decodes face indices that were compressed with an entropy code. - // Returns false on error. - bool DecodeAndDecompressIndices(uint32_t num_faces); -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_SEQUENTIAL_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/mesh_sequential_encoder.h b/cloudreg_env/include/draco/compression/mesh/mesh_sequential_encoder.h deleted file mode 100644 index 6726096..0000000 --- a/cloudreg_env/include/draco/compression/mesh/mesh_sequential_encoder.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// The encoder compresses all attribute values using an order preserving -// attribute encoder (that can still support quantization, prediction schemes, -// and other features). -// The mesh connectivity data can be encoded using two modes that are controlled -// using a global encoder options flag called "compress_connectivity" -// 1. When "compress_connectivity" == true: -// All point ids are first delta coded and then compressed using an entropy -// coding. -// 2. When "compress_connectivity" == false: -// All point ids are encoded directly using either 8, 16, or 32 bits per -// value based on the maximum point id value. - -#ifndef DRACO_COMPRESSION_MESH_MESH_SEQUENTIAL_ENCODER_H_ -#define DRACO_COMPRESSION_MESH_MESH_SEQUENTIAL_ENCODER_H_ - -#include "draco/compression/mesh/mesh_encoder.h" - -namespace draco { - -// Class that encodes mesh data using a simple binary representation of mesh's -// connectivity and geometry. -// TODO(ostava): Use a better name. -class MeshSequentialEncoder : public MeshEncoder { - public: - MeshSequentialEncoder(); - uint8_t GetEncodingMethod() const override { - return MESH_SEQUENTIAL_ENCODING; - } - - protected: - Status EncodeConnectivity() override; - bool GenerateAttributesEncoder(int32_t att_id) override; - void ComputeNumberOfEncodedPoints() override; - void ComputeNumberOfEncodedFaces() override; - - private: - // Returns false on error. - bool CompressAndEncodeIndices(); -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_MESH_SEQUENTIAL_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/traverser/depth_first_traverser.h b/cloudreg_env/include/draco/compression/mesh/traverser/depth_first_traverser.h deleted file mode 100644 index 84420cb..0000000 --- a/cloudreg_env/include/draco/compression/mesh/traverser/depth_first_traverser.h +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_TRAVERSER_DEPTH_FIRST_TRAVERSER_H_ -#define DRACO_COMPRESSION_MESH_TRAVERSER_DEPTH_FIRST_TRAVERSER_H_ - -#include - -#include "draco/compression/mesh/traverser/traverser_base.h" -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Basic traverser that traverses a mesh in a DFS like fashion using the -// CornerTable data structure. The necessary bookkeeping is available via the -// TraverserBase. Callbacks are handled through template argument -// TraversalObserverT. -// -// TraversalObserverT can perform an action on a traversal event such as newly -// visited face, or corner, but it does not affect the traversal itself. -// -// Concept TraversalObserverT requires: -// -// public: -// void OnNewFaceVisited(FaceIndex face); -// - Called whenever a previously unvisited face is reached. -// -// void OnNewVertexVisited(VertexIndex vert, CornerIndex corner) -// - Called when a new vertex is visited. |corner| is used to indicate the -// which of the vertex's corners has been reached. - -template -class DepthFirstTraverser - : public TraverserBase { - public: - typedef CornerTableT CornerTable; - typedef TraversalObserverT TraversalObserver; - typedef TraverserBase Base; - - DepthFirstTraverser() {} - - // Called before any traversing starts. - void OnTraversalStart() {} - - // Called when all the traversing is done. - void OnTraversalEnd() {} - - bool TraverseFromCorner(CornerIndex corner_id) { - if (this->IsFaceVisited(corner_id)) - return true; // Already traversed. - - corner_traversal_stack_.clear(); - corner_traversal_stack_.push_back(corner_id); - // For the first face, check the remaining corners as they may not be - // processed yet. - const VertexIndex next_vert = - this->corner_table()->Vertex(this->corner_table()->Next(corner_id)); - const VertexIndex prev_vert = - this->corner_table()->Vertex(this->corner_table()->Previous(corner_id)); - if (next_vert == kInvalidVertexIndex || prev_vert == kInvalidVertexIndex) - return false; - if (!this->IsVertexVisited(next_vert)) { - this->MarkVertexVisited(next_vert); - this->traversal_observer().OnNewVertexVisited( - next_vert, this->corner_table()->Next(corner_id)); - } - if (!this->IsVertexVisited(prev_vert)) { - this->MarkVertexVisited(prev_vert); - this->traversal_observer().OnNewVertexVisited( - prev_vert, this->corner_table()->Previous(corner_id)); - } - - // Start the actual traversal. - while (!corner_traversal_stack_.empty()) { - // Currently processed corner. - corner_id = corner_traversal_stack_.back(); - FaceIndex face_id(corner_id.value() / 3); - // Make sure the face hasn't been visited yet. - if (corner_id == kInvalidCornerIndex || this->IsFaceVisited(face_id)) { - // This face has been already traversed. - corner_traversal_stack_.pop_back(); - continue; - } - while (true) { - this->MarkFaceVisited(face_id); - this->traversal_observer().OnNewFaceVisited(face_id); - const VertexIndex vert_id = this->corner_table()->Vertex(corner_id); - if (vert_id == kInvalidVertexIndex) - return false; - if (!this->IsVertexVisited(vert_id)) { - const bool on_boundary = this->corner_table()->IsOnBoundary(vert_id); - this->MarkVertexVisited(vert_id); - this->traversal_observer().OnNewVertexVisited(vert_id, corner_id); - if (!on_boundary) { - corner_id = this->corner_table()->GetRightCorner(corner_id); - face_id = FaceIndex(corner_id.value() / 3); - continue; - } - } - // The current vertex has been already visited or it was on a boundary. - // We need to determine whether we can visit any of it's neighboring - // faces. - const CornerIndex right_corner_id = - this->corner_table()->GetRightCorner(corner_id); - const CornerIndex left_corner_id = - this->corner_table()->GetLeftCorner(corner_id); - const FaceIndex right_face_id( - (right_corner_id == kInvalidCornerIndex - ? kInvalidFaceIndex - : FaceIndex(right_corner_id.value() / 3))); - const FaceIndex left_face_id( - (left_corner_id == kInvalidCornerIndex - ? kInvalidFaceIndex - : FaceIndex(left_corner_id.value() / 3))); - if (this->IsFaceVisited(right_face_id)) { - // Right face has been already visited. - if (this->IsFaceVisited(left_face_id)) { - // Both neighboring faces are visited. End reached. - corner_traversal_stack_.pop_back(); - break; // Break from the while (true) loop. - } else { - // Go to the left face. - corner_id = left_corner_id; - face_id = left_face_id; - } - } else { - // Right face was not visited. - if (this->IsFaceVisited(left_face_id)) { - // Left face visited, go to the right one. - corner_id = right_corner_id; - face_id = right_face_id; - } else { - // Both neighboring faces are unvisited, we need to visit both of - // them. - - // Split the traversal. - // First make the top of the current corner stack point to the left - // face (this one will be processed second). - corner_traversal_stack_.back() = left_corner_id; - // Add a new corner to the top of the stack (right face needs to - // be traversed first). - corner_traversal_stack_.push_back(right_corner_id); - // Break from the while (true) loop. - break; - } - } - } - } - return true; - } - - private: - std::vector corner_traversal_stack_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_TRAVERSER_DEPTH_FIRST_TRAVERSER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h b/cloudreg_env/include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h deleted file mode 100644 index b60d2c1..0000000 --- a/cloudreg_env/include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MAX_PREDICTION_DEGREE_TRAVERSER_H_ -#define DRACO_COMPRESSION_MESH_TRAVERSER_MAX_PREDICTION_DEGREE_TRAVERSER_H_ - -#include - -#include "draco/compression/mesh/traverser/traverser_base.h" -#include "draco/mesh/corner_table.h" - -namespace draco { - -// PredictionDegreeTraverser provides framework for traversal over a corner -// table data structure following paper "Multi-way Geometry Encoding" by -// Cohen-or at al.'02. The traversal is implicitly guided by prediction degree -// of the destination vertices. A prediction degree is computed as the number of -// possible faces that can be used as source points for traversal to the given -// destination vertex (see image below, where faces F1 and F2 are already -// traversed and face F0 is not traversed yet. The prediction degree of vertex -// V is then equal to two). -// -// X-----V-----o -// / \ / \ / \ -// / F0\ / \ / F2\ -// X-----o-----o-----B -// \ F1/ -// \ / -// A -// -// The class implements the same interface as the DepthFirstTraverser -// (depth_first_traverser.h) and it can be controlled via the same template -// trait classes |CornerTableT| and |TraversalObserverT|, that are used -// for controlling and monitoring of the traversal respectively. For details, -// please see depth_first_traverser.h. -template -class MaxPredictionDegreeTraverser - : public TraverserBase { - public: - typedef CornerTableT CornerTable; - typedef TraversalObserverT TraversalObserver; - typedef TraverserBase Base; - - MaxPredictionDegreeTraverser() {} - - // Called before any traversing starts. - void OnTraversalStart() { - prediction_degree_.resize(this->corner_table()->num_vertices(), 0); - } - - // Called when all the traversing is done. - void OnTraversalEnd() {} - - bool TraverseFromCorner(CornerIndex corner_id) { - if (prediction_degree_.size() == 0) - return true; - - // Traversal starts from the |corner_id|. It's going to follow either the - // right or the left neighboring faces to |corner_id| based on their - // prediction degree. - traversal_stacks_[0].push_back(corner_id); - best_priority_ = 0; - // For the first face, check the remaining corners as they may not be - // processed yet. - const VertexIndex next_vert = - this->corner_table()->Vertex(this->corner_table()->Next(corner_id)); - const VertexIndex prev_vert = - this->corner_table()->Vertex(this->corner_table()->Previous(corner_id)); - if (!this->IsVertexVisited(next_vert)) { - this->MarkVertexVisited(next_vert); - this->traversal_observer().OnNewVertexVisited( - next_vert, this->corner_table()->Next(corner_id)); - } - if (!this->IsVertexVisited(prev_vert)) { - this->MarkVertexVisited(prev_vert); - this->traversal_observer().OnNewVertexVisited( - prev_vert, this->corner_table()->Previous(corner_id)); - } - const VertexIndex tip_vertex = this->corner_table()->Vertex(corner_id); - if (!this->IsVertexVisited(tip_vertex)) { - this->MarkVertexVisited(tip_vertex); - this->traversal_observer().OnNewVertexVisited(tip_vertex, corner_id); - } - // Start the actual traversal. - while ((corner_id = PopNextCornerToTraverse()) != kInvalidCornerIndex) { - FaceIndex face_id(corner_id.value() / 3); - // Make sure the face hasn't been visited yet. - if (this->IsFaceVisited(face_id)) { - // This face has been already traversed. - continue; - } - - while (true) { - face_id = FaceIndex(corner_id.value() / 3); - this->MarkFaceVisited(face_id); - this->traversal_observer().OnNewFaceVisited(face_id); - - // If the newly reached vertex hasn't been visited, mark it and notify - // the observer. - const VertexIndex vert_id = this->corner_table()->Vertex(corner_id); - if (!this->IsVertexVisited(vert_id)) { - this->MarkVertexVisited(vert_id); - this->traversal_observer().OnNewVertexVisited(vert_id, corner_id); - } - - // Check whether we can traverse to the right and left neighboring - // faces. - const CornerIndex right_corner_id = - this->corner_table()->GetRightCorner(corner_id); - const CornerIndex left_corner_id = - this->corner_table()->GetLeftCorner(corner_id); - const FaceIndex right_face_id( - (right_corner_id == kInvalidCornerIndex - ? kInvalidFaceIndex - : FaceIndex(right_corner_id.value() / 3))); - const FaceIndex left_face_id( - (left_corner_id == kInvalidCornerIndex - ? kInvalidFaceIndex - : FaceIndex(left_corner_id.value() / 3))); - const bool is_right_face_visited = this->IsFaceVisited(right_face_id); - const bool is_left_face_visited = this->IsFaceVisited(left_face_id); - - if (!is_left_face_visited) { - // We can go to the left face. - const int priority = ComputePriority(left_corner_id); - if (is_right_face_visited && priority <= best_priority_) { - // Right face has been already visited and the priority is equal or - // better than the best priority. We are sure that the left face - // would be traversed next so there is no need to put it onto the - // stack. - corner_id = left_corner_id; - continue; - } else { - AddCornerToTraversalStack(left_corner_id, priority); - } - } - if (!is_right_face_visited) { - // Go to the right face. - const int priority = ComputePriority(right_corner_id); - if (priority <= best_priority_) { - // We are sure that the right face would be traversed next so there - // is no need to put it onto the stack. - corner_id = right_corner_id; - continue; - } else { - AddCornerToTraversalStack(right_corner_id, priority); - } - } - - // Couldn't proceed directly to the next corner - break; - } - } - return true; - } - - private: - // Retrieves the next available corner (edge) to traverse. Edges are processed - // based on their priorities. - // Returns kInvalidCornerIndex when there is no edge available. - CornerIndex PopNextCornerToTraverse() { - for (int i = best_priority_; i < kMaxPriority; ++i) { - if (!traversal_stacks_[i].empty()) { - const CornerIndex ret = traversal_stacks_[i].back(); - traversal_stacks_[i].pop_back(); - best_priority_ = i; - return ret; - } - } - return kInvalidCornerIndex; - } - - inline void AddCornerToTraversalStack(CornerIndex ci, int priority) { - traversal_stacks_[priority].push_back(ci); - // Make sure that the best available priority is up to date. - if (priority < best_priority_) - best_priority_ = priority; - } - - // Returns the priority of traversing edge leading to |corner_id|. - inline int ComputePriority(CornerIndex corner_id) { - const VertexIndex v_tip = this->corner_table()->Vertex(corner_id); - // Priority 0 when traversing to already visited vertices. - int priority = 0; - if (!this->IsVertexVisited(v_tip)) { - const int degree = ++prediction_degree_[v_tip]; - // Priority 1 when prediction degree > 1, otherwise 2. - priority = (degree > 1 ? 1 : 2); - } - // Clamp the priority to the maximum number of buckets. - if (priority >= kMaxPriority) - priority = kMaxPriority - 1; - return priority; - } - - // For efficiency reasons, the priority traversal is implemented using buckets - // where each buckets represent a stack of available corners for a given - // priority. Corners with the highest priority are always processed first. - static constexpr int kMaxPriority = 3; - std::vector traversal_stacks_[kMaxPriority]; - - // Keep the track of the best available priority to improve the performance - // of PopNextCornerToTraverse() method. - int best_priority_; - - // Prediction degree available for each vertex. - IndexTypeVector prediction_degree_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_TRAVERSER_MAX_PREDICTION_DEGREE_TRAVERSER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h b/cloudreg_env/include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h deleted file mode 100644 index e66dd14..0000000 --- a/cloudreg_env/include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_ -#define DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_ - -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/attributes/points_sequencer.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Class that can be used to generate encoding (and decoding) order of attribute -// values based on the traversal of the encoded mesh. The class should be used -// as the TraversalObserverT member of a Traverser class such as the -// DepthFirstTraverser (depth_first_traverser.h). -// TODO(hemmer): rename to AttributeIndicesCodingTraverserObserver -template -class MeshAttributeIndicesEncodingObserver { - public: - MeshAttributeIndicesEncodingObserver() - : att_connectivity_(nullptr), - encoding_data_(nullptr), - mesh_(nullptr), - sequencer_(nullptr) {} - MeshAttributeIndicesEncodingObserver( - const CornerTableT *connectivity, const Mesh *mesh, - PointsSequencer *sequencer, - MeshAttributeIndicesEncodingData *encoding_data) - : att_connectivity_(connectivity), - encoding_data_(encoding_data), - mesh_(mesh), - sequencer_(sequencer) {} - - // Interface for TraversalObserverT - - void OnNewFaceVisited(FaceIndex /* face */) {} - - inline void OnNewVertexVisited(VertexIndex vertex, CornerIndex corner) { - const PointIndex point_id = - mesh_->face(FaceIndex(corner.value() / 3))[corner.value() % 3]; - // Append the visited attribute to the encoding order. - sequencer_->AddPointId(point_id); - - // Keep track of visited corners. - encoding_data_->encoded_attribute_value_index_to_corner_map.push_back( - corner); - - encoding_data_ - ->vertex_to_encoded_attribute_value_index_map[vertex.value()] = - encoding_data_->num_values; - - encoding_data_->num_values++; - } - - private: - const CornerTableT *att_connectivity_; - MeshAttributeIndicesEncodingData *encoding_data_; - const Mesh *mesh_; - PointsSequencer *sequencer_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h b/cloudreg_env/include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h deleted file mode 100644 index fbcda53..0000000 --- a/cloudreg_env/include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MESH_TRAVERSAL_SEQUENCER_H_ -#define DRACO_COMPRESSION_MESH_TRAVERSER_MESH_TRAVERSAL_SEQUENCER_H_ - -#include "draco/attributes/geometry_indices.h" -#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h" -#include "draco/compression/attributes/points_sequencer.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Sequencer that generates point sequence in an order given by a deterministic -// traversal on the mesh surface. Note that all attributes encoded with this -// sequence must share the same connectivity. -// TODO(hemmer): Consider refactoring such that this is an observer. -template -class MeshTraversalSequencer : public PointsSequencer { - public: - MeshTraversalSequencer(const Mesh *mesh, - const MeshAttributeIndicesEncodingData *encoding_data) - : mesh_(mesh), encoding_data_(encoding_data), corner_order_(nullptr) {} - void SetTraverser(const TraverserT &t) { traverser_ = t; } - - // Function that can be used to set an order in which the mesh corners should - // be processed. This is an optional flag used usually only by the encoder - // to match the same corner order that is going to be used by the decoder. - // Note that |corner_order| should contain only one corner per face (it can - // have all corners but only the first encountered corner for each face is - // going to be used to start a traversal). If the corner order is not set, the - // corners are processed sequentially based on their ids. - void SetCornerOrder(const std::vector &corner_order) { - corner_order_ = &corner_order; - } - - bool UpdatePointToAttributeIndexMapping(PointAttribute *attribute) override { - const auto *corner_table = traverser_.corner_table(); - attribute->SetExplicitMapping(mesh_->num_points()); - const size_t num_faces = mesh_->num_faces(); - const size_t num_points = mesh_->num_points(); - for (FaceIndex f(0); f < static_cast(num_faces); ++f) { - const auto &face = mesh_->face(f); - for (int p = 0; p < 3; ++p) { - const PointIndex point_id = face[p]; - const VertexIndex vert_id = - corner_table->Vertex(CornerIndex(3 * f.value() + p)); - if (vert_id == kInvalidVertexIndex) - return false; - const AttributeValueIndex att_entry_id( - encoding_data_ - ->vertex_to_encoded_attribute_value_index_map[vert_id.value()]); - if (att_entry_id.value() >= num_points) { - // There cannot be more attribute values than the number of points. - return false; - } - attribute->SetPointMapEntry(point_id, att_entry_id); - } - } - return true; - } - - protected: - bool GenerateSequenceInternal() override { - // Preallocate memory for storing point indices. We expect the number of - // points to be the same as the number of corner table vertices. - out_point_ids()->reserve(traverser_.corner_table()->num_vertices()); - - traverser_.OnTraversalStart(); - if (corner_order_) { - for (uint32_t i = 0; i < corner_order_->size(); ++i) { - if (!ProcessCorner(corner_order_->at(i))) - return false; - } - } else { - const int32_t num_faces = traverser_.corner_table()->num_faces(); - for (int i = 0; i < num_faces; ++i) { - if (!ProcessCorner(CornerIndex(3 * i))) - return false; - } - } - traverser_.OnTraversalEnd(); - return true; - } - - private: - bool ProcessCorner(CornerIndex corner_id) { - return traverser_.TraverseFromCorner(corner_id); - } - - TraverserT traverser_; - const Mesh *mesh_; - const MeshAttributeIndicesEncodingData *encoding_data_; - const std::vector *corner_order_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_TRAVERSER_MESH_TRAVERSAL_SEQUENCER_H_ diff --git a/cloudreg_env/include/draco/compression/mesh/traverser/traverser_base.h b/cloudreg_env/include/draco/compression/mesh/traverser/traverser_base.h deleted file mode 100644 index 643c5db..0000000 --- a/cloudreg_env/include/draco/compression/mesh/traverser/traverser_base.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_MESH_TRAVERSER_TRAVERSER_BASE_H_ -#define DRACO_COMPRESSION_MESH_TRAVERSER_TRAVERSER_BASE_H_ - -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Class providing the basic traversal functionality needed by traversers (such -// as the DepthFirstTraverser, see depth_first_traverser.h). It keeps a pointer -// to the corner table that is used for the traversal, plus it provides a basic -// bookkeeping of visited faces and vertices during the traversal. -template -class TraverserBase { - public: - typedef CornerTableT CornerTable; - typedef TraversalObserverT TraversalObserver; - - TraverserBase() : corner_table_(nullptr) {} - virtual ~TraverserBase() = default; - - virtual void Init(const CornerTable *corner_table, - TraversalObserver traversal_observer) { - corner_table_ = corner_table; - is_face_visited_.assign(corner_table->num_faces(), false); - is_vertex_visited_.assign(corner_table_->num_vertices(), false); - traversal_observer_ = traversal_observer; - } - - const CornerTable &GetCornerTable() const { return *corner_table_; } - - inline bool IsFaceVisited(FaceIndex face_id) const { - if (face_id == kInvalidFaceIndex) - return true; // Invalid faces are always considered as visited. - return is_face_visited_[face_id.value()]; - } - - // Returns true if the face containing the given corner was visited. - inline bool IsFaceVisited(CornerIndex corner_id) const { - if (corner_id == kInvalidCornerIndex) - return true; // Invalid faces are always considered as visited. - return is_face_visited_[corner_id.value() / 3]; - } - - inline void MarkFaceVisited(FaceIndex face_id) { - is_face_visited_[face_id.value()] = true; - } - inline bool IsVertexVisited(VertexIndex vert_id) const { - return is_vertex_visited_[vert_id.value()]; - } - inline void MarkVertexVisited(VertexIndex vert_id) { - is_vertex_visited_[vert_id.value()] = true; - } - - inline const CornerTable *corner_table() const { return corner_table_; } - inline const TraversalObserverT &traversal_observer() const { - return traversal_observer_; - } - inline TraversalObserverT &traversal_observer() { - return traversal_observer_; - } - - private: - const CornerTable *corner_table_; - TraversalObserverT traversal_observer_; - std::vector is_face_visited_; - std::vector is_vertex_visited_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_MESH_TRAVERSER_TRAVERSER_BASE_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h deleted file mode 100644 index e220a2a..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// See dynamic_integer_points_kd_tree_encoder.h for documentation. - -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_H_ - -#include -#include -#include - -#include "draco/compression/bit_coders/adaptive_rans_bit_decoder.h" -#include "draco/compression/bit_coders/direct_bit_decoder.h" -#include "draco/compression/bit_coders/folded_integer_bit_decoder.h" -#include "draco/compression/bit_coders/rans_bit_decoder.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/core/bit_utils.h" -#include "draco/core/decoder_buffer.h" -#include "draco/core/math_utils.h" - -namespace draco { - -template -struct DynamicIntegerPointsKdTreeDecoderCompressionPolicy - : public DynamicIntegerPointsKdTreeDecoderCompressionPolicy< - compression_level_t - 1> {}; - -template <> -struct DynamicIntegerPointsKdTreeDecoderCompressionPolicy<0> { - typedef DirectBitDecoder NumbersDecoder; - typedef DirectBitDecoder AxisDecoder; - typedef DirectBitDecoder HalfDecoder; - typedef DirectBitDecoder RemainingBitsDecoder; - static constexpr bool select_axis = false; -}; - -template <> -struct DynamicIntegerPointsKdTreeDecoderCompressionPolicy<2> - : public DynamicIntegerPointsKdTreeDecoderCompressionPolicy<1> { - typedef RAnsBitDecoder NumbersDecoder; -}; - -template <> -struct DynamicIntegerPointsKdTreeDecoderCompressionPolicy<4> - : public DynamicIntegerPointsKdTreeDecoderCompressionPolicy<3> { - typedef FoldedBit32Decoder NumbersDecoder; -}; - -template <> -struct DynamicIntegerPointsKdTreeDecoderCompressionPolicy<6> - : public DynamicIntegerPointsKdTreeDecoderCompressionPolicy<5> { - static constexpr bool select_axis = true; -}; - -// Decodes a point cloud encoded by DynamicIntegerPointsKdTreeEncoder. -template -class DynamicIntegerPointsKdTreeDecoder { - static_assert(compression_level_t >= 0, "Compression level must in [0..6]."); - static_assert(compression_level_t <= 6, "Compression level must in [0..6]."); - typedef DynamicIntegerPointsKdTreeDecoderCompressionPolicy< - compression_level_t> - Policy; - - typedef typename Policy::NumbersDecoder NumbersDecoder; - typedef typename Policy::AxisDecoder AxisDecoder; - typedef typename Policy::HalfDecoder HalfDecoder; - typedef typename Policy::RemainingBitsDecoder RemainingBitsDecoder; - typedef std::vector VectorUint32; - - public: - explicit DynamicIntegerPointsKdTreeDecoder(uint32_t dimension) - : bit_length_(0), - num_points_(0), - num_decoded_points_(0), - dimension_(dimension), - p_(dimension, 0), - axes_(dimension, 0), - // Init the stack with the maximum depth of the tree. - // +1 for a second leaf. - base_stack_(32 * dimension + 1, VectorUint32(dimension, 0)), - levels_stack_(32 * dimension + 1, VectorUint32(dimension, 0)) {} - - // Decodes a integer point cloud from |buffer|. - template - bool DecodePoints(DecoderBuffer *buffer, OutputIteratorT &oit); - template - bool DecodePoints(DecoderBuffer *buffer, OutputIteratorT &&oit); - - const uint32_t dimension() const { return dimension_; } - - private: - uint32_t GetAxis(uint32_t num_remaining_points, const VectorUint32 &levels, - uint32_t last_axis); - - template - bool DecodeInternal(uint32_t num_points, OutputIteratorT &oit); - - void DecodeNumber(int nbits, uint32_t *value) { - numbers_decoder_.DecodeLeastSignificantBits32(nbits, value); - } - - struct DecodingStatus { - DecodingStatus(uint32_t num_remaining_points_, uint32_t last_axis_, - uint32_t stack_pos_) - : num_remaining_points(num_remaining_points_), - last_axis(last_axis_), - stack_pos(stack_pos_) {} - - uint32_t num_remaining_points; - uint32_t last_axis; - uint32_t stack_pos; // used to get base and levels - }; - - uint32_t bit_length_; - uint32_t num_points_; - uint32_t num_decoded_points_; - uint32_t dimension_; - NumbersDecoder numbers_decoder_; - RemainingBitsDecoder remaining_bits_decoder_; - AxisDecoder axis_decoder_; - HalfDecoder half_decoder_; - VectorUint32 p_; - VectorUint32 axes_; - std::vector base_stack_; - std::vector levels_stack_; -}; - -// Decodes a point cloud from |buffer|. -template -template -bool DynamicIntegerPointsKdTreeDecoder::DecodePoints( - DecoderBuffer *buffer, OutputIteratorT &&oit) { - OutputIteratorT local = std::forward(oit); - return DecodePoints(buffer, local); -} - -template -template -bool DynamicIntegerPointsKdTreeDecoder::DecodePoints( - DecoderBuffer *buffer, OutputIteratorT &oit) { - buffer->Decode(&bit_length_); - if (bit_length_ > 32) - return false; - buffer->Decode(&num_points_); - if (num_points_ == 0) - return true; - num_decoded_points_ = 0; - - if (!numbers_decoder_.StartDecoding(buffer)) - return false; - if (!remaining_bits_decoder_.StartDecoding(buffer)) - return false; - if (!axis_decoder_.StartDecoding(buffer)) - return false; - if (!half_decoder_.StartDecoding(buffer)) - return false; - - if (!DecodeInternal(num_points_, oit)) - return false; - - numbers_decoder_.EndDecoding(); - remaining_bits_decoder_.EndDecoding(); - axis_decoder_.EndDecoding(); - half_decoder_.EndDecoding(); - - return true; -} - -template -uint32_t DynamicIntegerPointsKdTreeDecoder::GetAxis( - uint32_t num_remaining_points, const VectorUint32 &levels, - uint32_t last_axis) { - if (!Policy::select_axis) - return DRACO_INCREMENT_MOD(last_axis, dimension_); - - uint32_t best_axis = 0; - if (num_remaining_points < 64) { - for (uint32_t axis = 1; axis < dimension_; ++axis) { - if (levels[best_axis] > levels[axis]) { - best_axis = axis; - } - } - } else { - axis_decoder_.DecodeLeastSignificantBits32(4, &best_axis); - } - - return best_axis; -} - -template -template -bool DynamicIntegerPointsKdTreeDecoder::DecodeInternal( - uint32_t num_points, OutputIteratorT &oit) { - typedef DecodingStatus Status; - base_stack_[0] = VectorUint32(dimension_, 0); - levels_stack_[0] = VectorUint32(dimension_, 0); - DecodingStatus init_status(num_points, 0, 0); - std::stack status_stack; - status_stack.push(init_status); - - // TODO(hemmer): use preallocated vector instead of stack. - while (!status_stack.empty()) { - const DecodingStatus status = status_stack.top(); - status_stack.pop(); - - const uint32_t num_remaining_points = status.num_remaining_points; - const uint32_t last_axis = status.last_axis; - const uint32_t stack_pos = status.stack_pos; - const VectorUint32 &old_base = base_stack_[stack_pos]; - const VectorUint32 &levels = levels_stack_[stack_pos]; - - if (num_remaining_points > num_points) - return false; - - const uint32_t axis = GetAxis(num_remaining_points, levels, last_axis); - if (axis >= dimension_) - return false; - - const uint32_t level = levels[axis]; - - // All axes have been fully subdivided, just output points. - if ((bit_length_ - level) == 0) { - for (uint32_t i = 0; i < num_remaining_points; i++) { - *oit = old_base; - ++oit; - ++num_decoded_points_; - } - continue; - } - - DRACO_DCHECK_EQ(true, num_remaining_points != 0); - - // Fast decoding of remaining bits if number of points is 1 or 2. - if (num_remaining_points <= 2) { - // TODO(hemmer): axes_ not necessary, remove would change bitstream! - axes_[0] = axis; - for (uint32_t i = 1; i < dimension_; i++) { - axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_); - } - for (uint32_t i = 0; i < num_remaining_points; ++i) { - for (uint32_t j = 0; j < dimension_; j++) { - p_[axes_[j]] = 0; - const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]]; - if (num_remaining_bits) - remaining_bits_decoder_.DecodeLeastSignificantBits32( - num_remaining_bits, &p_[axes_[j]]); - p_[axes_[j]] = old_base[axes_[j]] | p_[axes_[j]]; - } - *oit = p_; - ++oit; - ++num_decoded_points_; - } - continue; - } - - if (num_decoded_points_ > num_points_) - return false; - - const int num_remaining_bits = bit_length_ - level; - const uint32_t modifier = 1 << (num_remaining_bits - 1); - base_stack_[stack_pos + 1] = old_base; // copy - base_stack_[stack_pos + 1][axis] += modifier; // new base - - const int incoming_bits = MostSignificantBit(num_remaining_points); - - uint32_t number = 0; - DecodeNumber(incoming_bits, &number); - - uint32_t first_half = num_remaining_points / 2 - number; - uint32_t second_half = num_remaining_points - first_half; - - if (first_half != second_half) - if (!half_decoder_.DecodeNextBit()) - std::swap(first_half, second_half); - - levels_stack_[stack_pos][axis] += 1; - levels_stack_[stack_pos + 1] = levels_stack_[stack_pos]; // copy - if (first_half) - status_stack.push(DecodingStatus(first_half, axis, stack_pos)); - if (second_half) - status_stack.push(DecodingStatus(second_half, axis, stack_pos + 1)); - } - return true; -} - -extern template class DynamicIntegerPointsKdTreeDecoder<0>; -extern template class DynamicIntegerPointsKdTreeDecoder<2>; -extern template class DynamicIntegerPointsKdTreeDecoder<4>; -extern template class DynamicIntegerPointsKdTreeDecoder<6>; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h deleted file mode 100644 index 47ac653..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +++ /dev/null @@ -1,365 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_H_ - -#include -#include -#include -#include -#include - -#include "draco/compression/bit_coders/adaptive_rans_bit_encoder.h" -#include "draco/compression/bit_coders/direct_bit_encoder.h" -#include "draco/compression/bit_coders/folded_integer_bit_encoder.h" -#include "draco/compression/bit_coders/rans_bit_encoder.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/core/bit_utils.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/math_utils.h" - -namespace draco { - -// This policy class provides several configurations for the encoder that allow -// to trade speed vs compression rate. Level 0 is fastest while 6 is the best -// compression rate. The decoder must select the same level. -template -struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy - : public DynamicIntegerPointsKdTreeEncoderCompressionPolicy< - compression_level_t - 1> {}; - -template <> -struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<0> { - typedef DirectBitEncoder NumbersEncoder; - typedef DirectBitEncoder AxisEncoder; - typedef DirectBitEncoder HalfEncoder; - typedef DirectBitEncoder RemainingBitsEncoder; - static constexpr bool select_axis = false; -}; - -template <> -struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<2> - : public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<1> { - typedef RAnsBitEncoder NumbersEncoder; -}; - -template <> -struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<4> - : public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<3> { - typedef FoldedBit32Encoder NumbersEncoder; -}; - -template <> -struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<6> - : public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<5> { - static constexpr bool select_axis = true; -}; - -// This class encodes a given integer point cloud based on the point cloud -// compression algorithm in: -// Olivier Devillers and Pierre-Marie Gandoin -// "Geometric compression for interactive transmission" -// -// In principle the algorithm keeps on splitting the point cloud in the middle -// while alternating the axes. In 3D this results in an Octree like structure. -// In each step we encode the number of points in the first half. -// The algorithm does not preserve the order of points. -// -// However, the algorithm here differs from the original as follows: -// The algorithm keeps on splitting the point cloud in the middle of the axis -// that keeps the point cloud as clustered as possible, which gives a better -// compression rate. -// The number of points is encode by the deviation from the half of the points -// in the smaller half of the two. This results in a better compression rate as -// there are more leading zeros, which is then compressed better by the -// arithmetic encoding. -template -class DynamicIntegerPointsKdTreeEncoder { - static_assert(compression_level_t >= 0, "Compression level must in [0..6]."); - static_assert(compression_level_t <= 6, "Compression level must in [0..6]."); - typedef DynamicIntegerPointsKdTreeEncoderCompressionPolicy< - compression_level_t> - Policy; - typedef typename Policy::NumbersEncoder NumbersEncoder; - typedef typename Policy::AxisEncoder AxisEncoder; - typedef typename Policy::HalfEncoder HalfEncoder; - typedef typename Policy::RemainingBitsEncoder RemainingBitsEncoder; - typedef std::vector VectorUint32; - - public: - explicit DynamicIntegerPointsKdTreeEncoder(uint32_t dimension) - : bit_length_(0), - dimension_(dimension), - deviations_(dimension, 0), - num_remaining_bits_(dimension, 0), - axes_(dimension, 0), - base_stack_(32 * dimension + 1, VectorUint32(dimension, 0)), - levels_stack_(32 * dimension + 1, VectorUint32(dimension, 0)) {} - - // Encodes an integer point cloud given by [begin,end) into buffer. - // |bit_length| gives the highest bit used for all coordinates. - template - bool EncodePoints(RandomAccessIteratorT begin, RandomAccessIteratorT end, - const uint32_t &bit_length, EncoderBuffer *buffer); - - // Encodes an integer point cloud given by [begin,end) into buffer. - template - bool EncodePoints(RandomAccessIteratorT begin, RandomAccessIteratorT end, - EncoderBuffer *buffer) { - return EncodePoints(begin, end, 32, buffer); - } - - const uint32_t dimension() const { return dimension_; } - - private: - template - uint32_t GetAndEncodeAxis(RandomAccessIteratorT begin, - RandomAccessIteratorT end, - const VectorUint32 &old_base, - const VectorUint32 &levels, uint32_t last_axis); - template - void EncodeInternal(RandomAccessIteratorT begin, RandomAccessIteratorT end); - - class Splitter { - public: - Splitter(uint32_t axis, uint32_t value) : axis_(axis), value_(value) {} - template - bool operator()(const PointT &a) const { - return a[axis_] < value_; - } - - private: - const uint32_t axis_; - const uint32_t value_; - }; - - void EncodeNumber(int nbits, uint32_t value) { - numbers_encoder_.EncodeLeastSignificantBits32(nbits, value); - } - - template - struct EncodingStatus { - EncodingStatus(RandomAccessIteratorT begin_, RandomAccessIteratorT end_, - uint32_t last_axis_, uint32_t stack_pos_) - : begin(begin_), - end(end_), - last_axis(last_axis_), - stack_pos(stack_pos_) { - num_remaining_points = static_cast(end - begin); - } - - RandomAccessIteratorT begin; - RandomAccessIteratorT end; - uint32_t last_axis; - uint32_t num_remaining_points; - uint32_t stack_pos; // used to get base and levels - }; - - uint32_t bit_length_; - uint32_t num_points_; - uint32_t dimension_; - NumbersEncoder numbers_encoder_; - RemainingBitsEncoder remaining_bits_encoder_; - AxisEncoder axis_encoder_; - HalfEncoder half_encoder_; - VectorUint32 deviations_; - VectorUint32 num_remaining_bits_; - VectorUint32 axes_; - std::vector base_stack_; - std::vector levels_stack_; -}; - -template -template -bool DynamicIntegerPointsKdTreeEncoder::EncodePoints( - RandomAccessIteratorT begin, RandomAccessIteratorT end, - const uint32_t &bit_length, EncoderBuffer *buffer) { - bit_length_ = bit_length; - num_points_ = static_cast(end - begin); - - buffer->Encode(bit_length_); - buffer->Encode(num_points_); - if (num_points_ == 0) - return true; - - numbers_encoder_.StartEncoding(); - remaining_bits_encoder_.StartEncoding(); - axis_encoder_.StartEncoding(); - half_encoder_.StartEncoding(); - - EncodeInternal(begin, end); - - numbers_encoder_.EndEncoding(buffer); - remaining_bits_encoder_.EndEncoding(buffer); - axis_encoder_.EndEncoding(buffer); - half_encoder_.EndEncoding(buffer); - - return true; -} -template -template -uint32_t -DynamicIntegerPointsKdTreeEncoder::GetAndEncodeAxis( - RandomAccessIteratorT begin, RandomAccessIteratorT end, - const VectorUint32 &old_base, const VectorUint32 &levels, - uint32_t last_axis) { - if (!Policy::select_axis) - return DRACO_INCREMENT_MOD(last_axis, dimension_); - - // For many points this function selects the axis that should be used - // for the split by keeping as many points as possible bundled. - // In the best case we do not split the point cloud at all. - // For lower number of points, we simply choose the axis that is refined the - // least so far. - - DRACO_DCHECK_EQ(true, end - begin != 0); - - uint32_t best_axis = 0; - if (end - begin < 64) { - for (uint32_t axis = 1; axis < dimension_; ++axis) { - if (levels[best_axis] > levels[axis]) { - best_axis = axis; - } - } - } else { - const uint32_t size = static_cast(end - begin); - for (uint32_t i = 0; i < dimension_; i++) { - deviations_[i] = 0; - num_remaining_bits_[i] = bit_length_ - levels[i]; - if (num_remaining_bits_[i] > 0) { - const uint32_t split = - old_base[i] + (1 << (num_remaining_bits_[i] - 1)); - for (auto it = begin; it != end; ++it) { - deviations_[i] += ((*it)[i] < split); - } - deviations_[i] = std::max(size - deviations_[i], deviations_[i]); - } - } - - uint32_t max_value = 0; - best_axis = 0; - for (uint32_t i = 0; i < dimension_; i++) { - // If axis can be subdivided. - if (num_remaining_bits_[i]) { - // Check if this is the better axis. - if (max_value < deviations_[i]) { - max_value = deviations_[i]; - best_axis = i; - } - } - } - axis_encoder_.EncodeLeastSignificantBits32(4, best_axis); - } - - return best_axis; -} - -template -template -void DynamicIntegerPointsKdTreeEncoder::EncodeInternal( - RandomAccessIteratorT begin, RandomAccessIteratorT end) { - typedef EncodingStatus Status; - - base_stack_[0] = VectorUint32(dimension_, 0); - levels_stack_[0] = VectorUint32(dimension_, 0); - Status init_status(begin, end, 0, 0); - std::stack status_stack; - status_stack.push(init_status); - - // TODO(hemmer): use preallocated vector instead of stack. - while (!status_stack.empty()) { - Status status = status_stack.top(); - status_stack.pop(); - - begin = status.begin; - end = status.end; - const uint32_t last_axis = status.last_axis; - const uint32_t stack_pos = status.stack_pos; - const VectorUint32 &old_base = base_stack_[stack_pos]; - const VectorUint32 &levels = levels_stack_[stack_pos]; - - const uint32_t axis = - GetAndEncodeAxis(begin, end, old_base, levels, last_axis); - const uint32_t level = levels[axis]; - const uint32_t num_remaining_points = static_cast(end - begin); - - // If this happens all axis are subdivided to the end. - if ((bit_length_ - level) == 0) - continue; - - // Fast encoding of remaining bits if number of points is 1 or 2. - // Doing this also for 2 gives a slight additional speed up. - if (num_remaining_points <= 2) { - // TODO(hemmer): axes_ not necessary, remove would change bitstream! - axes_[0] = axis; - for (uint32_t i = 1; i < dimension_; i++) { - axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_); - } - for (uint32_t i = 0; i < num_remaining_points; ++i) { - const auto &p = *(begin + i); - for (uint32_t j = 0; j < dimension_; j++) { - const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]]; - if (num_remaining_bits) { - remaining_bits_encoder_.EncodeLeastSignificantBits32( - num_remaining_bits, p[axes_[j]]); - } - } - } - continue; - } - - const uint32_t num_remaining_bits = bit_length_ - level; - const uint32_t modifier = 1 << (num_remaining_bits - 1); - base_stack_[stack_pos + 1] = old_base; // copy - base_stack_[stack_pos + 1][axis] += modifier; - const VectorUint32 &new_base = base_stack_[stack_pos + 1]; - - const RandomAccessIteratorT split = - std::partition(begin, end, Splitter(axis, new_base[axis])); - - DRACO_DCHECK_EQ(true, (end - begin) > 0); - - // Encode number of points in first and second half. - const int required_bits = MostSignificantBit(num_remaining_points); - - const uint32_t first_half = static_cast(split - begin); - const uint32_t second_half = static_cast(end - split); - const bool left = first_half < second_half; - - if (first_half != second_half) - half_encoder_.EncodeBit(left); - - if (left) { - EncodeNumber(required_bits, num_remaining_points / 2 - first_half); - } else { - EncodeNumber(required_bits, num_remaining_points / 2 - second_half); - } - - levels_stack_[stack_pos][axis] += 1; - levels_stack_[stack_pos + 1] = levels_stack_[stack_pos]; // copy - if (split != begin) - status_stack.push(Status(begin, split, axis, stack_pos)); - if (split != end) - status_stack.push(Status(split, end, axis, stack_pos + 1)); - } -} -extern template class DynamicIntegerPointsKdTreeEncoder<0>; -extern template class DynamicIntegerPointsKdTreeEncoder<2>; -extern template class DynamicIntegerPointsKdTreeEncoder<4>; -extern template class DynamicIntegerPointsKdTreeEncoder<6>; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h deleted file mode 100644 index 80be0c9..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_ - -#include - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_compression_method.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/compression/point_cloud/algorithms/quantize_points_3.h" -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// Decodes a point cloud encoded by PointCloudTreeEncoder. -class FloatPointsTreeDecoder { - public: - FloatPointsTreeDecoder(); - - // Decodes a point cloud from |buffer|. - template - bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &out); - template - bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &&out); - // Initializes a DecoderBuffer from |data|, and calls function above. - template - bool DecodePointCloud(const char *data, size_t data_size, - OutputIteratorT out) { - if (data == 0 || data_size <= 0) - return false; - - DecoderBuffer buffer; - buffer.Init(data, data_size); - buffer.set_bitstream_version(kDracoPointCloudBitstreamVersion); - return DecodePointCloud(&buffer, out); - } - - uint32_t quantization_bits() const { return qinfo_.quantization_bits; } - uint32_t compression_level() const { return compression_level_; } - float range() const { return qinfo_.range; } - uint32_t num_points() const { return num_points_; } - uint32_t version() const { return version_; } - std::string identification_string() const { - if (method_ == KDTREE) { - return "FloatPointsTreeDecoder: IntegerPointsKDTreeDecoder"; - } else { - return "FloatPointsTreeDecoder: Unsupported Method"; - } - } - - private: - bool DecodePointCloudKdTreeInternal(DecoderBuffer *buffer, - std::vector *qpoints); - - static const uint32_t version_ = 3; - QuantizationInfo qinfo_; - PointCloudCompressionMethod method_; - uint32_t num_points_; - uint32_t compression_level_; -}; - -template -bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer, - OutputIteratorT &&out) { - OutputIteratorT local = std::forward(out); - return DecodePointCloud(buffer, local); -} - -template -bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer, - OutputIteratorT &out) { - std::vector qpoints; - - uint32_t decoded_version; - if (!buffer->Decode(&decoded_version)) - return false; - - if (decoded_version == 3) { - int8_t method_number; - if (!buffer->Decode(&method_number)) - return false; - - method_ = static_cast(method_number); - - if (method_ == KDTREE) { - if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) - return false; - } else { // Unsupported method. - fprintf(stderr, "Method not supported. \n"); - return false; - } - } else if (decoded_version == 2) { // Version 2 only uses KDTREE method. - if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) - return false; - } else { // Unsupported version. - fprintf(stderr, "Version not supported. \n"); - return false; - } - - DequantizePoints3(qpoints.begin(), qpoints.end(), qinfo_, out); - return true; -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h deleted file mode 100644 index 1fd8074..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_ENCODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_ENCODER_H_ - -#include -#include - -#include "draco/compression/point_cloud/algorithms/point_cloud_compression_method.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/compression/point_cloud/algorithms/quantize_points_3.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// This class encodes a given point cloud based on the point cloud compression -// algorithm in: -// Olivier Devillers and Pierre-Marie Gandoin -// "Geometric compression for interactive transmission" -// -// In principle the algorithm keeps on splitting the point cloud in the middle -// while alternating the axes. For 3D this results in an Octree like structure. -// In each step we encode the number of points in the first half. -// The algorithm uses quantization and does not preserve the order of points. -// -// However, the algorithm here differs from the original as follows: -// The algorithm keeps on splitting the point cloud in the middle of the axis -// that keeps the point cloud as clustered as possible, which gives a better -// compression rate. -// The number of points is encode by the deviation from the half of the points -// in the smaller half of the two. This results in a better compression rate as -// there are more leading zeros, which is then compressed better by the -// arithmetic encoding. - -// TODO(hemmer): Remove class because it duplicates quantization code. -class FloatPointsTreeEncoder { - public: - explicit FloatPointsTreeEncoder(PointCloudCompressionMethod method); - explicit FloatPointsTreeEncoder(PointCloudCompressionMethod method, - uint32_t quantization_bits, - uint32_t compression_level); - - template - bool EncodePointCloud(InputIteratorT points_begin, InputIteratorT points_end); - EncoderBuffer *buffer() { return &buffer_; } - - uint32_t version() const { return version_; } - uint32_t quantization_bits() const { return qinfo_.quantization_bits; } - uint32_t &quantization_bits() { return qinfo_.quantization_bits; } - uint32_t compression_level() const { return compression_level_; } - uint32_t &compression_level() { return compression_level_; } - float range() const { return qinfo_.range; } - uint32_t num_points() const { return num_points_; } - std::string identification_string() const { - if (method_ == KDTREE) { - return "FloatPointsTreeEncoder: IntegerPointsKDTreeEncoder"; - } else { - return "FloatPointsTreeEncoder: Unsupported Method"; - } - } - - private: - void Clear() { buffer_.Clear(); } - bool EncodePointCloudKdTreeInternal(std::vector *qpoints); - - static const uint32_t version_; - QuantizationInfo qinfo_; - PointCloudCompressionMethod method_; - uint32_t num_points_; - EncoderBuffer buffer_; - uint32_t compression_level_; -}; - -template -bool FloatPointsTreeEncoder::EncodePointCloud(InputIteratorT points_begin, - InputIteratorT points_end) { - Clear(); - - // Collect necessary data for encoding. - num_points_ = std::distance(points_begin, points_end); - - // TODO(hemmer): Extend quantization tools to make this more automatic. - // Compute range of points for quantization - std::vector qpoints; - qpoints.reserve(num_points_); - QuantizePoints3(points_begin, points_end, &qinfo_, - std::back_inserter(qpoints)); - - // Encode header. - buffer()->Encode(version_); - buffer()->Encode(static_cast(method_)); - buffer()->Encode(qinfo_.quantization_bits); - buffer()->Encode(qinfo_.range); - buffer()->Encode(num_points_); - - if (method_ == KDTREE) - buffer()->Encode(compression_level_); - - if (num_points_ == 0) - return true; - - if (method_ == KDTREE) { - return EncodePointCloudKdTreeInternal(&qpoints); - } else { // Unsupported method. - fprintf(stderr, "Method not supported. \n"); - return false; - } -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h deleted file mode 100644 index 06ee718..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/integer_points_kd_tree_decoder.h +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// TODO(hemmer): Make this a wrapper using DynamicIntegerPointsKdTreeDecoder. -// -// See integer_points_kd_tree_encoder.h for documentation. - -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_DECODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_DECODER_H_ - -#include -#include - -#include "draco/compression/bit_coders/adaptive_rans_bit_decoder.h" -#include "draco/compression/bit_coders/direct_bit_decoder.h" -#include "draco/compression/bit_coders/folded_integer_bit_decoder.h" -#include "draco/compression/bit_coders/rans_bit_decoder.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/compression/point_cloud/algorithms/queuing_policy.h" -#include "draco/core/bit_utils.h" -#include "draco/core/decoder_buffer.h" -#include "draco/core/math_utils.h" - -namespace draco { - -template -struct IntegerPointsKdTreeDecoderCompressionPolicy - : public IntegerPointsKdTreeDecoderCompressionPolicy {}; - -template <> -struct IntegerPointsKdTreeDecoderCompressionPolicy<0> { - typedef DirectBitDecoder NumbersDecoder; - typedef DirectBitDecoder AxisDecoder; - typedef DirectBitDecoder HalfDecoder; - typedef DirectBitDecoder RemainingBitsDecoder; - static constexpr bool select_axis = false; - - template - using QueuingStrategy = Stack; -}; - -template <> -struct IntegerPointsKdTreeDecoderCompressionPolicy<2> - : public IntegerPointsKdTreeDecoderCompressionPolicy<1> { - typedef RAnsBitDecoder NumbersDecoder; -}; - -template <> -struct IntegerPointsKdTreeDecoderCompressionPolicy<4> - : public IntegerPointsKdTreeDecoderCompressionPolicy<3> { - typedef FoldedBit32Decoder NumbersDecoder; -}; - -template <> -struct IntegerPointsKdTreeDecoderCompressionPolicy<6> - : public IntegerPointsKdTreeDecoderCompressionPolicy<5> { - static constexpr bool select_axis = true; -}; - -template <> -struct IntegerPointsKdTreeDecoderCompressionPolicy<8> - : public IntegerPointsKdTreeDecoderCompressionPolicy<7> { - typedef FoldedBit32Decoder NumbersDecoder; - template - using QueuingStrategy = Queue; -}; - -template <> -struct IntegerPointsKdTreeDecoderCompressionPolicy<10> - : public IntegerPointsKdTreeDecoderCompressionPolicy<9> { - template - using QueuingStrategy = PriorityQueue; -}; - -// Decodes a point cloud encoded by IntegerPointsKdTreeEncoder. -// |PointDiT| is a type representing a point with uint32_t coordinates. -// must provide construction from three uint32_t and operator[]. -template -class IntegerPointsKdTreeDecoder { - typedef IntegerPointsKdTreeDecoderCompressionPolicy - Policy; - - typedef typename Policy::NumbersDecoder NumbersDecoder; - typedef typename Policy::AxisDecoder AxisDecoder; - typedef typename Policy::HalfDecoder HalfDecoder; - typedef typename Policy::RemainingBitsDecoder RemainingBitsDecoder; - - public: - IntegerPointsKdTreeDecoder() : bit_length_(0) {} - - // Decodes a integer point cloud from |buffer|. - template - bool DecodePoints(DecoderBuffer *buffer, OutputIteratorT oit); - - private: - // For the sake of readability of code, we decided to make this exception - // from the naming scheme. - static constexpr int D = PointTraits::Dimension(); - - uint32_t GetAxis(uint32_t num_remaining_points, const PointDiT &base, - std::array levels, uint32_t last_axis); - - template - void DecodeInternal(uint32_t num_remaining_points, PointDiT base, - std::array levels, uint32_t last_axis, - OutputIteratorT oit); - - void DecodeNumber(int nbits, uint32_t *value) { - numbers_decoder_.DecodeLeastSignificantBits32(nbits, value); - } - - struct DecodingStatus { - DecodingStatus( - uint32_t num_remaining_points_, const PointDiT &old_base_, - std::array::Dimension()> levels_, - uint32_t last_axis_) - : num_remaining_points(num_remaining_points_), - old_base(old_base_), - levels(levels_), - last_axis(last_axis_) {} - - uint32_t num_remaining_points; - PointDiT old_base; - std::array levels; - uint32_t last_axis; - friend bool operator<(const DecodingStatus &l, const DecodingStatus &r) { - return l.num_remaining_points < r.num_remaining_points; - } - }; - - uint32_t bit_length_; - uint32_t num_points_; - NumbersDecoder numbers_decoder_; - RemainingBitsDecoder remaining_bits_decoder_; - AxisDecoder axis_decoder_; - HalfDecoder half_decoder_; -}; - -// Decodes a point cloud from |buffer|. -template -template -bool IntegerPointsKdTreeDecoder::DecodePoints( - DecoderBuffer *buffer, OutputIteratorT oit) { - buffer->Decode(&bit_length_); - buffer->Decode(&num_points_); - if (num_points_ == 0) - return true; - - if (!numbers_decoder_.StartDecoding(buffer)) - return false; - if (!remaining_bits_decoder_.StartDecoding(buffer)) - return false; - if (!axis_decoder_.StartDecoding(buffer)) - return false; - if (!half_decoder_.StartDecoding(buffer)) - return false; - - DecodeInternal(num_points_, PointTraits::Origin(), - PointTraits::ZeroArray(), 0, oit); - - numbers_decoder_.EndDecoding(); - remaining_bits_decoder_.EndDecoding(); - axis_decoder_.EndDecoding(); - half_decoder_.EndDecoding(); - - return true; -} - -template -uint32_t IntegerPointsKdTreeDecoder::GetAxis( - uint32_t num_remaining_points, const PointDiT & /* base */, - std::array levels, uint32_t last_axis) { - if (!Policy::select_axis) - return DRACO_INCREMENT_MOD(last_axis, D); - - uint32_t best_axis = 0; - if (num_remaining_points < 64) { - for (uint32_t axis = 1; axis < D; ++axis) { - if (levels[best_axis] > levels[axis]) { - best_axis = axis; - } - } - } else { - axis_decoder_.DecodeLeastSignificantBits32(4, &best_axis); - } - - return best_axis; -} - -template -template -void IntegerPointsKdTreeDecoder::DecodeInternal( - uint32_t num_remaining_points, PointDiT old_base, - std::array levels, uint32_t last_axis, OutputIteratorT oit) { - DecodingStatus init_status(num_remaining_points, old_base, levels, last_axis); - typename Policy::template QueuingStrategy status_q; - status_q.push(init_status); - - while (!status_q.empty()) { - const DecodingStatus status = status_q.front(); - status_q.pop(); - - num_remaining_points = status.num_remaining_points; - old_base = status.old_base; - levels = status.levels; - last_axis = status.last_axis; - - const uint32_t axis = - GetAxis(num_remaining_points, old_base, levels, last_axis); - - const uint32_t level = levels[axis]; - - // All axes have been fully subdivided, just output points. - if ((bit_length_ - level) == 0) { - for (int i = 0; i < static_cast(num_remaining_points); i++) { - *oit++ = old_base; - } - continue; - } - - DRACO_DCHECK_EQ(true, num_remaining_points != 0); - if (num_remaining_points <= 2) { - std::array axes; - axes[0] = axis; - for (int i = 1; i < D; i++) { - axes[i] = DRACO_INCREMENT_MOD(axes[i - 1], D); - } - - std::array num_remaining_bits; - for (int i = 0; i < D; i++) { - num_remaining_bits[i] = bit_length_ - levels[axes[i]]; - } - - for (uint32_t i = 0; i < num_remaining_points; ++i) { - // Get remaining bits, mind the carry if not starting at x. - PointDiT p = PointTraits::Origin(); - for (int j = 0; j < static_cast(D); j++) { - if (num_remaining_bits[j]) - remaining_bits_decoder_.DecodeLeastSignificantBits32( - num_remaining_bits[j], &p[axes[j]]); - p[axes[j]] = old_base[axes[j]] | p[axes[j]]; - } - *oit++ = p; - } - continue; - } - - const int num_remaining_bits = bit_length_ - level; - const uint32_t modifier = 1 << (num_remaining_bits - 1); - PointDiT new_base(old_base); - new_base[axis] += modifier; - - const int incoming_bits = MostSignificantBit(num_remaining_points); - - uint32_t number = 0; - DecodeNumber(incoming_bits, &number); - - uint32_t first_half = num_remaining_points / 2 - number; - uint32_t second_half = num_remaining_points - first_half; - - if (first_half != second_half) - if (!half_decoder_.DecodeNextBit()) - std::swap(first_half, second_half); - - levels[axis] += 1; - if (first_half) - status_q.push(DecodingStatus(first_half, old_base, levels, axis)); - if (second_half) - status_q.push(DecodingStatus(second_half, new_base, levels, axis)); - } -} - -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; -extern template class IntegerPointsKdTreeDecoder; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/integer_points_kd_tree_encoder.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/integer_points_kd_tree_encoder.h deleted file mode 100644 index 9a3e8d7..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/integer_points_kd_tree_encoder.h +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// TODO(hemmer): Make this a wrapper using DynamicIntegerPointsKdTreeEncoder. -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_ENCODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_ENCODER_H_ - -#include -#include -#include -#include - -#include "draco/compression/bit_coders/adaptive_rans_bit_encoder.h" -#include "draco/compression/bit_coders/direct_bit_encoder.h" -#include "draco/compression/bit_coders/folded_integer_bit_encoder.h" -#include "draco/compression/bit_coders/rans_bit_encoder.h" -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/compression/point_cloud/algorithms/queuing_policy.h" -#include "draco/core/bit_utils.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/math_utils.h" - -namespace draco { - -// This policy class provides several configurations for the encoder that allow -// to trade speed vs compression rate. Level 0 is fastest while 10 is the best -// compression rate. The decoder must select the same level. -template -struct IntegerPointsKdTreeEncoderCompressionPolicy - : public IntegerPointsKdTreeEncoderCompressionPolicy {}; - -template <> -struct IntegerPointsKdTreeEncoderCompressionPolicy<0> { - typedef DirectBitEncoder NumbersEncoder; - typedef DirectBitEncoder AxisEncoder; - typedef DirectBitEncoder HalfEncoder; - typedef DirectBitEncoder RemainingBitsEncoder; - static constexpr bool select_axis = false; - - template - using QueuingStrategy = Stack; -}; - -template <> -struct IntegerPointsKdTreeEncoderCompressionPolicy<2> - : public IntegerPointsKdTreeEncoderCompressionPolicy<1> { - typedef RAnsBitEncoder NumbersEncoder; -}; - -template <> -struct IntegerPointsKdTreeEncoderCompressionPolicy<4> - : public IntegerPointsKdTreeEncoderCompressionPolicy<3> { - typedef FoldedBit32Encoder NumbersEncoder; -}; - -template <> -struct IntegerPointsKdTreeEncoderCompressionPolicy<6> - : public IntegerPointsKdTreeEncoderCompressionPolicy<5> { - static constexpr bool select_axis = true; -}; - -template <> -struct IntegerPointsKdTreeEncoderCompressionPolicy<8> - : public IntegerPointsKdTreeEncoderCompressionPolicy<7> { - typedef FoldedBit32Encoder NumbersEncoder; - template - using QueuingStrategy = Queue; -}; - -template <> -struct IntegerPointsKdTreeEncoderCompressionPolicy<10> - : public IntegerPointsKdTreeEncoderCompressionPolicy<9> { - template - using QueuingStrategy = PriorityQueue; -}; - -// This class encodes a given integer point cloud based on the point cloud -// compression algorithm in: -// Olivier Devillers and Pierre-Marie Gandoin -// "Geometric compression for interactive transmission" -// -// In principle the algorithm keeps on splitting the point cloud in the middle -// while alternating the axes. In 3D this results in an Octree like structure. -// In each step we encode the number of points in the first half. -// The algorithm does not preserve the order of points. -// -// However, the algorithm here differs from the original as follows: -// The algorithm keeps on splitting the point cloud in the middle of the axis -// that keeps the point cloud as clustered as possible, which gives a better -// compression rate. -// The number of points is encode by the deviation from the half of the points -// in the smaller half of the two. This results in a better compression rate as -// there are more leading zeros, which is then compressed better by the -// arithmetic encoding. -// -// |PointDiT| is a type representing a point with uint32_t coordinates. -// must provide construction from three uint32_t and operator[]. -template -class IntegerPointsKdTreeEncoder { - typedef IntegerPointsKdTreeEncoderCompressionPolicy - Policy; - typedef typename Policy::NumbersEncoder NumbersEncoder; - typedef typename Policy::AxisEncoder AxisEncoder; - typedef typename Policy::HalfEncoder HalfEncoder; - typedef typename Policy::RemainingBitsEncoder RemainingBitsEncoder; - - public: - IntegerPointsKdTreeEncoder() : bit_length_(0) {} - - // Encodes an integer point cloud given by [begin,end) into buffer. - // |bit_length| gives the highest bit used for all coordinates. - template - bool EncodePoints(RandomAccessIteratorT begin, RandomAccessIteratorT end, - const uint32_t &bit_length, EncoderBuffer *buffer); - - // Encodes an integer point cloud given by [begin,end) into buffer. - template - bool EncodePoints(RandomAccessIteratorT begin, RandomAccessIteratorT end, - EncoderBuffer *buffer) { - return EncodePoints(begin, end, 32, buffer); - } - - private: - // For the sack of readability of code, we decided to make this exception - // from the naming scheme. - static constexpr int D = PointTraits::Dimension(); - template - uint32_t GetAxis(RandomAccessIteratorT begin, RandomAccessIteratorT end, - const PointDiT &old_base, std::array levels, - uint32_t last_axis); - - template - void EncodeInternal(RandomAccessIteratorT begin, RandomAccessIteratorT end, - PointDiT old_base, std::array levels, - uint32_t last_axis); - - class Splitter { - public: - Splitter(int axis, uint32_t value) : axis_(axis), value_(value) {} - bool operator()(const PointDiT &a) { return a[axis_] < value_; } - - private: - int axis_; - uint32_t value_; - }; - - void EncodeNumber(int nbits, uint32_t value) { - numbers_encoder_.EncodeLeastSignificantBits32(nbits, value); - } - - template - struct EncodingStatus { - EncodingStatus( - RandomAccessIteratorT begin_, RandomAccessIteratorT end_, - const PointDiT &old_base_, - std::array::Dimension()> levels_, - uint32_t last_axis_) - : begin(begin_), - end(end_), - old_base(old_base_), - levels(levels_), - last_axis(last_axis_) { - num_remaining_points = end - begin; - } - - RandomAccessIteratorT begin; - RandomAccessIteratorT end; - PointDiT old_base; - std::array levels; - uint32_t last_axis; - uint32_t num_remaining_points; - friend bool operator<(const EncodingStatus &l, const EncodingStatus &r) { - return l.num_remaining_points < r.num_remaining_points; - } - }; - - uint32_t bit_length_; - uint32_t num_points_; - NumbersEncoder numbers_encoder_; - RemainingBitsEncoder remaining_bits_encoder_; - AxisEncoder axis_encoder_; - HalfEncoder half_encoder_; -}; - -template -template -bool IntegerPointsKdTreeEncoder::EncodePoints( - RandomAccessIteratorT begin, RandomAccessIteratorT end, - const uint32_t &bit_length, EncoderBuffer *buffer) { - bit_length_ = bit_length; - num_points_ = end - begin; - - buffer->Encode(bit_length_); - buffer->Encode(num_points_); - if (num_points_ == 0) - return true; - - numbers_encoder_.StartEncoding(); - remaining_bits_encoder_.StartEncoding(); - axis_encoder_.StartEncoding(); - half_encoder_.StartEncoding(); - - EncodeInternal(begin, end, PointTraits::Origin(), - PointTraits::ZeroArray(), 0); - - numbers_encoder_.EndEncoding(buffer); - remaining_bits_encoder_.EndEncoding(buffer); - axis_encoder_.EndEncoding(buffer); - half_encoder_.EndEncoding(buffer); - - return true; -} -template -template -uint32_t IntegerPointsKdTreeEncoder::GetAxis( - RandomAccessIteratorT begin, RandomAccessIteratorT end, - const PointDiT &old_base, std::array levels, - uint32_t last_axis) { - if (!Policy::select_axis) - return DRACO_INCREMENT_MOD(last_axis, D); - - // For many points this function selects the axis that should be used - // for the split by keeping as many points as possible bundled. - // In the best case we do not split the point cloud at all. - // For lower number of points, we simply choose the axis that is refined the - // least so far. - - DRACO_DCHECK_EQ(true, end - begin != 0); - - uint32_t best_axis = 0; - if (end - begin < 64) { - for (uint32_t axis = 1; axis < D; ++axis) { - if (levels[best_axis] > levels[axis]) { - best_axis = axis; - } - } - } else { - const uint32_t size = (end - begin); - std::array num_remaining_bits = - PointTraits::ZeroArray(); - for (int i = 0; i < D; i++) { - num_remaining_bits[i] = bit_length_ - levels[i]; - } - PointDiT split(old_base); - - for (int i = 0; i < D; i++) { - if (num_remaining_bits[i]) - split[i] += 1 << (num_remaining_bits[i] - 1); - } - - std::array deviations = PointTraits::ZeroArray(); - for (auto it = begin; it != end; ++it) { - for (int i = 0; i < D; i++) { - deviations[i] += ((*it)[i] < split[i]); - } - } - for (int i = 0; i < D; i++) { - deviations[i] = std::max(size - deviations[i], deviations[i]); - } - - uint32_t max_value = 0; - best_axis = 0; - for (int i = 0; i < D; i++) { - // If axis can be subdivided. - if (num_remaining_bits[i]) { - // Check if this is the better axis. - if (max_value < deviations[i]) { - max_value = deviations[i]; - best_axis = i; - } - } - } - axis_encoder_.EncodeLeastSignificantBits32(4, best_axis); - } - - return best_axis; -} - -template -template -void IntegerPointsKdTreeEncoder::EncodeInternal( - RandomAccessIteratorT begin, RandomAccessIteratorT end, PointDiT old_base, - std::array levels, uint32_t last_axis) { - EncodingStatus init_status(begin, end, old_base, - levels, last_axis); - typename Policy::template QueuingStrategy< - EncodingStatus> - status_q; - - status_q.push(init_status); - - while (!status_q.empty()) { - EncodingStatus status = status_q.front(); - status_q.pop(); - - begin = status.begin; - end = status.end; - old_base = status.old_base; - levels = status.levels; - last_axis = status.last_axis; - - const uint32_t axis = GetAxis(begin, end, old_base, levels, last_axis); - const uint32_t level = levels[axis]; - const uint32_t num_remaining_points = end - begin; - - // If this happens all axis are subdivided to the end. - if ((bit_length_ - level) == 0) - continue; - - // Fast encoding of remaining bits if number of points is 1. - // Doing this also for 2 gives a slight additional speed up. - if (num_remaining_points <= 2) { - std::array axes; - axes[0] = axis; - for (int i = 1; i < D; i++) { - axes[i] = DRACO_INCREMENT_MOD(axes[i - 1], D); - } - - std::array num_remaining_bits; - for (int i = 0; i < D; i++) { - num_remaining_bits[i] = bit_length_ - levels[axes[i]]; - } - - for (uint32_t i = 0; i < num_remaining_points; ++i) { - const PointDiT &p = *(begin + i); - for (int j = 0; j < D; j++) { - if (num_remaining_bits[j]) { - remaining_bits_encoder_.EncodeLeastSignificantBits32( - num_remaining_bits[j], p[axes[j]]); - } - } - } - continue; - } - - const uint32_t num_remaining_bits = bit_length_ - level; - const uint32_t modifier = 1 << (num_remaining_bits - 1); - PointDiT new_base(old_base); - new_base[axis] += modifier; - const RandomAccessIteratorT split = - std::partition(begin, end, Splitter(axis, new_base[axis])); - - DRACO_DCHECK_EQ(true, (end - begin) > 0); - - // Encode number of points in first and second half. - const int required_bits = MostSignificantBit(num_remaining_points); - - const uint32_t first_half = split - begin; - const uint32_t second_half = end - split; - const bool left = first_half < second_half; - - if (first_half != second_half) - half_encoder_.EncodeBit(left); - - if (left) { - EncodeNumber(required_bits, num_remaining_points / 2 - first_half); - } else { - EncodeNumber(required_bits, num_remaining_points / 2 - second_half); - } - - levels[axis] += 1; - if (split != begin) - status_q.push(EncodingStatus( - begin, split, old_base, levels, axis)); - if (split != end) - status_q.push(EncodingStatus(split, end, new_base, - levels, axis)); - } -} - -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; -extern template class IntegerPointsKdTreeEncoder; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_INTEGER_POINTS_KD_TREE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h deleted file mode 100644 index 9541c96..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_COMPRESSION_METHOD_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_COMPRESSION_METHOD_H_ - -namespace draco { - -// Enum indicating the used compression method, used by Encoder and Decoder. -enum PointCloudCompressionMethod { - RESERVED_POINT_CLOUD_METHOD_0 = 0, // Reserved for internal use. - // Generalized version of Encoding using the Octree method by Olivier - // Devillers to d dimensions. - // "Progressive lossless compression of arbitrary simplicial complexes" - // https://doi.org/10.1145/566570.566591 - KDTREE = 1, - RESERVED_POINT_CLOUD_METHOD_2 = 2, // Reserved for internal use. - RESERVED_POINT_CLOUD_METHOD_3 = 0, // Reserved for internal use. -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_COMPRESSION_METHOD_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/point_cloud_types.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/point_cloud_types.h deleted file mode 100644 index 3ed1d13..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/point_cloud_types.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_TYPES_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_TYPES_H_ - -#include -#include - -#include "draco/core/vector_d.h" - -namespace draco { - -// Using Eigen as this is favored by project Cartographer. -typedef Vector3f Point3f; -typedef Vector4f Point4f; -typedef Vector3ui Point3ui; -typedef Vector4ui Point4ui; -typedef Vector5ui Point5ui; -typedef Vector6ui Point6ui; -typedef Vector7ui Point7ui; - -typedef std::vector PointCloud3f; - -template -struct PointDLess; - -template -struct PointDLess> { - bool operator()(const VectorD &a, - const VectorD &b) const { - return a < b; - } -}; - -template -class PointTraits {}; - -template -class PointTraits> { - public: - typedef VectorD PointD; - typedef CoordinateTypeT CoordinateType; - - static constexpr uint32_t Dimension() { return dimension_t; } - static PointD Origin() { - PointD origin; - for (uint32_t i = 0; i < dimension_t; i++) { - origin(i) = 0; - } - return origin; - } - static std::array ZeroArray() { - std::array zero; - for (uint32_t i = 0; i < dimension_t; i++) { - zero[i] = 0; - } - return zero; - } -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_TYPES_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/quantize_points_3.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/quantize_points_3.h deleted file mode 100644 index 7711730..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/quantize_points_3.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUANTIZE_POINTS_3_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUANTIZE_POINTS_3_H_ - -#include -#include "draco/compression/point_cloud/algorithms/point_cloud_types.h" -#include "draco/core/quantization_utils.h" - -namespace draco { - -// TODO(hemmer): Make this a stable bounding box. -struct QuantizationInfo { - uint32_t quantization_bits; - float range; -}; - -template -OutputIterator QuantizePoints3(const PointIterator &begin, - const PointIterator &end, QuantizationInfo *info, - OutputIterator oit) { - DRACO_DCHECK_GE(info->quantization_bits, 0); - - float max_range = 0; - for (auto it = begin; it != end; ++it) { - max_range = std::max(std::fabs((*it)[0]), max_range); - max_range = std::max(std::fabs((*it)[1]), max_range); - max_range = std::max(std::fabs((*it)[2]), max_range); - } - - const uint32_t max_quantized_value((1 << info->quantization_bits) - 1); - Quantizer quantize; - quantize.Init(max_range, max_quantized_value); - info->range = max_range; - - Point3ui qpoint; - for (auto it = begin; it != end; ++it) { - // Quantize and all positive. - qpoint[0] = quantize((*it)[0]) + max_quantized_value; - qpoint[1] = quantize((*it)[1]) + max_quantized_value; - qpoint[2] = quantize((*it)[2]) + max_quantized_value; - *oit++ = (qpoint); - } - - return oit; -} - -template -void DequantizePoints3(const QPointIterator &begin, const QPointIterator &end, - const QuantizationInfo &info, OutputIterator &oit) { - DRACO_DCHECK_GE(info.quantization_bits, 0); - DRACO_DCHECK_GE(info.range, 0); - - const uint32_t quantization_bits = info.quantization_bits; - const float range = info.range; - const uint32_t max_quantized_value((1 << quantization_bits) - 1); - Dequantizer dequantize; - dequantize.Init(range, max_quantized_value); - - for (auto it = begin; it != end; ++it) { - const float x = dequantize((*it)[0] - max_quantized_value); - const float y = dequantize((*it)[1] - max_quantized_value); - const float z = dequantize((*it)[2] - max_quantized_value); - *oit = Point3f(x, y, z); - ++oit; - } -} - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUANTIZE_POINTS_3_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/algorithms/queuing_policy.h b/cloudreg_env/include/draco/compression/point_cloud/algorithms/queuing_policy.h deleted file mode 100644 index 2db0ea2..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/algorithms/queuing_policy.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File defining a coherent interface for different queuing strategies. - -#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUEUING_POLICY_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUEUING_POLICY_H_ - -#include -#include -#include - -namespace draco { - -template -class Queue { - public: - bool empty() const { return q_.empty(); } - typename std::queue::size_type size() const { return q_.size(); } - void clear() { return q_.clear(); } - void push(const T &value) { q_.push(value); } - void push(T &&value) { q_.push(std::move(value)); } - void pop() { q_.pop(); } - typename std::queue::const_reference front() const { return q_.front(); } - - private: - std::queue q_; -}; - -template -class Stack { - public: - bool empty() const { return s_.empty(); } - typename std::stack::size_type size() const { return s_.size(); } - void clear() { return s_.clear(); } - void push(const T &value) { s_.push(value); } - void push(T &&value) { s_.push(std::move(value)); } - void pop() { s_.pop(); } - typename std::stack::const_reference front() const { return s_.top(); } - - private: - std::stack s_; -}; - -template > -class PriorityQueue { - typedef std::priority_queue, Compare> QType; - - public: - bool empty() const { return s_.empty(); } - typename QType::size_type size() const { return s_.size(); } - void clear() { return s_.clear(); } - void push(const T &value) { s_.push(value); } - void push(T &&value) { s_.push(std::move(value)); } - void pop() { s_.pop(); } - typename QType::const_reference front() const { return s_.top(); } - - private: - QType s_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_QUEUING_POLICY_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_decoder.h b/cloudreg_env/include/draco/compression/point_cloud/point_cloud_decoder.h deleted file mode 100644 index abcb5e0..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_decoder.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_DECODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_DECODER_H_ - -#include "draco/compression/attributes/attributes_decoder_interface.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/decoder_options.h" -#include "draco/core/status.h" -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -// Abstract base class for all point cloud and mesh decoders. It provides a -// basic functionality that is shared between different decoders. -class PointCloudDecoder { - public: - PointCloudDecoder(); - virtual ~PointCloudDecoder() = default; - - virtual EncodedGeometryType GetGeometryType() const { return POINT_CLOUD; } - - // Decodes a Draco header int other provided |out_header|. - // Returns false on error. - static Status DecodeHeader(DecoderBuffer *buffer, DracoHeader *out_header); - - // The main entry point for point cloud decoding. - Status Decode(const DecoderOptions &options, DecoderBuffer *in_buffer, - PointCloud *out_point_cloud); - - bool SetAttributesDecoder( - int att_decoder_id, std::unique_ptr decoder) { - if (att_decoder_id < 0) - return false; - if (att_decoder_id >= static_cast(attributes_decoders_.size())) - attributes_decoders_.resize(att_decoder_id + 1); - attributes_decoders_[att_decoder_id] = std::move(decoder); - return true; - } - - // Returns an attribute containing decoded data in their portable form that - // is guaranteed to be the same for both encoder and decoder. I.e., it returns - // an attribute before it was transformed back into its final form which may - // be slightly different (non-portable) across platforms. For example, for - // attributes encoded with quantization, this method returns an attribute - // that contains the quantized values (before the dequantization step). - const PointAttribute *GetPortableAttribute(int32_t point_attribute_id); - - uint16_t bitstream_version() const { - return DRACO_BITSTREAM_VERSION(version_major_, version_minor_); - } - - const AttributesDecoderInterface *attributes_decoder(int dec_id) { - return attributes_decoders_[dec_id].get(); - } - int32_t num_attributes_decoders() const { - return static_cast(attributes_decoders_.size()); - } - - // Get a mutable pointer to the decoded point cloud. This is intended to be - // used mostly by other decoder subsystems. - PointCloud *point_cloud() { return point_cloud_; } - const PointCloud *point_cloud() const { return point_cloud_; } - - DecoderBuffer *buffer() { return buffer_; } - const DecoderOptions *options() const { return options_; } - - protected: - // Can be implemented by derived classes to perform any custom initialization - // of the decoder. Called in the Decode() method. - virtual bool InitializeDecoder() { return true; } - - // Creates an attribute decoder. - virtual bool CreateAttributesDecoder(int32_t att_decoder_id) = 0; - virtual bool DecodeGeometryData() { return true; } - virtual bool DecodePointAttributes(); - - virtual bool DecodeAllAttributes(); - virtual bool OnAttributesDecoded() { return true; } - - Status DecodeMetadata(); - - private: - // Point cloud that is being filled in by the decoder. - PointCloud *point_cloud_; - - std::vector> attributes_decoders_; - - // Map between attribute id and decoder id. - std::vector attribute_to_decoder_map_; - - // Input buffer holding the encoded data. - DecoderBuffer *buffer_; - - // Bit-stream version of the encoder that encoded the input data. - uint8_t version_major_; - uint8_t version_minor_; - - const DecoderOptions *options_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_encoder.h b/cloudreg_env/include/draco/compression/point_cloud/point_cloud_encoder.h deleted file mode 100644 index 8883f17..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_encoder.h +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_ENCODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_ENCODER_H_ - -#include "draco/compression/attributes/attributes_encoder.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/encoder_options.h" -#include "draco/core/encoder_buffer.h" -#include "draco/core/status.h" -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -// Abstract base class for all point cloud and mesh encoders. It provides a -// basic functionality that's shared between different encoders. -class PointCloudEncoder { - public: - PointCloudEncoder(); - virtual ~PointCloudEncoder() = default; - - // Sets the point cloud that is going be encoded. Must be called before the - // Encode() method. - void SetPointCloud(const PointCloud &pc); - - // The main entry point that encodes provided point cloud. - Status Encode(const EncoderOptions &options, EncoderBuffer *out_buffer); - - virtual EncodedGeometryType GetGeometryType() const { return POINT_CLOUD; } - - // Returns the unique identifier of the encoding method (such as Edgebreaker - // for mesh compression). - virtual uint8_t GetEncodingMethod() const = 0; - - // Returns the number of points that were encoded during the last Encode() - // function call. Valid only if "store_number_of_encoded_points" flag was set - // in the provided EncoderOptions. - size_t num_encoded_points() const { return num_encoded_points_; } - - int num_attributes_encoders() const { - return static_cast(attributes_encoders_.size()); - } - AttributesEncoder *attributes_encoder(int i) { - return attributes_encoders_[i].get(); - } - - // Adds a new attribute encoder, returning its id. - int AddAttributesEncoder(std::unique_ptr att_enc) { - attributes_encoders_.push_back(std::move(att_enc)); - return static_cast(attributes_encoders_.size() - 1); - } - - // Marks one attribute as a parent of another attribute. Must be called after - // all attribute encoders are created (usually in the - // AttributeEncoder::Init() method). - bool MarkParentAttribute(int32_t parent_att_id); - - // Returns an attribute containing portable version of the attribute data that - // is guaranteed to be encoded losslessly. This attribute can be used safely - // as predictor for other attributes. - const PointAttribute *GetPortableAttribute(int32_t point_attribute_id); - - EncoderBuffer *buffer() { return buffer_; } - const EncoderOptions *options() const { return options_; } - const PointCloud *point_cloud() const { return point_cloud_; } - - protected: - // Can be implemented by derived classes to perform any custom initialization - // of the encoder. Called in the Encode() method. - virtual bool InitializeEncoder() { return true; } - - // Should be used to encode any encoder-specific data. - virtual bool EncodeEncoderData() { return true; } - - // Encodes any global geometry data (such as the number of points). - virtual Status EncodeGeometryData() { return OkStatus(); } - - // encode all attribute values. The attribute encoders are sorted to resolve - // any attribute dependencies and all the encoded data is stored into the - // |buffer_|. - // Returns false if the encoding failed. - virtual bool EncodePointAttributes(); - - // Generate attribute encoders that are going to be used for encoding - // point attribute data. Calls GenerateAttributesEncoder() for every attribute - // of the encoded PointCloud. - virtual bool GenerateAttributesEncoders(); - - // Creates attribute encoder for a specific point attribute. This function - // needs to be implemented by the derived classes. The derived classes need - // to either 1. Create a new attribute encoder and add it using the - // AddAttributeEncoder method, or 2. add the attribute to an existing - // attribute encoder (using AttributesEncoder::AddAttributeId() method). - virtual bool GenerateAttributesEncoder(int32_t att_id) = 0; - - // Encodes any data that is necessary to recreate a given attribute encoder. - // Note: this is called in order in which the attribute encoders are going to - // be encoded. - virtual bool EncodeAttributesEncoderIdentifier(int32_t /* att_encoder_id */) { - return true; - } - - // Encodes all the attribute data using the created attribute encoders. - virtual bool EncodeAllAttributes(); - - // Computes and sets the num_encoded_points_ for the encoder. - virtual void ComputeNumberOfEncodedPoints() = 0; - - void set_num_encoded_points(size_t num_points) { - num_encoded_points_ = num_points; - } - - private: - // Encodes Draco header that is the same for all encoders. - Status EncodeHeader(); - - // Encode metadata. - Status EncodeMetadata(); - - // Rearranges attribute encoders and their attributes to reflect the - // underlying attribute dependencies. This ensures that the attributes are - // encoded in the correct order (parent attributes before their children). - bool RearrangeAttributesEncoders(); - - const PointCloud *point_cloud_; - std::vector> attributes_encoders_; - - // Map between attribute id and encoder id. - std::vector attribute_to_encoder_map_; - - // Encoding order of individual attribute encoders (i.e., the order in which - // they are processed during encoding that may be different from the order - // in which they were created because of attribute dependencies. - std::vector attributes_encoder_ids_order_; - - // This buffer holds the final encoded data. - EncoderBuffer *buffer_; - - const EncoderOptions *options_; - - size_t num_encoded_points_; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h b/cloudreg_env/include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h deleted file mode 100644 index 6e192f2..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_KD_TREE_DECODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_KD_TREE_DECODER_H_ - -#include "draco/compression/point_cloud/point_cloud_decoder.h" - -namespace draco { - -// Decodes PointCloud encoded with the PointCloudKdTreeEncoder. -class PointCloudKdTreeDecoder : public PointCloudDecoder { - protected: - bool DecodeGeometryData() override; - bool CreateAttributesDecoder(int32_t att_decoder_id) override; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_KD_TREE_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h b/cloudreg_env/include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h deleted file mode 100644 index 6acbb94..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_KD_TREE_ENCODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_KD_TREE_ENCODER_H_ - -#include "draco/compression/point_cloud/point_cloud_encoder.h" - -namespace draco { - -// Encodes a PointCloud using one of the available Kd-tree compression methods. -// See FloatPointsKdTreeEncoder and DynamicIntegerPointsKdTreeEncoder for more -// details. Currently, the input PointCloud must satisfy the following -// requirements to use this encoder: -// 1. PointCloud has only one attribute of type GeometryAttribute::POSITION. -// 2. The position attribute has three components (x,y,z). -// 3. The position values are stored as either DT_FLOAT32 or DT_UINT32. -// 4. If the position values are stored as DT_FLOAT32, quantization needs to -// be enabled for the position attribute. -class PointCloudKdTreeEncoder : public PointCloudEncoder { - public: - uint8_t GetEncodingMethod() const override { - return POINT_CLOUD_KD_TREE_ENCODING; - } - - protected: - Status EncodeGeometryData() override; - bool GenerateAttributesEncoder(int32_t att_id) override; - void ComputeNumberOfEncodedPoints() override; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_KD_TREE_ENCODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_sequential_decoder.h b/cloudreg_env/include/draco/compression/point_cloud/point_cloud_sequential_decoder.h deleted file mode 100644 index 9968dc2..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_sequential_decoder.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_SEQUENTIAL_DECODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_SEQUENTIAL_DECODER_H_ - -#include "draco/compression/point_cloud/point_cloud_decoder.h" - -namespace draco { - -// Point cloud decoder for data encoded by the PointCloudSequentialEncoder. -// All attribute values are decoded using an identity mapping between point ids -// and attribute value ids. -class PointCloudSequentialDecoder : public PointCloudDecoder { - protected: - bool DecodeGeometryData() override; - bool CreateAttributesDecoder(int32_t att_decoder_id) override; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_SEQUENTIAL_DECODER_H_ diff --git a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_sequential_encoder.h b/cloudreg_env/include/draco/compression/point_cloud/point_cloud_sequential_encoder.h deleted file mode 100644 index 40d8edc..0000000 --- a/cloudreg_env/include/draco/compression/point_cloud/point_cloud_sequential_encoder.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_SEQUENTIAL_ENCODER_H_ -#define DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_SEQUENTIAL_ENCODER_H_ - -#include "draco/compression/point_cloud/point_cloud_encoder.h" - -namespace draco { - -// A basic point cloud encoder that iterates over all points and encodes all -// attribute values for every visited point. The attribute values encoding -// can be controlled using provided encoding option to enable features such -// as quantization or prediction schemes. -// This encoder preserves the order and the number of input points, but the -// mapping between point ids and attribute values may be different for the -// decoded point cloud. -class PointCloudSequentialEncoder : public PointCloudEncoder { - public: - uint8_t GetEncodingMethod() const override { - return POINT_CLOUD_SEQUENTIAL_ENCODING; - } - - protected: - Status EncodeGeometryData() override; - bool GenerateAttributesEncoder(int32_t att_id) override; - void ComputeNumberOfEncodedPoints() override; -}; - -} // namespace draco - -#endif // DRACO_COMPRESSION_POINT_CLOUD_POINT_CLOUD_SEQUENTIAL_ENCODER_H_ diff --git a/cloudreg_env/include/draco/core/bit_utils.h b/cloudreg_env/include/draco/core/bit_utils.h deleted file mode 100644 index f63cd07..0000000 --- a/cloudreg_env/include/draco/core/bit_utils.h +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File containing a basic set of bit manipulation utilities used within the -// Draco library. - -#ifndef DRACO_CORE_BIT_UTILS_H_ -#define DRACO_CORE_BIT_UTILS_H_ - -#include -#include -#include - -#if defined(_MSC_VER) -#include -#endif // defined(_MSC_VER) - -namespace draco { - -// Returns the number of '1' bits within the input 32 bit integer. -inline int CountOneBits32(uint32_t n) { - n -= ((n >> 1) & 0x55555555); - n = ((n >> 2) & 0x33333333) + (n & 0x33333333); - return (((n + (n >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; -} - -inline uint32_t ReverseBits32(uint32_t n) { - n = ((n >> 1) & 0x55555555) | ((n & 0x55555555) << 1); - n = ((n >> 2) & 0x33333333) | ((n & 0x33333333) << 2); - n = ((n >> 4) & 0x0F0F0F0F) | ((n & 0x0F0F0F0F) << 4); - n = ((n >> 8) & 0x00FF00FF) | ((n & 0x00FF00FF) << 8); - return (n >> 16) | (n << 16); -} - -// Copies the |nbits| from the src integer into the |dst| integer using the -// provided bit offsets |dst_offset| and |src_offset|. -inline void CopyBits32(uint32_t *dst, int dst_offset, uint32_t src, - int src_offset, int nbits) { - const uint32_t mask = (~static_cast(0)) >> (32 - nbits) - << dst_offset; - *dst = (*dst & (~mask)) | (((src >> src_offset) << dst_offset) & mask); -} - -// Returns the location of the most significant bit in the input integer |n|. -// The functionality is not defined for |n == 0|. -inline int MostSignificantBit(uint32_t n) { -#if defined(__GNUC__) - return 31 ^ __builtin_clz(n); -#elif defined(_MSC_VER) - - unsigned long where; - _BitScanReverse(&where, n); - return (int)where; -#else - // TODO(fgalligan): Optimize this code. - int msb = -1; - while (n != 0) { - msb++; - n >>= 1; - } - return msb; -#endif -} - -// Helper function that converts signed integer values into unsigned integer -// symbols that can be encoded using an entropy encoder. -void ConvertSignedIntsToSymbols(const int32_t *in, int in_values, - uint32_t *out); - -// Converts unsigned integer symbols encoded with an entropy encoder back to -// signed values. -void ConvertSymbolsToSignedInts(const uint32_t *in, int in_values, - int32_t *out); - -// Helper function that converts a single signed integer value into an unsigned -// integer symbol that can be encoded using an entropy encoder. -template -typename std::make_unsigned::type ConvertSignedIntToSymbol( - IntTypeT val) { - typedef typename std::make_unsigned::type UnsignedType; - static_assert(std::is_integral::value, "IntTypeT is not integral."); - // Early exit if val is positive. - if (val >= 0) { - return static_cast(val) << 1; - } - val = -(val + 1); // Map -1 to 0, -2 to -1, etc.. - UnsignedType ret = static_cast(val); - ret <<= 1; - ret |= 1; - return ret; -} - -// Converts a single unsigned integer symbol encoded with an entropy encoder -// back to a signed value. -template -typename std::make_signed::type ConvertSymbolToSignedInt( - IntTypeT val) { - static_assert(std::is_integral::value, "IntTypeT is not integral."); - typedef typename std::make_signed::type SignedType; - const bool is_positive = !static_cast(val & 1); - val >>= 1; - if (is_positive) { - return static_cast(val); - } - SignedType ret = static_cast(val); - ret = -ret - 1; - return ret; -} - -} // namespace draco - -#endif // DRACO_CORE_BIT_UTILS_H_ diff --git a/cloudreg_env/include/draco/core/bounding_box.h b/cloudreg_env/include/draco/core/bounding_box.h deleted file mode 100644 index 0259267..0000000 --- a/cloudreg_env/include/draco/core/bounding_box.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2018 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_BOUNDING_BOX_H_ -#define DRACO_CORE_BOUNDING_BOX_H_ - -#include "draco/core/vector_d.h" - -namespace draco { - -// Class for detecting the bounding box of a point_cloud or mesh. -// Use the minimum point and the maximum point to define the bounding box. -// TODO(xiaoxumeng): Change the class of BoundingBox to a template, similar to -// draco/src/draco/core/vector_d.h -class BoundingBox { - public: - // Initialization - BoundingBox(const Vector3f &min_point_in, const Vector3f &max_point_in); - - inline const Vector3f &min_point() const { return min_point_; } - inline const Vector3f &max_point() const { return max_point_; } - - // Conditionally updates the bounding box. - // TODO(xiaoxumeng): Change the function to a template function and change the - // argument to an iterator. - inline void update_bounding_box(const Vector3f &new_point) { - for (int i = 0; i < 3; i++) { - if (new_point[i] < min_point_[i]) - min_point_[i] = new_point[i]; - if (new_point[i] > max_point_[i]) - max_point_[i] = new_point[i]; - } - } - - private: - Vector3f min_point_; - Vector3f max_point_; -}; -} // namespace draco - -#endif // DRACO_CORE_BOUNDING_BOX_H_ diff --git a/cloudreg_env/include/draco/core/cycle_timer.h b/cloudreg_env/include/draco/core/cycle_timer.h deleted file mode 100644 index 172f1c2..0000000 --- a/cloudreg_env/include/draco/core/cycle_timer.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_CYCLE_TIMER_H_ -#define DRACO_CORE_CYCLE_TIMER_H_ - -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -typedef LARGE_INTEGER timeval; -#else -#include -#endif - -#include -#include - -namespace draco { - -class DracoTimer { - public: - DracoTimer() {} - ~DracoTimer() {} - void Start(); - void Stop(); - int64_t GetInMs(); - - private: - timeval tv_start; - timeval tv_end; -}; - -typedef DracoTimer CycleTimer; - -} // namespace draco - -#endif // DRACO_CORE_CYCLE_TIMER_H_ diff --git a/cloudreg_env/include/draco/core/data_buffer.h b/cloudreg_env/include/draco/core/data_buffer.h deleted file mode 100644 index 8ee6905..0000000 --- a/cloudreg_env/include/draco/core/data_buffer.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DATA_BUFFER_H_ -#define DRACO_CORE_DATA_BUFFER_H_ - -#include -#include -#include - -#include "draco/core/draco_types.h" - -namespace draco { - -// Buffer descriptor servers as a unique identifier of a buffer. -struct DataBufferDescriptor { - DataBufferDescriptor() : buffer_id(0), buffer_update_count(0) {} - // Id of the data buffer. - int64_t buffer_id; - // The number of times the buffer content was updated. - int64_t buffer_update_count; -}; - -// Class used for storing raw buffer data. -class DataBuffer { - public: - DataBuffer(); - bool Update(const void *data, int64_t size); - bool Update(const void *data, int64_t size, int64_t offset); - - // Reallocate the buffer storage to a new size keeping the data unchanged. - void Resize(int64_t new_size); - void WriteDataToStream(std::ostream &stream); - // Reads data from the buffer. Potentially unsafe, called needs to ensure - // the accessed memory is valid. - void Read(int64_t byte_pos, void *out_data, size_t data_size) const { - memcpy(out_data, data() + byte_pos, data_size); - } - - // Writes data to the buffer. Unsafe, caller must ensure the accessed memory - // is valid. - void Write(int64_t byte_pos, const void *in_data, size_t data_size) { - memcpy(const_cast(data()) + byte_pos, in_data, data_size); - } - - // Copies data from another buffer to this buffer. - void Copy(int64_t dst_offset, const DataBuffer *src_buf, int64_t src_offset, - int64_t size) { - memcpy(const_cast(data()) + dst_offset, - src_buf->data() + src_offset, size); - } - - void set_update_count(int64_t buffer_update_count) { - descriptor_.buffer_update_count = buffer_update_count; - } - int64_t update_count() const { return descriptor_.buffer_update_count; } - size_t data_size() const { return data_.size(); } - const uint8_t *data() const { return data_.data(); } - uint8_t *data() { return &data_[0]; } - int64_t buffer_id() const { return descriptor_.buffer_id; } - void set_buffer_id(int64_t buffer_id) { descriptor_.buffer_id = buffer_id; } - - private: - std::vector data_; - // Counter incremented by Update() calls. - DataBufferDescriptor descriptor_; -}; - -} // namespace draco - -#endif // DRACO_CORE_DATA_BUFFER_H_ diff --git a/cloudreg_env/include/draco/core/decoder_buffer.h b/cloudreg_env/include/draco/core/decoder_buffer.h deleted file mode 100644 index 5e3d1ac..0000000 --- a/cloudreg_env/include/draco/core/decoder_buffer.h +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DECODER_BUFFER_H_ -#define DRACO_CORE_DECODER_BUFFER_H_ - -#include -#include -#include - -#include "draco/draco_features.h" - -#include "draco/core/macros.h" - -namespace draco { - -// Class is a wrapper around input data used by MeshDecoder. It provides a -// basic interface for decoding either typed or variable-bit sized data. -class DecoderBuffer { - public: - DecoderBuffer(); - DecoderBuffer(const DecoderBuffer &buf) = default; - - DecoderBuffer &operator=(const DecoderBuffer &buf) = default; - - // Sets the buffer's internal data. Note that no copy of the input data is - // made so the data owner needs to keep the data valid and unchanged for - // runtime of the decoder. - void Init(const char *data, size_t data_size); - - // Sets the buffer's internal data. |version| is the Draco bitstream version. - void Init(const char *data, size_t data_size, uint16_t version); - - // Starts decoding a bit sequence. - // decode_size must be true if the size of the encoded bit data was included, - // during encoding. The size is then returned to out_size. - // Returns false on error. - bool StartBitDecoding(bool decode_size, uint64_t *out_size); - - // Ends the decoding of the bit sequence and return to the default - // byte-aligned decoding. - void EndBitDecoding(); - - // Decodes up to 32 bits into out_val. Can be called only in between - // StartBitDecoding and EndBitDecoding. Otherwise returns false. - bool DecodeLeastSignificantBits32(int nbits, uint32_t *out_value) { - if (!bit_decoder_active()) - return false; - bit_decoder_.GetBits(nbits, out_value); - return true; - } - - // Decodes an arbitrary data type. - // Can be used only when we are not decoding a bit-sequence. - // Returns false on error. - template - bool Decode(T *out_val) { - if (!Peek(out_val)) - return false; - pos_ += sizeof(T); - return true; - } - - bool Decode(void *out_data, size_t size_to_decode) { - if (data_size_ < static_cast(pos_ + size_to_decode)) - return false; // Buffer overflow. - memcpy(out_data, (data_ + pos_), size_to_decode); - pos_ += size_to_decode; - return true; - } - - // Decodes an arbitrary data, but does not advance the reading position. - template - bool Peek(T *out_val) { - const size_t size_to_decode = sizeof(T); - if (data_size_ < static_cast(pos_ + size_to_decode)) - return false; // Buffer overflow. - memcpy(out_val, (data_ + pos_), size_to_decode); - return true; - } - - bool Peek(void *out_data, size_t size_to_peek) { - if (data_size_ < static_cast(pos_ + size_to_peek)) - return false; // Buffer overflow. - memcpy(out_data, (data_ + pos_), size_to_peek); - return true; - } - - // Discards #bytes from the input buffer. - void Advance(int64_t bytes) { pos_ += bytes; } - - // Moves the parsing position to a specific offset from the beginning of the - // input data. - void StartDecodingFrom(int64_t offset) { pos_ = offset; } - - void set_bitstream_version(uint16_t version) { bitstream_version_ = version; } - - // Returns the data array at the current decoder position. - const char *data_head() const { return data_ + pos_; } - int64_t remaining_size() const { return data_size_ - pos_; } - int64_t decoded_size() const { return pos_; } - bool bit_decoder_active() const { return bit_mode_; } - - // Returns the bitstream associated with the data. Returns 0 if unknown. - uint16_t bitstream_version() const { return bitstream_version_; } - - private: - // Internal helper class to decode bits from a bit buffer. - class BitDecoder { - public: - BitDecoder(); - ~BitDecoder(); - - // Sets the bit buffer to |b|. |s| is the size of |b| in bytes. - inline void reset(const void *b, size_t s) { - bit_offset_ = 0; - bit_buffer_ = static_cast(b); - bit_buffer_end_ = bit_buffer_ + s; - } - - // Returns number of bits decoded so far. - inline uint64_t BitsDecoded() const { - return static_cast(bit_offset_); - } - - // Return number of bits available for decoding - inline uint64_t AvailBits() const { - return ((bit_buffer_end_ - bit_buffer_) * 8) - bit_offset_; - } - - inline uint32_t EnsureBits(int k) { - DRACO_DCHECK_LE(k, 24); - DRACO_DCHECK_LE(static_cast(k), AvailBits()); - - uint32_t buf = 0; - for (int i = 0; i < k; ++i) { - buf |= PeekBit(i) << i; - } - return buf; // Okay to return extra bits - } - - inline void ConsumeBits(int k) { bit_offset_ += k; } - - // Returns |nbits| bits in |x|. - inline bool GetBits(int32_t nbits, uint32_t *x) { - DRACO_DCHECK_GE(nbits, 0); - DRACO_DCHECK_LE(nbits, 32); - uint32_t value = 0; - for (int32_t bit = 0; bit < nbits; ++bit) - value |= GetBit() << bit; - *x = value; - return true; - } - - private: - // TODO(fgalligan): Add support for error reporting on range check. - // Returns one bit from the bit buffer. - inline int GetBit() { - const size_t off = bit_offset_; - const size_t byte_offset = off >> 3; - const int bit_shift = static_cast(off & 0x7); - if (bit_buffer_ + byte_offset < bit_buffer_end_) { - const int bit = (bit_buffer_[byte_offset] >> bit_shift) & 1; - bit_offset_ = off + 1; - return bit; - } - return 0; - } - - inline int PeekBit(int offset) { - const size_t off = bit_offset_ + offset; - const size_t byte_offset = off >> 3; - const int bit_shift = static_cast(off & 0x7); - if (bit_buffer_ + byte_offset < bit_buffer_end_) { - const int bit = (bit_buffer_[byte_offset] >> bit_shift) & 1; - return bit; - } - return 0; - } - - const uint8_t *bit_buffer_; - const uint8_t *bit_buffer_end_; - size_t bit_offset_; - }; - friend class BufferBitCodingTest; - - const char *data_; - int64_t data_size_; - - // Current parsing position of the decoder. - int64_t pos_; - BitDecoder bit_decoder_; - bool bit_mode_; - uint16_t bitstream_version_; -}; - -} // namespace draco - -#endif // DRACO_CORE_DECODER_BUFFER_H_ diff --git a/cloudreg_env/include/draco/core/divide.h b/cloudreg_env/include/draco/core/divide.h deleted file mode 100644 index 2217c86..0000000 --- a/cloudreg_env/include/draco/core/divide.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DIVIDE_H_ -#define DRACO_CORE_DIVIDE_H_ -// An implementation of the divide by multiply algorithm -// https://gmplib.org/~tege/divcnst-pldi94.pdf -// This file is based off libvpx's divide.h. - -#include -#include - -namespace draco { - -struct fastdiv_elem { - unsigned mult; - unsigned shift; -}; - -extern const struct fastdiv_elem vp10_fastdiv_tab[256]; - -static inline unsigned fastdiv(unsigned x, int y) { - unsigned t = - ((uint64_t)x * vp10_fastdiv_tab[y].mult) >> (sizeof(x) * CHAR_BIT); - return (t + x) >> vp10_fastdiv_tab[y].shift; -} - -} // namespace draco - -#endif // DRACO_CORE_DIVIDE_H_ diff --git a/cloudreg_env/include/draco/core/draco_index_type.h b/cloudreg_env/include/draco/core/draco_index_type.h deleted file mode 100644 index d9dd3f6..0000000 --- a/cloudreg_env/include/draco/core/draco_index_type.h +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// This files provides a basic framework for strongly typed indices that are -// used within the Draco library. The motivation of using strongly typed indices -// is to prevent bugs caused by mixing up incompatible indices, such as indexing -// mesh faces with point indices and vice versa. -// -// Usage: -// Define strongly typed index using macro: -// -// DEFINE_NEW_DRACO_INDEX_TYPE(value_type, name) -// -// where |value_type| is the data type of the index value (such as int32_t) -// and |name| is a unique typename of the new index. -// -// E.g., we can define new index types as: -// -// DEFINE_NEW_DRACO_INDEX_TYPE(int, PointIndex) -// DEFINE_NEW_DRACO_INDEX_TYPE(int, FaceIndex) -// -// The new types can then be used in the similar way as the regular weakly -// typed indices (such as int32, int64, ...), but they cannot be -// accidentally misassigned. E.g.: -// -// PointIndex point_index(10); -// FaceIndex face_index; -// face_index = point_index; // Compile error! -// -// One can still cast one type to another explicitly by accessing the index -// value directly using the .value() method: -// -// face_index = FaceIndex(point_index.value()); // Compiles OK. -// -// Strongly typed indices support most of the common binary and unary -// operators and support for additional operators can be added if -// necessary. - -#ifndef DRACO_CORE_DRACO_INDEX_TYPE_H_ -#define DRACO_CORE_DRACO_INDEX_TYPE_H_ - -#include - -#include "draco/draco_features.h" - -namespace draco { - -#define DEFINE_NEW_DRACO_INDEX_TYPE(value_type, name) \ - struct name##_tag_type_ {}; \ - typedef IndexType name; - -template -class IndexType { - public: - typedef IndexType ThisIndexType; - typedef ValueTypeT ValueType; - - constexpr IndexType() : value_(ValueTypeT()) {} - constexpr explicit IndexType(ValueTypeT value) : value_(value) {} - - constexpr ValueTypeT value() const { return value_; } - - constexpr bool operator==(const IndexType &i) const { - return value_ == i.value_; - } - constexpr bool operator==(const ValueTypeT &val) const { - return value_ == val; - } - constexpr bool operator!=(const IndexType &i) const { - return value_ != i.value_; - } - constexpr bool operator!=(const ValueTypeT &val) const { - return value_ != val; - } - constexpr bool operator<(const IndexType &i) const { - return value_ < i.value_; - } - constexpr bool operator<(const ValueTypeT &val) const { return value_ < val; } - constexpr bool operator>(const IndexType &i) const { - return value_ > i.value_; - } - constexpr bool operator>(const ValueTypeT &val) const { return value_ > val; } - constexpr bool operator>=(const IndexType &i) const { - return value_ >= i.value_; - } - constexpr bool operator>=(const ValueTypeT &val) const { - return value_ >= val; - } - - inline ThisIndexType &operator++() { - ++value_; - return *this; - } - inline ThisIndexType operator++(int) { - const ThisIndexType ret(value_); - ++value_; - return ret; - } - - inline ThisIndexType &operator--() { - --value_; - return *this; - } - inline ThisIndexType operator--(int) { - const ThisIndexType ret(value_); - --value_; - return ret; - } - - constexpr ThisIndexType operator+(const IndexType &i) const { - return ThisIndexType(value_ + i.value_); - } - constexpr ThisIndexType operator+(const ValueTypeT &val) const { - return ThisIndexType(value_ + val); - } - constexpr ThisIndexType operator-(const IndexType &i) const { - return ThisIndexType(value_ - i.value_); - } - constexpr ThisIndexType operator-(const ValueTypeT &val) const { - return ThisIndexType(value_ - val); - } - - inline ThisIndexType &operator+=(const IndexType &i) { - value_ += i.value_; - return *this; - } - inline ThisIndexType operator+=(const ValueTypeT &val) { - value_ += val; - return *this; - } - inline ThisIndexType &operator-=(const IndexType &i) { - value_ -= i.value_; - return *this; - } - inline ThisIndexType operator-=(const ValueTypeT &val) { - value_ -= val; - return *this; - } - inline ThisIndexType &operator=(const ThisIndexType &i) { - value_ = i.value_; - return *this; - } - inline ThisIndexType &operator=(const ValueTypeT &val) { - value_ = val; - return *this; - } - - private: - ValueTypeT value_; -}; - -// Stream operator << provided for logging purposes. -template -std::ostream &operator<<(std::ostream &os, IndexType index) { - return os << index.value(); -} - -} // namespace draco - -// Specialize std::hash for the strongly indexed types. -namespace std { - -template -struct hash> { - size_t operator()(const draco::IndexType &i) const { - return static_cast(i.value()); - } -}; - -} // namespace std - -#endif // DRACO_CORE_DRACO_INDEX_TYPE_H_ diff --git a/cloudreg_env/include/draco/core/draco_index_type_vector.h b/cloudreg_env/include/draco/core/draco_index_type_vector.h deleted file mode 100644 index e2062ef..0000000 --- a/cloudreg_env/include/draco/core/draco_index_type_vector.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DRACO_INDEX_TYPE_VECTOR_H_ -#define DRACO_CORE_DRACO_INDEX_TYPE_VECTOR_H_ - -#include -#include -#include - -#include "draco/core/draco_index_type.h" - -namespace draco { - -// A wrapper around the standard std::vector that supports indexing of the -// vector entries using the strongly typed indices as defined in -// draco_index_type.h . -// TODO(ostava): Make the interface more complete. It's currently missing -// features such as iterators. -// TODO(draco-eng): Make unit tests for this class. -template -class IndexTypeVector { - public: - typedef typename std::vector::const_reference const_reference; - typedef typename std::vector::reference reference; - - IndexTypeVector() {} - explicit IndexTypeVector(size_t size) : vector_(size) {} - IndexTypeVector(size_t size, const ValueTypeT &val) : vector_(size, val) {} - - void clear() { vector_.clear(); } - void reserve(size_t size) { vector_.reserve(size); } - void resize(size_t size) { vector_.resize(size); } - void resize(size_t size, const ValueTypeT &val) { vector_.resize(size, val); } - void assign(size_t size, const ValueTypeT &val) { vector_.assign(size, val); } - - void swap(IndexTypeVector &arg) { - vector_.swap(arg.vector_); - } - - size_t size() const { return vector_.size(); } - - void push_back(const ValueTypeT &val) { vector_.push_back(val); } - void push_back(ValueTypeT &&val) { vector_.push_back(std::move(val)); } - - inline reference operator[](const IndexTypeT &index) { - return vector_[index.value()]; - } - inline const_reference operator[](const IndexTypeT &index) const { - return vector_[index.value()]; - } - inline reference at(const IndexTypeT &index) { - return vector_[index.value()]; - } - inline const_reference at(const IndexTypeT &index) const { - return vector_[index.value()]; - } - const ValueTypeT *data() const { return vector_.data(); } - - private: - std::vector vector_; -}; - -} // namespace draco - -#endif // DRACO_CORE_DRACO_INDEX_TYPE_VECTOR_H_ diff --git a/cloudreg_env/include/draco/core/draco_test_base.h b/cloudreg_env/include/draco/core/draco_test_base.h deleted file mode 100644 index f5c9d75..0000000 --- a/cloudreg_env/include/draco/core/draco_test_base.h +++ /dev/null @@ -1,11 +0,0 @@ -// Wrapper for including googletest indirectly. Useful when the location of the -// googletest sources must change depending on build environment and repository -// source location. -#ifndef DRACO_CORE_DRACO_TEST_BASE_H_ -#define DRACO_CORE_DRACO_TEST_BASE_H_ - -static bool FLAGS_update_golden_files; -#include "gtest/gtest.h" -#include "testing/draco_test_config.h" - -#endif // DRACO_CORE_DRACO_TEST_BASE_H_ diff --git a/cloudreg_env/include/draco/core/draco_test_utils.h b/cloudreg_env/include/draco/core/draco_test_utils.h deleted file mode 100644 index 3113a5d..0000000 --- a/cloudreg_env/include/draco/core/draco_test_utils.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DRACO_TEST_UTILS_H_ -#define DRACO_CORE_DRACO_TEST_UTILS_H_ - -#include "draco/core/draco_test_base.h" -#include "draco/io/mesh_io.h" -#include "draco/io/point_cloud_io.h" - -namespace draco { - -// Returns the full path to a given file system entry, such as test file or test -// directory. -std::string GetTestFileFullPath(const std::string &entry_name); - -// Returns the full path to a given temporary file (a location where tests store -// generated files). -std::string GetTestTempFileFullPath(const std::string &file_name); - -// Generates a new golden file and saves it into the correct folder. -// Returns false if the file couldn't be created. -bool GenerateGoldenFile(const std::string &golden_file_name, const void *data, - int data_size); - -// Compare a golden file content with the input data. -// Function will log the first byte position where the data differ. -// Returns false if there are any differences. -bool CompareGoldenFile(const std::string &golden_file_name, const void *data, - int data_size); - -// Loads a mesh / point cloud specified by a |file_name| that is going to be -// automatically converted to the correct path available to the testing -// instance. -inline std::unique_ptr ReadMeshFromTestFile( - const std::string &file_name) { - const std::string path = GetTestFileFullPath(file_name); - return ReadMeshFromFile(path).value(); -} -inline std::unique_ptr ReadMeshFromTestFile(const std::string &file_name, - bool use_metadata) { - const std::string path = GetTestFileFullPath(file_name); - return ReadMeshFromFile(path, use_metadata).value(); -} -inline std::unique_ptr ReadMeshFromTestFile(const std::string &file_name, - const Options &options) { - const std::string path = GetTestFileFullPath(file_name); - return ReadMeshFromFile(path, options).value(); -} - -inline std::unique_ptr ReadPointCloudFromTestFile( - const std::string &file_name) { - const std::string path = GetTestFileFullPath(file_name); - return ReadPointCloudFromFile(path).value(); -} - -} // namespace draco - -#endif // DRACO_CORE_DRACO_TEST_UTILS_H_ diff --git a/cloudreg_env/include/draco/core/draco_types.h b/cloudreg_env/include/draco/core/draco_types.h deleted file mode 100644 index f5a21e4..0000000 --- a/cloudreg_env/include/draco/core/draco_types.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DRACO_TYPES_H_ -#define DRACO_CORE_DRACO_TYPES_H_ - -#include -#include - -#include "draco/draco_features.h" - -namespace draco { - -enum DataType { - // Not a legal value for DataType. Used to indicate a field has not been set. - DT_INVALID = 0, - DT_INT8, - DT_UINT8, - DT_INT16, - DT_UINT16, - DT_INT32, - DT_UINT32, - DT_INT64, - DT_UINT64, - DT_FLOAT32, - DT_FLOAT64, - DT_BOOL, - DT_TYPES_COUNT -}; - -int32_t DataTypeLength(DataType dt); - -// Equivalent to std::is_integral for draco::DataType. Returns true for all -// signed and unsigned integer types (including DT_BOOL). Returns false -// otherwise. -bool IsDataTypeIntegral(DataType dt); - -} // namespace draco - -#endif // DRACO_CORE_DRACO_TYPES_H_ diff --git a/cloudreg_env/include/draco/core/draco_version.h b/cloudreg_env/include/draco/core/draco_version.h deleted file mode 100644 index 9d3a67e..0000000 --- a/cloudreg_env/include/draco/core/draco_version.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_DRACO_VERSION_H_ -#define DRACO_CORE_DRACO_VERSION_H_ - -namespace draco { - -// Draco version is comprised of ... -static const char kDracoVersion[] = "1.3.5"; - -const char *Version() { return kDracoVersion; } - -} // namespace draco - -#endif // DRACO_CORE_DRACO_VERSION_H_ diff --git a/cloudreg_env/include/draco/core/encoder_buffer.h b/cloudreg_env/include/draco/core/encoder_buffer.h deleted file mode 100644 index ff3e89b..0000000 --- a/cloudreg_env/include/draco/core/encoder_buffer.h +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_ENCODER_BUFFER_H_ -#define DRACO_CORE_ENCODER_BUFFER_H_ - -#include -#include - -#include "draco/core/bit_utils.h" -#include "draco/core/macros.h" - -namespace draco { - -// Class representing a buffer that can be used for either for byte-aligned -// encoding of arbitrary data structures or for encoding of variable-length -// bit data. -class EncoderBuffer { - public: - EncoderBuffer(); - void Clear(); - void Resize(int64_t nbytes); - - // Start encoding a bit sequence. A maximum size of the sequence needs to - // be known upfront. - // If encode_size is true, the size of encoded bit sequence is stored before - // the sequence. Decoder can then use this size to skip over the bit sequence - // if needed. - // Returns false on error. - bool StartBitEncoding(int64_t required_bits, bool encode_size); - - // End the encoding of the bit sequence and return to the default byte-aligned - // encoding. - void EndBitEncoding(); - - // Encode up to 32 bits into the buffer. Can be called only in between - // StartBitEncoding and EndBitEncoding. Otherwise returns false. - bool EncodeLeastSignificantBits32(int nbits, uint32_t value) { - if (!bit_encoder_active()) - return false; - bit_encoder_->PutBits(value, nbits); - return true; - } - // Encode an arbitrary data type. - // Can be used only when we are not encoding a bit-sequence. - // Returns false when the value couldn't be encoded. - template - bool Encode(const T &data) { - if (bit_encoder_active()) - return false; - const uint8_t *src_data = reinterpret_cast(&data); - buffer_.insert(buffer_.end(), src_data, src_data + sizeof(T)); - return true; - } - bool Encode(const void *data, size_t data_size) { - if (bit_encoder_active()) - return false; - const uint8_t *src_data = reinterpret_cast(data); - buffer_.insert(buffer_.end(), src_data, src_data + data_size); - return true; - } - - bool bit_encoder_active() const { return bit_encoder_reserved_bytes_ > 0; } - const char *data() const { return buffer_.data(); } - size_t size() const { return buffer_.size(); } - std::vector *buffer() { return &buffer_; } - - private: - // Internal helper class to encode bits to a bit buffer. - class BitEncoder { - public: - // |data| is the buffer to write the bits into. - explicit BitEncoder(char *data) : bit_buffer_(data), bit_offset_(0) {} - - // Write |nbits| of |data| into the bit buffer. - void PutBits(uint32_t data, int32_t nbits) { - DRACO_DCHECK_GE(nbits, 0); - DRACO_DCHECK_LE(nbits, 32); - for (int32_t bit = 0; bit < nbits; ++bit) - PutBit((data >> bit) & 1); - } - - // Return number of bits encoded so far. - uint64_t Bits() const { return static_cast(bit_offset_); } - - // TODO(fgalligan): Remove this function once we know we do not need the - // old API anymore. - // This is a function of an old API, that currently does nothing. - void Flush(int /* left_over_bit_value */) {} - - // Return the number of bits required to store the given number - static uint32_t BitsRequired(uint32_t x) { - return static_cast(MostSignificantBit(x)); - } - - private: - void PutBit(uint8_t value) { - const int byte_size = 8; - const uint64_t off = static_cast(bit_offset_); - const uint64_t byte_offset = off / byte_size; - const int bit_shift = off % byte_size; - - // TODO(fgalligan): Check performance if we add a branch and only do one - // memory write if bit_shift is 7. Also try using a temporary variable to - // hold the bits before writing to the buffer. - - bit_buffer_[byte_offset] &= ~(1 << bit_shift); - bit_buffer_[byte_offset] |= value << bit_shift; - bit_offset_++; - } - - char *bit_buffer_; - size_t bit_offset_; - }; - friend class BufferBitCodingTest; - // All data is stored in this vector. - std::vector buffer_; - - // Bit encoder is used when encoding variable-length bit data. - // TODO(ostava): Currently encoder needs to be recreated each time - // StartBitEncoding method is called. This is not necessary if BitEncoder - // supported reset function which can easily added but let's leave that for - // later. - std::unique_ptr bit_encoder_; - - // The number of bytes reserved for bit encoder. - // Values > 0 indicate we are in the bit encoding mode. - int64_t bit_encoder_reserved_bytes_; - - // Flag used indicating that we need to store the length of the currently - // processed bit sequence. - bool encode_bit_sequence_size_; -}; - -} // namespace draco - -#endif // DRACO_CORE_ENCODER_BUFFER_H_ diff --git a/cloudreg_env/include/draco/core/hash_utils.h b/cloudreg_env/include/draco/core/hash_utils.h deleted file mode 100644 index 0e8da60..0000000 --- a/cloudreg_env/include/draco/core/hash_utils.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_HASH_UTILS_H_ -#define DRACO_CORE_HASH_UTILS_H_ - -#include -#include - -// TODO(fgalligan): Move this to core. - -namespace draco { - -template -size_t HashCombine(T1 a, T2 b) { - const size_t hash1 = std::hash()(a); - const size_t hash2 = std::hash()(b); - return (hash1 << 2) ^ (hash2 << 1); -} - -template -size_t HashCombine(T a, size_t hash) { - const size_t hasha = std::hash()(a); - return (hash) ^ (hasha + 239); -} - -inline uint64_t HashCombine(uint64_t a, uint64_t b) { - return (a + 1013) ^ (b + 107) << 1; -} - -// Will never return 1 or 0. -uint64_t FingerprintString(const char *s, size_t len); - -// Hash for std::array. -template -struct HashArray { - size_t operator()(const T &a) const { - size_t hash = 79; // Magic number. - for (unsigned int i = 0; i < std::tuple_size::value; ++i) { - hash = HashCombine(hash, ValueHash(a[i])); - } - return hash; - } - - template - size_t ValueHash(const V &val) const { - return std::hash()(val); - } -}; - -} // namespace draco - -#endif // DRACO_CORE_HASH_UTILS_H_ diff --git a/cloudreg_env/include/draco/core/macros.h b/cloudreg_env/include/draco/core/macros.h deleted file mode 100644 index 09819e6..0000000 --- a/cloudreg_env/include/draco/core/macros.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_MACROS_H_ -#define DRACO_CORE_MACROS_H_ - -#include "assert.h" - -#include "draco/draco_features.h" - -#ifdef ANDROID_LOGGING -#include -#define LOG_TAG "draco" -#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) -#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) -#else -#define LOGI printf -#define LOGE printf -#endif - -#include -namespace draco { - -#ifndef DISALLOW_COPY_AND_ASSIGN -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName &) = delete; \ - void operator=(const TypeName &) = delete; -#endif - -#ifndef FALLTHROUGH_INTENDED -#if defined(__clang__) && defined(__has_warning) -#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") -#define FALLTHROUGH_INTENDED [[clang::fallthrough]] -#endif -#elif defined(__GNUC__) && __GNUC__ >= 7 -#define FALLTHROUGH_INTENDED [[gnu::fallthrough]] -#endif - -// If FALLTHROUGH_INTENDED is still not defined, define it. -#ifndef FALLTHROUGH_INTENDED -#define FALLTHROUGH_INTENDED \ - do { \ - } while (0) -#endif -#endif - -#ifndef LOG -#define LOG(...) std::cout -#endif - -#ifndef VLOG -#define VLOG(...) std::cout -#endif - -} // namespace draco - -#ifdef DRACO_DEBUG -#define DRACO_DCHECK(x) (assert(x)); -#define DRACO_DCHECK_EQ(a, b) assert((a) == (b)); -#define DRACO_DCHECK_NE(a, b) assert((a) != (b)); -#define DRACO_DCHECK_GE(a, b) assert((a) >= (b)); -#define DRACO_DCHECK_GT(a, b) assert((a) > (b)); -#define DRACO_DCHECK_LE(a, b) assert((a) <= (b)); -#define DRACO_DCHECK_LT(a, b) assert((a) < (b)); -#define DRACO_DCHECK_NOTNULL(x) assert((x) != NULL); -#else -#define DRACO_DCHECK(x) -#define DRACO_DCHECK_EQ(a, b) -#define DRACO_DCHECK_NE(a, b) -#define DRACO_DCHECK_GE(a, b) -#define DRACO_DCHECK_GT(a, b) -#define DRACO_DCHECK_LE(a, b) -#define DRACO_DCHECK_LT(a, b) -#define DRACO_DCHECK_NOTNULL(x) -#endif - -// Helper macros for concatenating macro values. -#define DRACO_MACROS_IMPL_CONCAT_INNER_(x, y) x##y -#define DRACO_MACROS_IMPL_CONCAT_(x, y) DRACO_MACROS_IMPL_CONCAT_INNER_(x, y) - -// Expand the n-th argument of the macro. Used to select an argument based on -// the number of entries in a variadic macro argument. Example usage: -// -// #define FUNC_1(x) x -// #define FUNC_2(x, y) x + y -// #define FUNC_3(x, y, z) x + y + z -// -// #define VARIADIC_MACRO(...) -// DRACO_SELECT_NTH_FROM_3(__VA_ARGS__, FUNC_3, FUNC_2, FUNC_1) __VA_ARGS__ -// -#define DRACO_SELECT_NTH_FROM_2(_1, _2, NAME) NAME -#define DRACO_SELECT_NTH_FROM_3(_1, _2, _3, NAME) NAME -#define DRACO_SELECT_NTH_FROM_4(_1, _2, _3, _4, NAME) NAME - -// Macro that converts the Draco bit-stream into one uint16_t number. -// Useful mostly when checking version numbers. -#define DRACO_BITSTREAM_VERSION(MAJOR, MINOR) \ - ((static_cast(MAJOR) << 8) | MINOR) - -#endif // DRACO_CORE_MACROS_H_ diff --git a/cloudreg_env/include/draco/core/math_utils.h b/cloudreg_env/include/draco/core/math_utils.h deleted file mode 100644 index 50cf5d5..0000000 --- a/cloudreg_env/include/draco/core/math_utils.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_MATH_UTILS_H_ -#define DRACO_CORE_MATH_UTILS_H_ - -#include - -#include "draco/core/vector_d.h" - -#define DRACO_INCREMENT_MOD(I, M) (((I) == ((M)-1)) ? 0 : ((I) + 1)) - -// Returns floor(sqrt(x)) where x is an integer number. The main intend of this -// function is to provide a cross platform and deterministic implementation of -// square root for integer numbers. This function is not intended to be a -// replacement for std::sqrt() for general cases. IntSqrt is in fact about 3X -// slower compared to most implementation of std::sqrt(). -inline uint64_t IntSqrt(uint64_t number) { - if (number == 0) - return 0; - // First estimate good initial value of the square root as log2(number). - uint64_t act_number = number; - uint64_t square_root = 1; - while (act_number >= 2) { - // Double the square root until |square_root * square_root > number|. - square_root *= 2; - act_number /= 4; - } - // Perform Newton's (or Babylonian) method to find the true floor(sqrt()). - do { - // New |square_root| estimate is computed as the average between - // |square_root| and |number / square_root|. - square_root = (square_root + number / square_root) / 2; - - // Note that after the first iteration, the estimate is always going to be - // larger or equal to the true square root value. Therefore to check - // convergence, we can simply detect condition when the square of the - // estimated square root is larger than the input. - } while (square_root * square_root > number); - return square_root; -} - -#endif // DRACO_CORE_MATH_UTILS_H_ diff --git a/cloudreg_env/include/draco/core/options.h b/cloudreg_env/include/draco/core/options.h deleted file mode 100644 index 4995299..0000000 --- a/cloudreg_env/include/draco/core/options.h +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_OPTIONS_H_ -#define DRACO_CORE_OPTIONS_H_ - -#include -#include -#include - -namespace draco { - -// Class for storing generic options as a pair in a string map. -// The API provides helper methods for directly storing values of various types -// such as ints and bools. One named option should be set with only a single -// data type. -class Options { - public: - Options(); - - // Merges |other_options| on top of the existing options of this instance - // replacing all entries that are present in both options instances. - void MergeAndReplace(const Options &other_options); - - void SetInt(const std::string &name, int val); - void SetFloat(const std::string &name, float val); - void SetBool(const std::string &name, bool val); - void SetString(const std::string &name, const std::string &val); - template - void SetVector(const std::string &name, const VectorT &vec) { - SetVector(name, &vec[0], VectorT::dimension); - } - template - void SetVector(const std::string &name, const DataTypeT *vec, int num_dims); - - // Getters will return a default value if the entry is not found. The default - // value can be specified in the overloaded version of each function. - int GetInt(const std::string &name) const; - int GetInt(const std::string &name, int default_val) const; - float GetFloat(const std::string &name) const; - float GetFloat(const std::string &name, float default_val) const; - bool GetBool(const std::string &name) const; - bool GetBool(const std::string &name, bool default_val) const; - std::string GetString(const std::string &name) const; - std::string GetString(const std::string &name, - const std::string &default_val) const; - template - VectorT GetVector(const std::string &name, const VectorT &default_val) const; - // Unlike other Get functions, this function returns false if the option does - // not exist, otherwise it fills |out_val| with the vector values. If a - // default value is needed, it can be set in |out_val|. - template - bool GetVector(const std::string &name, int num_dims, - DataTypeT *out_val) const; - - bool IsOptionSet(const std::string &name) const { - return options_.count(name) > 0; - } - - private: - // All entries are internally stored as strings and converted to the desired - // return type based on the used Get* method. - // TODO(ostava): Consider adding type safety mechanism that would prevent - // unsafe operations such as a conversion from vector to int. - std::map options_; -}; - -template -void Options::SetVector(const std::string &name, const DataTypeT *vec, - int num_dims) { - std::string out; - for (int i = 0; i < num_dims; ++i) { - if (i > 0) - out += " "; - -// GNU STL on android doesn't include a proper std::to_string, but the libc++ -// version does -#if defined(ANDROID) && !defined(_LIBCPP_VERSION) - out += to_string(vec[i]); -#else - out += std::to_string(vec[i]); -#endif - } - options_[name] = out; -} - -template -VectorT Options::GetVector(const std::string &name, - const VectorT &default_val) const { - VectorT ret = default_val; - GetVector(name, VectorT::dimension, &ret[0]); - return ret; -} - -template -bool Options::GetVector(const std::string &name, int num_dims, - DataTypeT *out_val) const { - const auto it = options_.find(name); - if (it == options_.end()) - return false; - const std::string value = it->second; - if (value.length() == 0) - return true; // Option set but no data is present - const char *act_str = value.c_str(); - char *next_str; - for (int i = 0; i < num_dims; ++i) { - if (std::is_integral::value) { -#ifdef ANDROID - const int val = strtol(act_str, &next_str, 10); -#else - const int val = std::strtol(act_str, &next_str, 10); -#endif - if (act_str == next_str) - return true; // End reached. - act_str = next_str; - out_val[i] = static_cast(val); - } else { -#ifdef ANDROID - const float val = strtof(act_str, &next_str); -#else - const float val = std::strtof(act_str, &next_str); -#endif - if (act_str == next_str) - return true; // End reached. - act_str = next_str; - out_val[i] = static_cast(val); - } - } - return true; -} - -} // namespace draco - -#endif // DRACO_CORE_OPTIONS_H_ diff --git a/cloudreg_env/include/draco/core/quantization_utils.h b/cloudreg_env/include/draco/core/quantization_utils.h deleted file mode 100644 index 5491046..0000000 --- a/cloudreg_env/include/draco/core/quantization_utils.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// A set of classes for quantizing and dequantizing of floating point values -// into integers. -// The quantization works on all floating point numbers within (-range, +range) -// interval producing integers in range -// (-max_quantized_value, +max_quantized_value). - -#ifndef DRACO_CORE_QUANTIZATION_UTILS_H_ -#define DRACO_CORE_QUANTIZATION_UTILS_H_ - -#include -#include - -#include "draco/core/macros.h" - -namespace draco { - -// Class for quantizing single precision floating point values. The values -// should be centered around zero and be within interval (-range, +range), where -// the range is specified in the Init() method. Alternatively, the quantization -// can be defined by |delta| that specifies the distance between two quantized -// values. Note that the quantizer always snaps the values to the nearest -// integer value. E.g. for |delta| == 1.f, values -0.4f and 0.4f would be -// both quantized to 0 while value 0.6f would be quantized to 1. If a value -// lies exactly between two quantized states, it is always rounded up. E.g., -// for |delta| == 1.f, value -0.5f would be quantized to 0 while 0.5f would be -// quantized to 1. -class Quantizer { - public: - Quantizer(); - void Init(float range, int32_t max_quantized_value); - void Init(float delta); - inline int32_t QuantizeFloat(float val) const { - val *= inverse_delta_; - return static_cast(floor(val + 0.5f)); - } - inline int32_t operator()(float val) const { return QuantizeFloat(val); } - - private: - float inverse_delta_; -}; - -// Class for dequantizing values that were previously quantized using the -// Quantizer class. -class Dequantizer { - public: - Dequantizer(); - - // Initializes the dequantizer. Both parameters must correspond to the values - // provided to the initializer of the Quantizer class. - // Returns false when the initialization fails. - bool Init(float range, int32_t max_quantized_value); - - // Initializes the dequantizer using the |delta| between two quantized values. - bool Init(float delta); - - inline float DequantizeFloat(int32_t val) const { - return static_cast(val) * delta_; - } - inline float operator()(int32_t val) const { return DequantizeFloat(val); } - - private: - float delta_; -}; - -} // namespace draco - -#endif // DRACO_CORE_QUANTIZATION_UTILS_H_ diff --git a/cloudreg_env/include/draco/core/status.h b/cloudreg_env/include/draco/core/status.h deleted file mode 100644 index 0a483f0..0000000 --- a/cloudreg_env/include/draco/core/status.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_STATUS_H_ -#define DRACO_CORE_STATUS_H_ - -#include - -namespace draco { - -// Class encapsulating a return status of an operation with an optional error -// message. Intended to be used as a return type for functions instead of bool. -class Status { - public: - enum Code { - OK = 0, - ERROR = -1, // Used for general errors. - IO_ERROR = -2, // Error when handling input or output stream. - INVALID_PARAMETER = -3, // Invalid parameter passed to a function. - UNSUPPORTED_VERSION = -4, // Input not compatible with the current version. - UNKNOWN_VERSION = -5, // Input was created with an unknown version of - // the library. - }; - - Status() : code_(OK) {} - Status(const Status &status) = default; - Status(Status &&status) = default; - explicit Status(Code code) : code_(code) {} - Status(Code code, const std::string &error_msg) - : code_(code), error_msg_(error_msg) {} - - Code code() const { return code_; } - const std::string &error_msg_string() const { return error_msg_; } - const char *error_msg() const { return error_msg_.c_str(); } - - bool operator==(Code code) const { return code == code_; } - bool ok() const { return code_ == OK; } - - Status &operator=(const Status &) = default; - - private: - Code code_; - std::string error_msg_; -}; - -inline std::ostream &operator<<(std::ostream &os, const Status &status) { - os << status.error_msg_string(); - return os; -} - -inline Status OkStatus() { return Status(Status::OK); } - -// Evaluates an expression that returns draco::Status. If the status is not OK, -// the macro returns the status object. -#define DRACO_RETURN_IF_ERROR(expression) \ - { \ - const draco::Status _local_status = (expression); \ - if (!_local_status.ok()) \ - return _local_status; \ - } - -} // namespace draco - -#endif // DRACO_CORE_STATUS_H_ diff --git a/cloudreg_env/include/draco/core/status_or.h b/cloudreg_env/include/draco/core/status_or.h deleted file mode 100644 index 156b9bc..0000000 --- a/cloudreg_env/include/draco/core/status_or.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_STATUS_OR_H_ -#define DRACO_CORE_STATUS_OR_H_ - -#include "draco/core/macros.h" -#include "draco/core/status.h" - -namespace draco { - -// Class StatusOr is used to wrap a Status along with a value of a specified -// type |T|. StatusOr is intended to be returned from functions in situations -// where it is desirable to carry over more information about the potential -// errors encountered during the function execution. If there are not errors, -// the caller can simply use the return value, otherwise the Status object -// provides more info about the encountered problem. -template -class StatusOr { - public: - StatusOr() {} - // Note: Constructors are intentionally not explicit to allow returning - // Status or the return value directly from functions. - StatusOr(const StatusOr &) = default; - StatusOr(StatusOr &&) = default; - StatusOr(const Status &status) : status_(status) {} - StatusOr(const T &value) : status_(OkStatus()), value_(value) {} - StatusOr(T &&value) : status_(OkStatus()), value_(std::move(value)) {} - StatusOr(const Status &status, const T &value) - : status_(status), value_(value) {} - - const Status &status() const { return status_; } - const T &value() const & { return value_; } - const T &&value() const && { return std::move(value_); } - T &&value() && { return std::move(value_); } - - // For consistency with existing Google StatusOr API we also include - // ValueOrDie() that currently returns the value(). - const T &ValueOrDie() const & { return value(); } - T &&ValueOrDie() && { return std::move(value()); } - - bool ok() const { return status_.ok(); } - - private: - Status status_; - T value_; -}; - -// In case StatusOr is ok(), this macro assigns value stored in StatusOr -// to |lhs|, otherwise it returns the error Status. -// -// DRACO_ASSIGN_OR_RETURN(lhs, expression) -// -#define DRACO_ASSIGN_OR_RETURN(lhs, expression) \ - DRACO_ASSIGN_OR_RETURN_IMPL_(DRACO_MACROS_IMPL_CONCAT_(_statusor, __LINE__), \ - lhs, expression, _status) - -// The actual implementation of the above macro. -#define DRACO_ASSIGN_OR_RETURN_IMPL_(statusor, lhs, expression, error_expr) \ - auto statusor = (expression); \ - if (!statusor.ok()) { \ - auto _status = std::move(statusor.status()); \ - (void)_status; /* error_expression may not use it */ \ - return error_expr; \ - } \ - lhs = std::move(statusor).value(); - -} // namespace draco - -#endif // DRACO_CORE_STATUS_OR_H_ diff --git a/cloudreg_env/include/draco/core/varint_decoding.h b/cloudreg_env/include/draco/core/varint_decoding.h deleted file mode 100644 index 6cd41b2..0000000 --- a/cloudreg_env/include/draco/core/varint_decoding.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_VARINT_DECODING_H_ -#define DRACO_CORE_VARINT_DECODING_H_ - -#include - -#include "draco/core/bit_utils.h" -#include "draco/core/decoder_buffer.h" - -namespace draco { - -// Decodes a specified integer as varint. Note that the IntTypeT must be the -// same as the one used in the corresponding EncodeVarint() call. -template -bool DecodeVarint(IntTypeT *out_val, DecoderBuffer *buffer) { - if (std::is_unsigned::value) { - // Coding of unsigned values. - // 0-6 bit - data - // 7 bit - next byte? - uint8_t in; - if (!buffer->Decode(&in)) - return false; - if (in & (1 << 7)) { - // Next byte is available, decode it first. - if (!DecodeVarint(out_val, buffer)) - return false; - // Append decoded info from this byte. - *out_val <<= 7; - *out_val |= in & ((1 << 7) - 1); - } else { - // Last byte reached - *out_val = in; - } - } else { - // IntTypeT is a signed value. Decode the symbol and convert to signed. - typename std::make_unsigned::type symbol; - if (!DecodeVarint(&symbol, buffer)) - return false; - *out_val = ConvertSymbolToSignedInt(symbol); - } - return true; -} - -} // namespace draco - -#endif // DRACO_CORE_VARINT_DECODING_H_ diff --git a/cloudreg_env/include/draco/core/varint_encoding.h b/cloudreg_env/include/draco/core/varint_encoding.h deleted file mode 100644 index b9b6dca..0000000 --- a/cloudreg_env/include/draco/core/varint_encoding.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_VARINT_ENCODING_H_ -#define DRACO_CORE_VARINT_ENCODING_H_ - -#include - -#include "draco/core/bit_utils.h" -#include "draco/core/encoder_buffer.h" - -namespace draco { - -// Encodes a specified integer as varint. Note that different coding is used -// when IntTypeT is an unsigned data type. -template -bool EncodeVarint(IntTypeT val, EncoderBuffer *out_buffer) { - if (std::is_unsigned::value) { - // Coding of unsigned values. - // 0-6 bit - data - // 7 bit - next byte? - uint8_t out = 0; - out |= val & ((1 << 7) - 1); - if (val >= (1 << 7)) { - out |= (1 << 7); - if (!out_buffer->Encode(out)) - return false; - if (!EncodeVarint(val >> 7, out_buffer)) - return false; - return true; - } - if (!out_buffer->Encode(out)) - return false; - } else { - // IntTypeT is a signed value. Convert to unsigned symbol and encode. - const typename std::make_unsigned::type symbol = - ConvertSignedIntToSymbol(val); - if (!EncodeVarint(symbol, out_buffer)) - return false; - } - return true; -} - -} // namespace draco - -#endif // DRACO_CORE_VARINT_ENCODING_H_ diff --git a/cloudreg_env/include/draco/core/vector_d.h b/cloudreg_env/include/draco/core/vector_d.h deleted file mode 100644 index 189517f..0000000 --- a/cloudreg_env/include/draco/core/vector_d.h +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_CORE_VECTOR_D_H_ -#define DRACO_CORE_VECTOR_D_H_ - -#include -#include -#include -#include - -#include "draco/core/macros.h" - -namespace draco { -// D-dimensional vector class with basic operations. -template -class VectorD { - public: - static constexpr int dimension = dimension_t; - - typedef ScalarT Scalar; - typedef VectorD Self; - - // TODO(hemmer): Deprecate. - typedef ScalarT CoefficientType; - - VectorD() { - for (int i = 0; i < dimension; ++i) - (*this)[i] = Scalar(0); - } - - // The following constructor does not compile in opt mode, which for now led - // to the constructors further down, which is not ideal. - // TODO(hemmer): fix constructor below and remove others. - // template - // explicit VectorD(Args... args) : v_({args...}) {} - - VectorD(const Scalar &c0, const Scalar &c1) : v_({{c0, c1}}) { - DRACO_DCHECK_EQ(dimension, 2); - v_[0] = c0; - v_[1] = c1; - } - - VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2) - : v_({{c0, c1, c2}}) { - DRACO_DCHECK_EQ(dimension, 3); - } - - VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2, - const Scalar &c3) - : v_({{c0, c1, c2, c3}}) { - DRACO_DCHECK_EQ(dimension, 4); - } - - VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2, - const Scalar &c3, const Scalar &c4) - : v_({{c0, c1, c2, c3, c4}}) { - DRACO_DCHECK_EQ(dimension, 5); - } - - VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2, - const Scalar &c3, const Scalar &c4, const Scalar &c5) - : v_({{c0, c1, c2, c3, c4, c5}}) { - DRACO_DCHECK_EQ(dimension, 6); - } - - VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2, - const Scalar &c3, const Scalar &c4, const Scalar &c5, - const Scalar &c6) - : v_({{c0, c1, c2, c3, c4, c5, c6}}) { - DRACO_DCHECK_EQ(dimension, 7); - } - - VectorD(const Self &o) { - for (int i = 0; i < dimension; ++i) - (*this)[i] = o[i]; - } - - // Constructs the vector from another vector with a different data type or a - // different number of components. If the |src_vector| has more components - // than |this| vector, the excess components are truncated. If the - // |src_vector| has fewer components than |this| vector, the remaining - // components are padded with 0. - // Note that the constructor is intentionally explicit to avoid accidental - // conversions between different vector types. - template - explicit VectorD(const VectorD &src_vector) { - for (int i = 0; i < dimension; ++i) { - if (i < other_dimension_t) - v_[i] = Scalar(src_vector[i]); - else - v_[i] = Scalar(0); - } - } - - Scalar &operator[](int i) { return v_[i]; } - const Scalar &operator[](int i) const { return v_[i]; } - // TODO(hemmer): remove. - // Similar to interface of Eigen library. - Scalar &operator()(int i) { return v_[i]; } - const Scalar &operator()(int i) const { return v_[i]; } - - // Unary operators. - Self operator-() const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = -(*this)[i]; - } - return ret; - } - - // Binary operators. - Self operator+(const Self &o) const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = (*this)[i] + o[i]; - } - return ret; - } - - Self operator-(const Self &o) const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = (*this)[i] - o[i]; - } - return ret; - } - - Self operator*(const Scalar &o) const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = (*this)[i] * o; - } - return ret; - } - - Self operator/(const Scalar &o) const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = (*this)[i] / o; - } - return ret; - } - - Self operator+(const Scalar &o) const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = (*this)[i] + o; - } - return ret; - } - - Self operator-(const Scalar &o) const { - Self ret; - for (int i = 0; i < dimension; ++i) { - ret[i] = (*this)[i] - o; - } - return ret; - } - - bool operator==(const Self &o) const { - for (int i = 0; i < dimension; ++i) { - if ((*this)[i] != o[i]) - return false; - } - return true; - } - - bool operator!=(const Self &x) const { return !((*this) == x); } - - bool operator<(const Self &x) const { - for (int i = 0; i < dimension - 1; ++i) { - if (v_[i] < x.v_[i]) - return true; - if (v_[i] > x.v_[i]) - return false; - } - // Only one check needed for the last dimension. - if (v_[dimension - 1] < x.v_[dimension - 1]) - return true; - return false; - } - - // Functions. - Scalar SquaredNorm() const { return this->Dot(*this); } - - // Computes L1, the sum of absolute values of all entries. - Scalar AbsSum() const { - Scalar result(0); - for (int i = 0; i < dimension; ++i) { - result += std::abs(v_[i]); - } - return result; - } - - Scalar Dot(const Self &o) const { - Scalar ret(0); - for (int i = 0; i < dimension; ++i) { - ret += (*this)[i] * o[i]; - } - return ret; - } - - void Normalize() { - const Scalar magnitude = std::sqrt(this->SquaredNorm()); - if (magnitude == 0) { - return; - } - for (int i = 0; i < dimension; ++i) { - (*this)[i] /= magnitude; - } - } - - const Scalar &MaxCoeff() const { - return *std::max_element(v_.begin(), v_.end()); - } - - const Scalar &MinCoeff() const { - return *std::min_element(v_.begin(), v_.end()); - } - - Scalar *data() { return &(v_[0]); } - - private: - std::array v_; -}; - -// Scalar multiplication from the other side too. -template -VectorD operator*( - const ScalarT &o, const VectorD &v) { - return v * o; -} - -// Calculates the squared distance between two points. -template -ScalarT SquaredDistance(const VectorD &v1, - const VectorD &v2) { - ScalarT difference; - ScalarT squared_distance = 0; - // Check each index separately so difference is never negative and underflow - // is avoided for unsigned types. - for (int i = 0; i < dimension_t; ++i) { - if (v1[i] >= v2[i]) { - difference = v1[i] - v2[i]; - } else { - difference = v2[i] - v1[i]; - } - squared_distance += (difference * difference); - } - return squared_distance; -} - -// Global function computing the cross product of two 3D vectors. -template -VectorD CrossProduct(const VectorD &u, - const VectorD &v) { - // Preventing accidental use with uint32_t and the like. - static_assert(std::is_signed::value, - "ScalarT must be a signed type. "); - VectorD r; - r[0] = (u[1] * v[2]) - (u[2] * v[1]); - r[1] = (u[2] * v[0]) - (u[0] * v[2]); - r[2] = (u[0] * v[1]) - (u[1] * v[0]); - return r; -} - -template -inline std::ostream &operator<<( - std::ostream &out, const draco::VectorD &vec) { - for (int i = 0; i < dimension_t - 1; ++i) { - out << vec[i] << " "; - } - out << vec[dimension_t - 1]; - return out; -} - -typedef VectorD Vector2f; -typedef VectorD Vector3f; -typedef VectorD Vector4f; -typedef VectorD Vector5f; -typedef VectorD Vector6f; -typedef VectorD Vector7f; - -typedef VectorD Vector2ui; -typedef VectorD Vector3ui; -typedef VectorD Vector4ui; -typedef VectorD Vector5ui; -typedef VectorD Vector6ui; -typedef VectorD Vector7ui; - -} // namespace draco - -#endif // DRACO_CORE_VECTOR_D_H_ diff --git a/cloudreg_env/include/draco/draco_features.h b/cloudreg_env/include/draco/draco_features.h deleted file mode 100644 index 087d098..0000000 --- a/cloudreg_env/include/draco/draco_features.h +++ /dev/null @@ -1,15 +0,0 @@ -// GENERATED FILE -- DO NOT EDIT - -#ifndef DRACO_FEATURES_H_ -#define DRACO_FEATURES_H_ - -#define DRACO_POINT_CLOUD_COMPRESSION_SUPPORTED -#define DRACO_MESH_COMPRESSION_SUPPORTED -#define DRACO_NORMAL_ENCODING_SUPPORTED -#define DRACO_STANDARD_EDGEBREAKER_SUPPORTED -#define DRACO_PREDICTIVE_EDGEBREAKER_SUPPORTED -#define DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED -#define DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED -#define DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED - -#endif // DRACO_FEATURES_H_ \ No newline at end of file diff --git a/cloudreg_env/include/draco/io/file_utils.h b/cloudreg_env/include/draco/io/file_utils.h deleted file mode 100644 index 0ffdb61..0000000 --- a/cloudreg_env/include/draco/io/file_utils.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2018 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_FILE_UTILS_H_ -#define DRACO_IO_FILE_UTILS_H_ - -#include - -namespace draco { - -// Splits full path to a file into a folder path + file name. -// |out_folder_path| will contain the path to the folder containing the file -// excluding the final slash. If no folder is specified in the |full_path|, then -// |out_folder_path| is set to "." -// Returns false on error. -bool SplitPath(const std::string &full_path, std::string *out_folder_path, - std::string *out_file_name); - -// Replaces file extension in |in_file_name| with |new_extension|. -// If |in_file_name| does not have any extension, the extension is appended. -std::string ReplaceFileExtension(const std::string &in_file_name, - const std::string &new_extension); - -// Returns the file extension in lowercase if present, else "". Extension is -// defined as the string after the last '.' character. If the file starts with -// '.' (e.g. Linux hidden files), the first delimiter is ignored. -std::string LowercaseFileExtension(const std::string &filename); - -// Given a path of the input file |input_file_relative_path| relative to the -// parent directory of |sibling_file_full_path|, this function returns full path -// to the input file. If |sibling_file_full_path| has no directory, the relative -// path itself |input_file_relative_path| is returned. A common use case is for -// the |input_file_relative_path| to be just a file name. See usage examples in -// the unit test. -std::string GetFullPath(const std::string &input_file_relative_path, - const std::string &sibling_file_full_path); - -} // namespace draco - -#endif // DRACO_IO_FILE_UTILS_H_ diff --git a/cloudreg_env/include/draco/io/mesh_io.h b/cloudreg_env/include/draco/io/mesh_io.h deleted file mode 100644 index 15cfbb3..0000000 --- a/cloudreg_env/include/draco/io/mesh_io.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_MESH_IO_H_ -#define DRACO_MESH_MESH_IO_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/decode.h" -#include "draco/compression/expert_encode.h" -#include "draco/core/options.h" - -namespace draco { - -template -OutStreamT WriteMeshIntoStream(const Mesh *mesh, OutStreamT &&os, - MeshEncoderMethod method, - const EncoderOptions &options) { - EncoderBuffer buffer; - EncoderOptions local_options = options; - ExpertEncoder encoder(*mesh); - encoder.Reset(local_options); - encoder.SetEncodingMethod(method); - if (!encoder.EncodeToBuffer(&buffer).ok()) { - os.setstate(std::ios_base::badbit); - return os; - } - - os.write(static_cast(buffer.data()), buffer.size()); - - return os; -} - -template -OutStreamT WriteMeshIntoStream(const Mesh *mesh, OutStreamT &&os, - MeshEncoderMethod method) { - const EncoderOptions options = EncoderOptions::CreateDefaultOptions(); - return WriteMeshIntoStream(mesh, os, method, options); -} - -template -OutStreamT &WriteMeshIntoStream(const Mesh *mesh, OutStreamT &&os) { - return WriteMeshIntoStream(mesh, os, MESH_EDGEBREAKER_ENCODING); -} - -template -InStreamT &ReadMeshFromStream(std::unique_ptr *mesh, InStreamT &&is) { - // Determine size of stream and write into a vector - const auto start_pos = is.tellg(); - is.seekg(0, std::ios::end); - const std::streampos is_size = is.tellg() - start_pos; - is.seekg(start_pos); - std::vector data(is_size); - is.read(&data[0], is_size); - - // Create a mesh from that data. - DecoderBuffer buffer; - buffer.Init(&data[0], data.size()); - Decoder decoder; - auto statusor = decoder.DecodeMeshFromBuffer(&buffer); - *mesh = std::move(statusor).value(); - if (!statusor.ok() || *mesh == nullptr) { - is.setstate(std::ios_base::badbit); - } - - return is; -} - -// Reads a mesh from a file. The function automatically chooses the correct -// decoder based on the extension of the files. Currently, .obj and .ply files -// are supported. Other file extensions are processed by the default -// draco::MeshDecoder. -// Returns nullptr with an error status if the decoding failed. -StatusOr> ReadMeshFromFile(const std::string &file_name); - -// Reads a mesh from a file. The function does the same thing as the previous -// one except using metadata to encode additional information when -// |use_metadata| is set to true. -// Returns nullptr with an error status if the decoding failed. -StatusOr> ReadMeshFromFile(const std::string &file_name, - bool use_metadata); - -// Reads a mesh from a file. Reading is configured with |options|: -// use_metadata : Read obj file info like material names and object names into -// metadata. Default is false. -// Returns nullptr with an error status if the decoding failed. -StatusOr> ReadMeshFromFile(const std::string &file_name, - const Options &options); - -} // namespace draco - -#endif // DRACO_MESH_MESH_IO_H_ diff --git a/cloudreg_env/include/draco/io/obj_decoder.h b/cloudreg_env/include/draco/io/obj_decoder.h deleted file mode 100644 index 33b9dee..0000000 --- a/cloudreg_env/include/draco/io/obj_decoder.h +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_OBJ_DECODER_H_ -#define DRACO_IO_OBJ_DECODER_H_ - -#include -#include - -#include "draco/draco_features.h" - -#include "draco/core/decoder_buffer.h" -#include "draco/core/status.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Decodes a Wavefront OBJ file into draco::Mesh (or draco::PointCloud if the -// connectivity data is not needed).. This decoder can handle decoding of -// positions, texture coordinates, normals and triangular faces. -// All other geometry properties are ignored. -class ObjDecoder { - public: - ObjDecoder(); - - // Decodes an obj file stored in the input file. - // Returns nullptr if the decoding failed. - Status DecodeFromFile(const std::string &file_name, Mesh *out_mesh); - Status DecodeFromFile(const std::string &file_name, - PointCloud *out_point_cloud); - - Status DecodeFromBuffer(DecoderBuffer *buffer, Mesh *out_mesh); - Status DecodeFromBuffer(DecoderBuffer *buffer, PointCloud *out_point_cloud); - - // Flag that can be used to turn on/off deduplication of input values. - // This should be disabled only when we are sure that the input data does not - // contain any duplicate entries. - // Default: true - void set_deduplicate_input_values(bool v) { deduplicate_input_values_ = v; } - // Flag for whether using metadata to record other information in the obj - // file, e.g. material names, object names. - void set_use_metadata(bool flag) { use_metadata_ = flag; } - - protected: - Status DecodeInternal(); - DecoderBuffer *buffer() { return &buffer_; } - - private: - // Resets internal counters for attributes and faces. - void ResetCounters(); - - // Parses the next mesh property definition (position, tex coord, normal, or - // face). If the parsed data is unrecognized, it will be skipped. - // Returns false when the end of file was reached. - bool ParseDefinition(Status *status); - - // Attempts to parse definition of position, normal, tex coord, or face - // respectively. - // Returns false when the parsed data didn't contain the given definition. - bool ParseVertexPosition(Status *status); - bool ParseNormal(Status *status); - bool ParseTexCoord(Status *status); - bool ParseFace(Status *status); - bool ParseMaterialLib(Status *status); - bool ParseMaterial(Status *status); - bool ParseObject(Status *status); - - // Parses triplet of position, tex coords and normal indices. - // Returns false on error. - bool ParseVertexIndices(std::array *out_indices); - - // Maps specified point index to the parsed vertex indices (triplet of - // position, texture coordinate, and normal indices) . - void MapPointToVertexIndices(PointIndex pi, - const std::array &indices); - - // Parses material file definitions from a separate file. - bool ParseMaterialFile(const std::string &file_name, Status *status); - bool ParseMaterialFileDefinition(Status *status); - - // If set to true, the parser will count the number of various definitions - // but it will not parse the actual data or add any new entries to the mesh. - bool counting_mode_; - int num_obj_faces_; - int num_positions_; - int num_tex_coords_; - int num_normals_; - int num_materials_; - int last_sub_obj_id_; - - int pos_att_id_; - int tex_att_id_; - int norm_att_id_; - int material_att_id_; - int sub_obj_att_id_; // Attribute id for storing sub-objects. - - bool deduplicate_input_values_; - - int last_material_id_; - std::string material_file_name_; - - std::string input_file_name_; - - std::unordered_map material_name_to_id_; - std::unordered_map obj_name_to_id_; - - bool use_metadata_; - - DecoderBuffer buffer_; - - // Data structure that stores the decoded data. |out_point_cloud_| must be - // always set but |out_mesh_| is optional. - Mesh *out_mesh_; - PointCloud *out_point_cloud_; -}; - -} // namespace draco - -#endif // DRACO_IO_OBJ_DECODER_H_ diff --git a/cloudreg_env/include/draco/io/obj_encoder.h b/cloudreg_env/include/draco/io/obj_encoder.h deleted file mode 100644 index 352a047..0000000 --- a/cloudreg_env/include/draco/io/obj_encoder.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_OBJ_ENCODER_H_ -#define DRACO_IO_OBJ_ENCODER_H_ - -#include "draco/core/encoder_buffer.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Class for encoding input draco::Mesh or draco::PointCloud into the Wavefront -// OBJ format. -class ObjEncoder { - public: - ObjEncoder(); - - // Encodes the mesh or a point cloud and saves it into a file. - // Returns false when either the encoding failed or when the file couldn't be - // opened. - bool EncodeToFile(const PointCloud &pc, const std::string &file_name); - bool EncodeToFile(const Mesh &mesh, const std::string &file_name); - - // Encodes the mesh or the point cloud into a buffer. - bool EncodeToBuffer(const PointCloud &pc, EncoderBuffer *out_buffer); - bool EncodeToBuffer(const Mesh &mesh, EncoderBuffer *out_buffer); - - protected: - bool EncodeInternal(); - EncoderBuffer *buffer() const { return out_buffer_; } - bool ExitAndCleanup(bool return_value); - - private: - bool GetSubObjects(); - bool EncodeMaterialFileName(); - bool EncodePositions(); - bool EncodeTextureCoordinates(); - bool EncodeNormals(); - bool EncodeFaces(); - bool EncodeSubObject(FaceIndex face_id); - bool EncodeMaterial(FaceIndex face_id); - bool EncodeFaceCorner(FaceIndex face_id, int local_corner_id); - - void EncodeFloat(float val); - void EncodeFloatList(float *vals, int num_vals); - void EncodeInt(int32_t val); - - // Various attributes used by the encoder. If an attribute is not used, it is - // set to nullptr. - const PointAttribute *pos_att_; - const PointAttribute *tex_coord_att_; - const PointAttribute *normal_att_; - const PointAttribute *material_att_; - const PointAttribute *sub_obj_att_; - - // Buffer used for encoding float/int numbers. - char num_buffer_[20]; - - EncoderBuffer *out_buffer_; - - const PointCloud *in_point_cloud_; - const Mesh *in_mesh_; - - // Store sub object name for each value. - std::unordered_map sub_obj_id_to_name_; - // Current sub object id of faces. - int current_sub_obj_id_; - - // Store material name for each value in material attribute. - std::unordered_map material_id_to_name_; - // Current material id of faces. - int current_material_id_; - - std::string file_name_; -}; - -} // namespace draco - -#endif // DRACO_IO_OBJ_ENCODER_H_ diff --git a/cloudreg_env/include/draco/io/parser_utils.h b/cloudreg_env/include/draco/io/parser_utils.h deleted file mode 100644 index aa62905..0000000 --- a/cloudreg_env/include/draco/io/parser_utils.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_PARSER_UTILS_H_ -#define DRACO_IO_PARSER_UTILS_H_ - -#include "draco/core/decoder_buffer.h" - -namespace draco { -namespace parser { - -// Skips to first character not included in |skip_chars|. -void SkipCharacters(DecoderBuffer *buffer, const char *skip_chars); - -// Skips any whitespace until a regular character is reached. -void SkipWhitespace(DecoderBuffer *buffer); - -// Returns true if the next character is a whitespace. -// |end_reached| is set to true when the end of the stream is reached. -bool PeekWhitespace(DecoderBuffer *buffer, bool *end_reached); -void SkipLine(DecoderBuffer *buffer); - -// Parses signed floating point number or returns false on error. -bool ParseFloat(DecoderBuffer *buffer, float *value); - -// Parses a signed integer (can be preceded by '-' or '+' characters. -bool ParseSignedInt(DecoderBuffer *buffer, int32_t *value); - -// Parses an unsigned integer. It cannot be preceded by '-' or '+' -// characters. -bool ParseUnsignedInt(DecoderBuffer *buffer, uint32_t *value); - -// Returns -1 if c == '-'. -// Returns +1 if c == '+'. -// Returns 0 otherwise. -int GetSignValue(char c); - -// Parses a string until a whitespace or end of file is reached. -bool ParseString(DecoderBuffer *buffer, std::string *out_string); - -// Parses the entire line into the buffer (excluding the new line character). -void ParseLine(DecoderBuffer *buffer, std::string *out_string); - -// Parses line and stores into a new decoder buffer. -DecoderBuffer ParseLineIntoDecoderBuffer(DecoderBuffer *buffer); - -// Returns a string with all characters converted to lower case. -std::string ToLower(const std::string &str); - -} // namespace parser -} // namespace draco - -#endif // DRACO_IO_PARSER_UTILS_H_ diff --git a/cloudreg_env/include/draco/io/ply_decoder.h b/cloudreg_env/include/draco/io/ply_decoder.h deleted file mode 100644 index 9e667ab..0000000 --- a/cloudreg_env/include/draco/io/ply_decoder.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_MESH_PLY_DECODER_H_ -#define DRACO_IO_MESH_PLY_DECODER_H_ - -#include - -#include "draco/draco_features.h" - -#include "draco/core/decoder_buffer.h" -#include "draco/core/status.h" -#include "draco/io/ply_reader.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Decodes a Wavefront OBJ file into draco::Mesh (or draco::PointCloud if the -// connectivity data is not needed). -// TODO(ostava): The current implementation assumes that the input vertices are -// defined with x, y, z properties. The decoder also reads uint8 red, green, -// blue, alpha color information, but all other attributes are ignored for now. -class PlyDecoder { - public: - PlyDecoder(); - - // Decodes an obj file stored in the input file. - Status DecodeFromFile(const std::string &file_name, Mesh *out_mesh); - Status DecodeFromFile(const std::string &file_name, - PointCloud *out_point_cloud); - - Status DecodeFromBuffer(DecoderBuffer *buffer, Mesh *out_mesh); - Status DecodeFromBuffer(DecoderBuffer *buffer, PointCloud *out_point_cloud); - - protected: - Status DecodeInternal(); - DecoderBuffer *buffer() { return &buffer_; } - - private: - Status DecodeFaceData(const PlyElement *face_element); - Status DecodeVertexData(const PlyElement *vertex_element); - - template - bool ReadPropertiesToAttribute( - const std::vector &properties, - PointAttribute *attribute, int num_vertices); - - DecoderBuffer buffer_; - - // Data structure that stores the decoded data. |out_point_cloud_| must be - // always set but |out_mesh_| is optional. - Mesh *out_mesh_; - PointCloud *out_point_cloud_; -}; - -} // namespace draco - -#endif // DRACO_IO_MESH_PLY_DECODER_H_ diff --git a/cloudreg_env/include/draco/io/ply_encoder.h b/cloudreg_env/include/draco/io/ply_encoder.h deleted file mode 100644 index 242bbd6..0000000 --- a/cloudreg_env/include/draco/io/ply_encoder.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_PLY_ENCODER_H_ -#define DRACO_IO_PLY_ENCODER_H_ - -#include "draco/core/encoder_buffer.h" -#include "draco/mesh/mesh.h" - -namespace draco { - -// Class for encoding draco::Mesh or draco::PointCloud into the PLY file format. -class PlyEncoder { - public: - PlyEncoder(); - - // Encodes the mesh or a point cloud and saves it into a file. - // Returns false when either the encoding failed or when the file couldn't be - // opened. - bool EncodeToFile(const PointCloud &pc, const std::string &file_name); - bool EncodeToFile(const Mesh &mesh, const std::string &file_name); - - // Encodes the mesh or the point cloud into a buffer. - bool EncodeToBuffer(const PointCloud &pc, EncoderBuffer *out_buffer); - bool EncodeToBuffer(const Mesh &mesh, EncoderBuffer *out_buffer); - - protected: - bool EncodeInternal(); - EncoderBuffer *buffer() const { return out_buffer_; } - bool ExitAndCleanup(bool return_value); - - private: - const char *GetAttributeDataType(int attribute); - - EncoderBuffer *out_buffer_; - - const PointCloud *in_point_cloud_; - const Mesh *in_mesh_; -}; - -} // namespace draco - -#endif // DRACO_IO_PLY_ENCODER_H_ diff --git a/cloudreg_env/include/draco/io/ply_property_reader.h b/cloudreg_env/include/draco/io/ply_property_reader.h deleted file mode 100644 index efb8a3a..0000000 --- a/cloudreg_env/include/draco/io/ply_property_reader.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_PLY_PROPERTY_READER_H_ -#define DRACO_IO_PLY_PROPERTY_READER_H_ - -#include - -#include "draco/io/ply_reader.h" - -namespace draco { - -// Class for reading PlyProperty with a given type, performing data conversion -// if necessary. -template -class PlyPropertyReader { - public: - explicit PlyPropertyReader(const PlyProperty *property) - : property_(property) { - // Find the suitable function for converting values. - switch (property->data_type()) { - case DT_UINT8: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_INT8: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_UINT16: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_INT16: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_UINT32: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_INT32: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_FLOAT32: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - case DT_FLOAT64: - convert_value_func_ = [=](int val_id) { - return this->ConvertValue(val_id); - }; - break; - default: - break; - } - } - - ReadTypeT ReadValue(int value_id) const { - return convert_value_func_(value_id); - } - - private: - template - ReadTypeT ConvertValue(int value_id) const { - const void *const address = property_->GetDataEntryAddress(value_id); - const SourceTypeT src_val = *reinterpret_cast(address); - return static_cast(src_val); - } - - const PlyProperty *property_; - std::function convert_value_func_; -}; - -} // namespace draco - -#endif // DRACO_IO_PLY_PROPERTY_READER_H_ diff --git a/cloudreg_env/include/draco/io/ply_property_writer.h b/cloudreg_env/include/draco/io/ply_property_writer.h deleted file mode 100644 index 4f243b2..0000000 --- a/cloudreg_env/include/draco/io/ply_property_writer.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_PLY_PROPERTY_WRITER_H_ -#define DRACO_IO_PLY_PROPERTY_WRITER_H_ - -#include - -#include "draco/io/ply_reader.h" - -namespace draco { - -// Class for writing PlyProperty with a given type, performing data conversion -// if necessary. -template -class PlyPropertyWriter { - public: - explicit PlyPropertyWriter(PlyProperty *property) : property_(property) { - // Find the suitable function for converting values. - switch (property->data_type()) { - case DT_UINT8: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_INT8: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_UINT16: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_INT16: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_UINT32: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_INT32: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_FLOAT32: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - case DT_FLOAT64: - convert_value_func_ = [=](WriteTypeT val) { - return this->ConvertValue(val); - }; - break; - default: - break; - } - } - - void PushBackValue(WriteTypeT value) const { - return convert_value_func_(value); - } - - private: - template - void ConvertValue(WriteTypeT value) const { - const SourceTypeT src_val = static_cast(value); - property_->push_back_value(&src_val); - } - - PlyProperty *property_; - std::function convert_value_func_; -}; - -} // namespace draco - -#endif // DRACO_IO_PLY_PROPERTY_WRITER_H_ diff --git a/cloudreg_env/include/draco/io/ply_reader.h b/cloudreg_env/include/draco/io/ply_reader.h deleted file mode 100644 index 845ef23..0000000 --- a/cloudreg_env/include/draco/io/ply_reader.h +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// File contains helper classes used for parsing of PLY files. The classes are -// used by the PlyDecoder (ply_decoder.h) to read a point cloud or mesh from a -// source PLY file. -// TODO(ostava): Currently, we support only binary PLYs encoded in the little -// endian format ("format binary_little_endian 1.0"). - -#ifndef DRACO_IO_PLY_READER_H_ -#define DRACO_IO_PLY_READER_H_ - -#include -#include - -#include "draco/core/decoder_buffer.h" -#include "draco/core/draco_types.h" -#include "draco/core/status.h" -#include "draco/core/status_or.h" - -namespace draco { - -// A single PLY property of a given PLY element. For "vertex" element this can -// contain data such as "x", "y", or "z" coordinate of the vertex, while for -// "face" element this usually contains corner indices. -class PlyProperty { - public: - friend class PlyReader; - - PlyProperty(const std::string &name, DataType data_type, DataType list_type); - void ReserveData(int num_entries) { - data_.reserve(DataTypeLength(data_type_) * num_entries); - } - - int64_t GetListEntryOffset(int entry_id) const { - return list_data_[entry_id * 2]; - } - int64_t GetListEntryNumValues(int entry_id) const { - return list_data_[entry_id * 2 + 1]; - } - const void *GetDataEntryAddress(int entry_id) const { - return data_.data() + entry_id * data_type_num_bytes_; - } - void push_back_value(const void *data) { - data_.insert(data_.end(), static_cast(data), - static_cast(data) + data_type_num_bytes_); - } - - const std::string &name() const { return name_; } - bool is_list() const { return list_data_type_ != DT_INVALID; } - DataType data_type() const { return data_type_; } - int data_type_num_bytes() const { return data_type_num_bytes_; } - DataType list_data_type() const { return list_data_type_; } - int list_data_type_num_bytes() const { return list_data_type_num_bytes_; } - - private: - std::string name_; - std::vector data_; - // List data contain pairs of - std::vector list_data_; - DataType data_type_; - int data_type_num_bytes_; - DataType list_data_type_; - int list_data_type_num_bytes_; -}; - -// A single PLY element such as "vertex" or "face". Each element can store -// arbitrary properties such as vertex coordinates or face indices. -class PlyElement { - public: - PlyElement(const std::string &name, int64_t num_entries); - void AddProperty(const PlyProperty &prop) { - property_index_[prop.name()] = static_cast(properties_.size()); - properties_.emplace_back(prop); - if (!properties_.back().is_list()) - properties_.back().ReserveData(static_cast(num_entries_)); - } - - const PlyProperty *GetPropertyByName(const std::string &name) const { - const auto it = property_index_.find(name); - if (it != property_index_.end()) - return &properties_[it->second]; - return nullptr; - } - - int num_properties() const { return static_cast(properties_.size()); } - int num_entries() const { return static_cast(num_entries_); } - const PlyProperty &property(int prop_index) const { - return properties_[prop_index]; - } - PlyProperty &property(int prop_index) { return properties_[prop_index]; } - - private: - std::string name_; - int64_t num_entries_; - std::vector properties_; - std::map property_index_; -}; - -// Class responsible for parsing PLY data. It produces a list of PLY elements -// and their properties that can be used to construct a mesh or a point cloud. -class PlyReader { - public: - PlyReader(); - Status Read(DecoderBuffer *buffer); - - const PlyElement *GetElementByName(const std::string &name) const { - const auto it = element_index_.find(name); - if (it != element_index_.end()) - return &elements_[it->second]; - return nullptr; - } - - int num_elements() const { return static_cast(elements_.size()); } - const PlyElement &element(int element_index) const { - return elements_[element_index]; - } - - private: - enum Format { kLittleEndian = 0, kAscii }; - - Status ParseHeader(DecoderBuffer *buffer); - StatusOr ParseEndHeader(DecoderBuffer *buffer); - bool ParseElement(DecoderBuffer *buffer); - StatusOr ParseProperty(DecoderBuffer *buffer); - bool ParsePropertiesData(DecoderBuffer *buffer); - bool ParseElementData(DecoderBuffer *buffer, int element_index); - bool ParseElementDataAscii(DecoderBuffer *buffer, int element_index); - - // Splits |line| by whitespace characters. - std::vector SplitWords(const std::string &line); - DataType GetDataTypeFromString(const std::string &name) const; - - std::vector elements_; - std::map element_index_; - Format format_; -}; - -} // namespace draco - -#endif // DRACO_IO_PLY_READER_H_ diff --git a/cloudreg_env/include/draco/io/point_cloud_io.h b/cloudreg_env/include/draco/io/point_cloud_io.h deleted file mode 100644 index 4e1eb35..0000000 --- a/cloudreg_env/include/draco/io/point_cloud_io.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_IO_POINT_CLOUD_IO_H_ -#define DRACO_IO_POINT_CLOUD_IO_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/decode.h" -#include "draco/compression/expert_encode.h" - -namespace draco { - -template -OutStreamT WritePointCloudIntoStream(const PointCloud *pc, OutStreamT &&os, - PointCloudEncodingMethod method, - const EncoderOptions &options) { - EncoderBuffer buffer; - EncoderOptions local_options = options; - ExpertEncoder encoder(*pc); - encoder.Reset(local_options); - encoder.SetEncodingMethod(method); - if (!encoder.EncodeToBuffer(&buffer).ok()) { - os.setstate(std::ios_base::badbit); - return os; - } - - os.write(static_cast(buffer.data()), buffer.size()); - - return os; -} - -template -OutStreamT WritePointCloudIntoStream(const PointCloud *pc, OutStreamT &&os, - PointCloudEncodingMethod method) { - const EncoderOptions options = EncoderOptions::CreateDefaultOptions(); - return WritePointCloudIntoStream(pc, os, method, options); -} - -template -OutStreamT &WritePointCloudIntoStream(const PointCloud *pc, OutStreamT &&os) { - return WritePointCloudIntoStream(pc, os, POINT_CLOUD_SEQUENTIAL_ENCODING); -} - -template -InStreamT &ReadPointCloudFromStream(std::unique_ptr *point_cloud, - InStreamT &&is) { - // Determine size of stream and write into a vector - const auto start_pos = is.tellg(); - is.seekg(0, std::ios::end); - const std::streampos is_size = is.tellg() - start_pos; - is.seekg(start_pos); - std::vector data(is_size); - is.read(&data[0], is_size); - - // Create a point cloud from that data. - DecoderBuffer buffer; - buffer.Init(&data[0], data.size()); - Decoder decoder; - auto statusor = decoder.DecodePointCloudFromBuffer(&buffer); - *point_cloud = std::move(statusor).value(); - if (!statusor.ok() || *point_cloud == nullptr) { - is.setstate(std::ios_base::badbit); - } - - return is; -} - -// Reads a point cloud from a file. The function automatically chooses the -// correct decoder based on the extension of the files. Currently, .obj and .ply -// files are supported. Other file extensions are processed by the default -// draco::PointCloudDecoder. -// Returns nullptr with an error status if the decoding failed. -StatusOr> ReadPointCloudFromFile( - const std::string &file_name); - -} // namespace draco - -#endif // DRACO_IO_POINT_CLOUD_IO_H_ diff --git a/cloudreg_env/include/draco/javascript/emscripten/animation_decoder_webidl_wrapper.h b/cloudreg_env/include/draco/javascript/emscripten/animation_decoder_webidl_wrapper.h deleted file mode 100644 index 96f98ad..0000000 --- a/cloudreg_env/include/draco/javascript/emscripten/animation_decoder_webidl_wrapper.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_JAVASCRIPT_EMSCRITPEN_DECODER_WEBIDL_WRAPPER_H_ -#define DRACO_JAVASCRIPT_EMSCRITPEN_DECODER_WEBIDL_WRAPPER_H_ - -#include - -#include "draco/animation/keyframe_animation_decoder.h" -#include "draco/attributes/attribute_transform_type.h" -#include "draco/attributes/point_attribute.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/decode.h" -#include "draco/core/decoder_buffer.h" - -typedef draco::AttributeTransformType draco_AttributeTransformType; -typedef draco::GeometryAttribute draco_GeometryAttribute; -typedef draco_GeometryAttribute::Type draco_GeometryAttribute_Type; -typedef draco::EncodedGeometryType draco_EncodedGeometryType; -typedef draco::Status draco_Status; -typedef draco::Status::Code draco_StatusCode; - -class DracoFloat32Array { - public: - DracoFloat32Array(); - float GetValue(int index) const; - - // In case |values| is nullptr, the data is allocated but not initialized. - bool SetValues(const float *values, int count); - - // Directly sets a value for a specific index. The array has to be already - // allocated at this point (using SetValues() method). - void SetValue(int index, float val) { values_[index] = val; } - - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -// Class used by emscripten WebIDL Binder [1] to wrap calls to decode animation -// data. -class AnimationDecoder { - public: - AnimationDecoder(); - - // Decodes animation data from the provided buffer. - const draco::Status *DecodeBufferToKeyframeAnimation( - draco::DecoderBuffer *in_buffer, draco::KeyframeAnimation *animation); - - static bool GetTimestamps(const draco::KeyframeAnimation &animation, - DracoFloat32Array *timestamp); - - static bool GetKeyframes(const draco::KeyframeAnimation &animation, - int keyframes_id, DracoFloat32Array *animation_data); - - private: - draco::KeyframeAnimationDecoder decoder_; - draco::Status last_status_; -}; - -#endif // DRACO_JAVASCRIPT_EMSCRITPEN_DECODER_WEBIDL_WRAPPER_H_ diff --git a/cloudreg_env/include/draco/javascript/emscripten/animation_encoder_webidl_wrapper.h b/cloudreg_env/include/draco/javascript/emscripten/animation_encoder_webidl_wrapper.h deleted file mode 100644 index f2ac733..0000000 --- a/cloudreg_env/include/draco/javascript/emscripten/animation_encoder_webidl_wrapper.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_JAVASCRIPT_EMSCRIPTEN_ANIMATION_ENCODER_WEBIDL_WRAPPER_H_ -#define DRACO_JAVASCRIPT_EMSCRIPTEN_ANIMATION_ENCODER_WEBIDL_WRAPPER_H_ - -#include - -#include "draco/animation/keyframe_animation_encoder.h" -#include "draco/attributes/point_attribute.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/encoder_options.h" -#include "draco/compression/encode.h" - -class DracoInt8Array { - public: - DracoInt8Array(); - int GetValue(int index) const; - bool SetValues(const char *values, int count); - - size_t size() { return values_.size(); } - - private: - std::vector values_; -}; - -class AnimationBuilder { - public: - AnimationBuilder(); - - bool SetTimestamps(draco::KeyframeAnimation *animation, long num_frames, - const float *timestamps); - - int AddKeyframes(draco::KeyframeAnimation *animation, long num_frames, - long num_components, const float *animation_data); -}; - -class AnimationEncoder { - public: - AnimationEncoder(); - - void SetTimestampsQuantization(long quantization_bits); - // TODO: Use expert encoder to set per attribute quantization. - void SetKeyframesQuantization(long quantization_bits); - int EncodeAnimationToDracoBuffer(draco::KeyframeAnimation *animation, - DracoInt8Array *draco_buffer); - - private: - draco::KeyframeAnimationEncoder encoder_; - long timestamps_quantization_bits_; - long keyframes_quantization_bits_; - draco::EncoderOptions options_; -}; - -#endif // DRACO_JAVASCRIPT_EMSCRIPTEN_ANIMATION_ENCODER_WEBIDL_WRAPPER_H_ diff --git a/cloudreg_env/include/draco/javascript/emscripten/decoder_webidl_wrapper.h b/cloudreg_env/include/draco/javascript/emscripten/decoder_webidl_wrapper.h deleted file mode 100644 index ab3f0c8..0000000 --- a/cloudreg_env/include/draco/javascript/emscripten/decoder_webidl_wrapper.h +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_JAVASCRIPT_EMSCRITPEN_DECODER_WEBIDL_WRAPPER_H_ -#define DRACO_JAVASCRIPT_EMSCRITPEN_DECODER_WEBIDL_WRAPPER_H_ - -#include - -#include "draco/attributes/attribute_transform_type.h" -#include "draco/attributes/point_attribute.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/decode.h" -#include "draco/core/decoder_buffer.h" -#include "draco/mesh/mesh.h" - -typedef draco::AttributeTransformType draco_AttributeTransformType; -typedef draco::GeometryAttribute draco_GeometryAttribute; -typedef draco_GeometryAttribute::Type draco_GeometryAttribute_Type; -typedef draco::EncodedGeometryType draco_EncodedGeometryType; -typedef draco::Status draco_Status; -typedef draco::Status::Code draco_StatusCode; - -// To generate Draco JabvaScript bindings you must have emscripten installed. -// Then run make -f Makefile.emcc jslib. - -class MetadataQuerier { - public: - MetadataQuerier(); - - bool HasEntry(const draco::Metadata &metadata, const char *entry_name) const; - - // This function does not guarantee that entry's type is long. - long GetIntEntry(const draco::Metadata &metadata, - const char *entry_name) const; - - // This function does not guarantee that entry's type is double. - double GetDoubleEntry(const draco::Metadata &metadata, - const char *entry_name) const; - - // This function does not guarantee that entry's type is char*. - const char *GetStringEntry(const draco::Metadata &metadata, - const char *entry_name); - - long NumEntries(const draco::Metadata &metadata) const; - const char *GetEntryName(const draco::Metadata &metadata, int entry_id); - - private: - // Cached values for metadata entries. - std::vector entry_names_; - const draco::Metadata *entry_names_metadata_; - - // Cached value for GetStringEntry() to avoid scoping issues. - std::string last_string_returned_; -}; - -class DracoFloat32Array { - public: - DracoFloat32Array(); - float GetValue(int index) const; - - // In case |values| is nullptr, the data is allocated but not initialized. - bool SetValues(const float *values, int count); - - // Directly sets a value for a specific index. The array has to be already - // allocated at this point (using SetValues() method). - void SetValue(int index, float val) { values_[index] = val; } - - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -class DracoInt8Array { - public: - DracoInt8Array(); - - int8_t GetValue(int index) const; - bool SetValues(const int8_t *values, int count); - - void SetValue(int index, int8_t val) { values_[index] = val; } - - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -class DracoUInt8Array { - public: - DracoUInt8Array(); - uint8_t GetValue(int index) const; - bool SetValues(const uint8_t *values, int count); - - void SetValue(int index, uint8_t val) { values_[index] = val; } - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -class DracoInt16Array { - public: - DracoInt16Array(); - - int16_t GetValue(int index) const; - bool SetValues(const int16_t *values, int count); - - void SetValue(int index, int16_t val) { values_[index] = val; } - - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -class DracoUInt16Array { - public: - DracoUInt16Array(); - uint16_t GetValue(int index) const; - bool SetValues(const uint16_t *values, int count); - - void SetValue(int index, uint16_t val) { values_[index] = val; } - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -class DracoInt32Array { - public: - DracoInt32Array(); - - int32_t GetValue(int index) const; - bool SetValues(const int *values, int count); - - void SetValue(int index, int32_t val) { values_[index] = val; } - - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -class DracoUInt32Array { - public: - DracoUInt32Array(); - uint32_t GetValue(int index) const; - bool SetValues(const uint32_t *values, int count); - - void SetValue(int index, uint32_t val) { values_[index] = val; } - int size() const { return values_.size(); } - - private: - std::vector values_; -}; - -// Class used by emscripten WebIDL Binder [1] to wrap calls to decode Draco -// data. -// [1]http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html -class Decoder { - public: - Decoder(); - - // Returns the geometry type stored in the |in_buffer|. Return values can be - // INVALID_GEOMETRY_TYPE, POINT_CLOUD, or MESH. - draco_EncodedGeometryType GetEncodedGeometryType( - draco::DecoderBuffer *in_buffer); - - // Decodes a point cloud from the provided buffer. - const draco::Status *DecodeBufferToPointCloud( - draco::DecoderBuffer *in_buffer, draco::PointCloud *out_point_cloud); - - // Decodes a triangular mesh from the provided buffer. - const draco::Status *DecodeBufferToMesh(draco::DecoderBuffer *in_buffer, - draco::Mesh *out_mesh); - - // Returns an attribute id for the first attribute of a given type. - long GetAttributeId(const draco::PointCloud &pc, - draco_GeometryAttribute_Type type) const; - - // Returns an attribute id of an attribute that contains a valid metadata - // entry "name" with value |attribute_name|. - static long GetAttributeIdByName(const draco::PointCloud &pc, - const char *attribute_name); - - // Returns an attribute id of an attribute with a specified metadata pair - // <|metadata_name|, |metadata_value|>. - static long GetAttributeIdByMetadataEntry(const draco::PointCloud &pc, - const char *metadata_name, - const char *metadata_value); - - // Returns an attribute id of an attribute that has the unique id. - static const draco::PointAttribute *GetAttributeByUniqueId( - const draco::PointCloud &pc, long unique_id); - - // Returns a PointAttribute pointer from |att_id| index. - static const draco::PointAttribute *GetAttribute(const draco::PointCloud &pc, - long att_id); - - // Returns Mesh::Face values in |out_values| from |face_id| index. - static bool GetFaceFromMesh(const draco::Mesh &m, - draco::FaceIndex::ValueType face_id, - DracoInt32Array *out_values); - - // Returns triangle strips for mesh |m|. If there's multiple strips, - // the strips will be separated by degenerate faces. - static long GetTriangleStripsFromMesh(const draco::Mesh &m, - DracoInt32Array *strip_values); - - // Returns float attribute values in |out_values| from |entry_index| index. - static bool GetAttributeFloat( - const draco::PointAttribute &pa, - draco::AttributeValueIndex::ValueType entry_index, - DracoFloat32Array *out_values); - - // Returns float attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeFloatForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoFloat32Array *out_values); - - // Returns int8_t attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeInt8ForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoInt8Array *out_values); - - // Returns uint8_t attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeUInt8ForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoUInt8Array *out_values); - - // Returns int16_t attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeInt16ForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoInt16Array *out_values); - - // Returns uint16_t attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeUInt16ForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoUInt16Array *out_values); - - // Returns int32_t attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeInt32ForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoInt32Array *out_values); - - // Deprecated: Use GetAttributeInt32ForAllPoints() instead. - static bool GetAttributeIntForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoInt32Array *out_values); - - // Returns uint32_t attribute values for all point ids of the point cloud. - // I.e., the |out_values| is going to contain m.num_points() entries. - static bool GetAttributeUInt32ForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - DracoUInt32Array *out_values); - - // Tells the decoder to skip an attribute transform (e.g. dequantization) for - // an attribute of a given type. - void SkipAttributeTransform(draco_GeometryAttribute_Type att_type); - - const draco::Metadata *GetMetadata(const draco::PointCloud &pc) const; - const draco::Metadata *GetAttributeMetadata(const draco::PointCloud &pc, - long att_id) const; - - private: - template - static bool GetAttributeDataForAllPoints(const draco::PointCloud &pc, - const draco::PointAttribute &pa, - draco::DataType draco_signed_type, - draco::DataType draco_unsigned_type, - DracoArrayT *out_values) { - const int components = pa.num_components(); - const int num_points = pc.num_points(); - const int num_entries = num_points * components; - - if ((pa.data_type() == draco_signed_type || - pa.data_type() == draco_unsigned_type) && - pa.is_mapping_identity()) { - // Copy values directly to the output vector. - out_values->SetValues(reinterpret_cast( - pa.GetAddress(draco::AttributeValueIndex(0))), - num_entries); - return true; - } - - // Copy values one by one. - std::vector values(components); - int entry_id = 0; - - out_values->SetValues(nullptr, num_entries); - for (draco::PointIndex i(0); i < num_points; ++i) { - const draco::AttributeValueIndex val_index = pa.mapped_index(i); - if (!pa.ConvertValue(val_index, &values[0])) - return false; - for (int j = 0; j < components; ++j) { - out_values->SetValue(entry_id++, values[j]); - } - } - return true; - } - - draco::Decoder decoder_; - draco::Status last_status_; -}; - -#endif // DRACO_JAVASCRIPT_EMSCRITPEN_DECODER_WEBIDL_WRAPPER_H_ diff --git a/cloudreg_env/include/draco/javascript/emscripten/encoder_webidl_wrapper.h b/cloudreg_env/include/draco/javascript/emscripten/encoder_webidl_wrapper.h deleted file mode 100644 index 4db6cfc..0000000 --- a/cloudreg_env/include/draco/javascript/emscripten/encoder_webidl_wrapper.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_JAVASCRIPT_EMSCRITPEN_ENCODER_WEBIDL_WRAPPER_H_ -#define DRACO_JAVASCRIPT_EMSCRITPEN_ENCODER_WEBIDL_WRAPPER_H_ - -#include - -#include "draco/attributes/point_attribute.h" -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/config/encoder_options.h" -#include "draco/compression/encode.h" -#include "draco/compression/expert_encode.h" -#include "draco/mesh/mesh.h" - -typedef draco::GeometryAttribute draco_GeometryAttribute; -typedef draco::GeometryAttribute::Type draco_GeometryAttribute_Type; -typedef draco::EncodedGeometryType draco_EncodedGeometryType; -typedef draco::MeshEncoderMethod draco_MeshEncoderMethod; - -class DracoInt8Array { - public: - DracoInt8Array(); - int8_t GetValue(int index) const; - bool SetValues(const char *values, int count); - - size_t size() { return values_.size(); } - - private: - std::vector values_; -}; - -class MetadataBuilder { - public: - MetadataBuilder(); - bool AddStringEntry(draco::Metadata *metadata, const char *entry_name, - const char *entry_value); - bool AddIntEntry(draco::Metadata *metadata, const char *entry_name, - long entry_value); - bool AddDoubleEntry(draco::Metadata *metadata, const char *entry_name, - double entry_value); -}; - -class PointCloudBuilder { - public: - PointCloudBuilder() {} - int AddFloatAttribute(draco::PointCloud *pc, - draco_GeometryAttribute_Type type, long num_vertices, - long num_components, const float *att_values); - int AddInt8Attribute(draco::PointCloud *pc, draco_GeometryAttribute_Type type, - long num_vertices, long num_components, - const char *att_values); - int AddUInt8Attribute(draco::PointCloud *pc, - draco_GeometryAttribute_Type type, long num_vertices, - long num_components, const uint8_t *att_values); - int AddInt16Attribute(draco::PointCloud *pc, - draco_GeometryAttribute_Type type, long num_vertices, - long num_components, const int16_t *att_values); - int AddUInt16Attribute(draco::PointCloud *pc, - draco_GeometryAttribute_Type type, long num_vertices, - long num_components, const uint16_t *att_values); - int AddInt32Attribute(draco::PointCloud *pc, - draco_GeometryAttribute_Type type, long num_vertices, - long num_components, const int32_t *att_values); - int AddUInt32Attribute(draco::PointCloud *pc, - draco_GeometryAttribute_Type type, long num_vertices, - long num_components, const uint32_t *att_values); - bool SetMetadataForAttribute(draco::PointCloud *pc, long attribute_id, - const draco::Metadata *metadata); - bool AddMetadata(draco::PointCloud *pc, const draco::Metadata *metadata); - - private: - template - int AddAttribute(draco::PointCloud *pc, draco_GeometryAttribute_Type type, - long num_vertices, long num_components, - const DataTypeT *att_values, - draco::DataType draco_data_type) { - if (!pc) - return -1; - draco::PointAttribute att; - att.Init(type, NULL, num_components, draco_data_type, - /* normalized */ false, - /* stride */ sizeof(DataTypeT) * num_components, - /* byte_offset */ 0); - const int att_id = - pc->AddAttribute(att, /* identity_mapping */ true, num_vertices); - draco::PointAttribute *const att_ptr = pc->attribute(att_id); - - for (draco::PointIndex i(0); i < num_vertices; ++i) { - att_ptr->SetAttributeValue(att_ptr->mapped_index(i), - &att_values[i.value() * num_components]); - } - if (pc->num_points() == 0) { - pc->set_num_points(num_vertices); - } else if (pc->num_points() != num_vertices) { - return -1; - } - return att_id; - } -}; - -// TODO(draco-eng): Regenerate wasm decoder. -// TODO(draco-eng): Add script to generate and test all Javascipt code. -class MeshBuilder : public PointCloudBuilder { - public: - MeshBuilder(); - - bool AddFacesToMesh(draco::Mesh *mesh, long num_faces, const int *faces); - - // Deprecated: Use AddFloatAttribute() instead. - int AddFloatAttributeToMesh(draco::Mesh *mesh, - draco_GeometryAttribute_Type type, - long num_vertices, long num_components, - const float *att_values); - - // Deprecated: Use AddInt32Attribute() instead. - int AddInt32AttributeToMesh(draco::Mesh *mesh, - draco_GeometryAttribute_Type type, - long num_vertices, long num_components, - const int32_t *att_values); - - // Deprecated: Use AddMetadata() instead. - bool AddMetadataToMesh(draco::Mesh *mesh, const draco::Metadata *metadata); -}; - -class Encoder { - public: - Encoder(); - - void SetEncodingMethod(long method); - void SetAttributeQuantization(draco_GeometryAttribute_Type type, - long quantization_bits); - void SetAttributeExplicitQuantization(draco_GeometryAttribute_Type type, - long quantization_bits, - long num_components, - const float *origin, float range); - void SetSpeedOptions(long encoding_speed, long decoding_speed); - void SetTrackEncodedProperties(bool flag); - - int EncodeMeshToDracoBuffer(draco::Mesh *mesh, DracoInt8Array *buffer); - - int EncodePointCloudToDracoBuffer(draco::PointCloud *pc, - bool deduplicate_values, - DracoInt8Array *buffer); - int GetNumberOfEncodedPoints(); - int GetNumberOfEncodedFaces(); - - private: - draco::Encoder encoder_; -}; - -class ExpertEncoder { - public: - ExpertEncoder(draco::PointCloud *pc); - - void SetEncodingMethod(long method); - void SetAttributeQuantization(long att_id, long quantization_bits); - void SetAttributeExplicitQuantization(long att_id, long quantization_bits, - long num_components, - const float *origin, float range); - void SetSpeedOptions(long encoding_speed, long decoding_speed); - void SetTrackEncodedProperties(bool flag); - - int EncodeToDracoBuffer(bool deduplicate_values, DracoInt8Array *buffer); - - int GetNumberOfEncodedPoints(); - int GetNumberOfEncodedFaces(); - - private: - std::unique_ptr encoder_; - - draco::PointCloud *pc_; -}; - -#endif // DRACO_JAVASCRIPT_EMSCRITPEN_ENCODER_WEBIDL_WRAPPER_H_ diff --git a/cloudreg_env/include/draco/maya/draco_maya_plugin.h b/cloudreg_env/include/draco/maya/draco_maya_plugin.h deleted file mode 100644 index cd4fa69..0000000 --- a/cloudreg_env/include/draco/maya/draco_maya_plugin.h +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MAYA_PLUGIN_H_ -#define DRACO_MAYA_PLUGIN_H_ - -#include -#include "draco/compression/decode.h" -#include "draco/compression/encode.h" - -#ifdef BUILD_MAYA_PLUGIN - -// If compiling with Visual Studio. -#if defined(_MSC_VER) -#define EXPORT_API __declspec(dllexport) -#else -// Other platforms don't need this. -#define EXPORT_API -#endif // defined(_MSC_VER) - -namespace draco { -namespace maya { - -enum class EncodeResult { - OK = 0, - KO_WRONG_INPUT = -1, - KO_MESH_ENCODING = -2, - KO_FILE_CREATION = -3 -}; -enum class DecodeResult { - OK = 0, - KO_GEOMETRY_TYPE_INVALID = -1, - KO_TRIANGULAR_MESH_NOT_FOUND = -2, - KO_MESH_DECODING = -3 -}; - -extern "C" { -struct EXPORT_API Drc2PyMesh { - Drc2PyMesh() - : faces_num(0), - faces(nullptr), - vertices_num(0), - vertices(nullptr), - normals_num(0), - normals(nullptr), - uvs_num(0), - uvs_real_num(0), - uvs(nullptr) {} - int faces_num; - int *faces; - int vertices_num; - float *vertices; - int normals_num; - float *normals; - int uvs_num; - int uvs_real_num; - float *uvs; -}; - -EXPORT_API DecodeResult drc2py_decode(char *data, unsigned int length, - Drc2PyMesh **res_mesh); -EXPORT_API void drc2py_free(Drc2PyMesh **res_mesh); -EXPORT_API EncodeResult drc2py_encode(Drc2PyMesh *in_mesh, char *file_path); -} // extern "C" - -} // namespace maya -} // namespace draco - -#endif // BUILD_MAYA_PLUGIN - -#endif // DRACO_MAYA_PLUGIN_H_ diff --git a/cloudreg_env/include/draco/mesh/corner_table.h b/cloudreg_env/include/draco/mesh/corner_table.h deleted file mode 100644 index 704a7b1..0000000 --- a/cloudreg_env/include/draco/mesh/corner_table.h +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_CORNER_TABLE_H_ -#define DRACO_MESH_CORNER_TABLE_H_ - -#include -#include - -#include "draco/attributes/geometry_indices.h" -#include "draco/core/draco_index_type_vector.h" -#include "draco/core/macros.h" -#include "draco/mesh/valence_cache.h" - -namespace draco { - -// CornerTable is used to represent connectivity of triangular meshes. -// For every corner of all faces, the corner table stores the index of the -// opposite corner in the neighboring face (if it exists) as illustrated in the -// figure below (see corner |c| and it's opposite corner |o|). -// -// * -// /c\ -// / \ -// /n p\ -// *-------* -// \ / -// \ / -// \o/ -// * -// -// All corners are defined by unique CornerIndex and each triplet of corners -// that define a single face id always ordered consecutively as: -// { 3 * FaceIndex, 3 * FaceIndex + 1, 3 * FaceIndex +2 }. -// This representation of corners allows CornerTable to easily retrieve Next and -// Previous corners on any face (see corners |n| and |p| in the figure above). -// Using the Next, Previous, and Opposite corners then enables traversal of any -// 2-manifold surface. -// If the CornerTable is constructed from a non-manifold surface, the input -// non-manifold edges and vertices are automatically split. -class CornerTable { - public: - // Corner table face type. - typedef std::array FaceType; - - CornerTable(); - static std::unique_ptr Create( - const IndexTypeVector &faces); - - // Initializes the CornerTable from provides set of indexed faces. - // The input faces can represent a non-manifold topology, in which case the - // non-manifold edges and vertices are going to be split. - bool Init(const IndexTypeVector &faces); - - // Resets the corner table to the given number of invalid faces. - bool Reset(int num_faces); - - // Resets the corner table to the given number of invalid faces and vertices. - bool Reset(int num_faces, int num_vertices); - - inline int num_vertices() const { - return static_cast(vertex_corners_.size()); - } - inline int num_corners() const { - return static_cast(corner_to_vertex_map_.size()); - } - inline int num_faces() const { - return static_cast(corner_to_vertex_map_.size() / 3); - } - - inline CornerIndex Opposite(CornerIndex corner) const { - if (corner == kInvalidCornerIndex) - return corner; - return opposite_corners_[corner]; - } - inline CornerIndex Next(CornerIndex corner) const { - if (corner == kInvalidCornerIndex) - return corner; - return LocalIndex(++corner) ? corner : corner - 3; - } - inline CornerIndex Previous(CornerIndex corner) const { - if (corner == kInvalidCornerIndex) - return corner; - return LocalIndex(corner) ? corner - 1 : corner + 2; - } - inline VertexIndex Vertex(CornerIndex corner) const { - if (corner == kInvalidCornerIndex) - return kInvalidVertexIndex; - return ConfidentVertex(corner); - } - inline VertexIndex ConfidentVertex(CornerIndex corner) const { - DRACO_DCHECK_GE(corner.value(), 0); - DRACO_DCHECK_LT(corner.value(), num_corners()); - return corner_to_vertex_map_[corner]; - } - inline FaceIndex Face(CornerIndex corner) const { - if (corner == kInvalidCornerIndex) - return kInvalidFaceIndex; - return FaceIndex(corner.value() / 3); - } - inline CornerIndex FirstCorner(FaceIndex face) const { - if (face == kInvalidFaceIndex) - return kInvalidCornerIndex; - return CornerIndex(face.value() * 3); - } - inline std::array AllCorners(FaceIndex face) const { - const CornerIndex ci = CornerIndex(face.value() * 3); - return {{ci, ci + 1, ci + 2}}; - } - inline int LocalIndex(CornerIndex corner) const { return corner.value() % 3; } - - inline FaceType FaceData(FaceIndex face) const { - const CornerIndex first_corner = FirstCorner(face); - FaceType face_data; - for (int i = 0; i < 3; ++i) { - face_data[i] = corner_to_vertex_map_[first_corner + i]; - } - return face_data; - } - - void SetFaceData(FaceIndex face, FaceType data) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - const CornerIndex first_corner = FirstCorner(face); - for (int i = 0; i < 3; ++i) { - corner_to_vertex_map_[first_corner + i] = data[i]; - } - } - - // Returns the left-most corner of a single vertex 1-ring. If a vertex is not - // on a boundary (in which case it has a full 1-ring), this function returns - // any of the corners mapped to the given vertex. - inline CornerIndex LeftMostCorner(VertexIndex v) const { - return vertex_corners_[v]; - } - - // Returns the parent vertex index of a given corner table vertex. - VertexIndex VertexParent(VertexIndex vertex) const { - if (vertex.value() < static_cast(num_original_vertices_)) - return vertex; - return non_manifold_vertex_parents_[vertex - num_original_vertices_]; - } - - // Returns true if the corner is valid. - inline bool IsValid(CornerIndex c) const { - return Vertex(c) != kInvalidVertexIndex; - } - - // Returns the valence (or degree) of a vertex. - // Returns -1 if the given vertex index is not valid. - int Valence(VertexIndex v) const; - // Same as above but does not check for validity and does not return -1 - int ConfidentValence(VertexIndex v) const; - // Returns the valence of the vertex at the given corner. - inline int Valence(CornerIndex c) const { - if (c == kInvalidCornerIndex) - return -1; - return ConfidentValence(c); - } - inline int ConfidentValence(CornerIndex c) const { - DRACO_DCHECK_LT(c.value(), num_corners()); - return ConfidentValence(ConfidentVertex(c)); - } - - // Returns true if the specified vertex is on a boundary. - inline bool IsOnBoundary(VertexIndex vert) const { - const CornerIndex corner = LeftMostCorner(vert); - if (SwingLeft(corner) == kInvalidCornerIndex) - return true; - return false; - } - - // *-------* - // / \ / \ - // / \ / \ - // / sl\c/sr \ - // *-------v-------* - // Returns the corner on the adjacent face on the right that maps to - // the same vertex as the given corner (sr in the above diagram). - inline CornerIndex SwingRight(CornerIndex corner) const { - return Previous(Opposite(Previous(corner))); - } - // Returns the corner on the left face that maps to the same vertex as the - // given corner (sl in the above diagram). - inline CornerIndex SwingLeft(CornerIndex corner) const { - return Next(Opposite(Next(corner))); - } - - // Get opposite corners on the left and right faces respectively (see image - // below, where L and R are the left and right corners of a corner X. - // - // *-------*-------* - // \L /X\ R/ - // \ / \ / - // \ / \ / - // *-------* - inline CornerIndex GetLeftCorner(CornerIndex corner_id) const { - if (corner_id == kInvalidCornerIndex) - return kInvalidCornerIndex; - return Opposite(Previous(corner_id)); - } - inline CornerIndex GetRightCorner(CornerIndex corner_id) const { - if (corner_id == kInvalidCornerIndex) - return kInvalidCornerIndex; - return Opposite(Next(corner_id)); - } - - // Returns the number of new vertices that were created as a result of - // splitting of non-manifold vertices of the input geometry. - int NumNewVertices() const { return num_vertices() - num_original_vertices_; } - int NumOriginalVertices() const { return num_original_vertices_; } - - // Returns the number of faces with duplicated vertex indices. - int NumDegeneratedFaces() const { return num_degenerated_faces_; } - - // Returns the number of isolated vertices (vertices that have - // vertex_corners_ mapping set to kInvalidCornerIndex. - int NumIsolatedVertices() const { return num_isolated_vertices_; } - - bool IsDegenerated(FaceIndex face) const; - - // Methods that modify an existing corner table. - // Sets the opposite corner mapping between two corners. Caller must ensure - // that the indices are valid. - inline void SetOppositeCorner(CornerIndex corner_id, - CornerIndex opp_corner_id) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - opposite_corners_[corner_id] = opp_corner_id; - } - - // Sets opposite corners for both input corners. - inline void SetOppositeCorners(CornerIndex corner_0, CornerIndex corner_1) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - if (corner_0 != kInvalidCornerIndex) - SetOppositeCorner(corner_0, corner_1); - if (corner_1 != kInvalidCornerIndex) - SetOppositeCorner(corner_1, corner_0); - } - - // Updates mapping between a corner and a vertex. - inline void MapCornerToVertex(CornerIndex corner_id, VertexIndex vert_id) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - corner_to_vertex_map_[corner_id] = vert_id; - } - - VertexIndex AddNewVertex() { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - // Add a new invalid vertex. - vertex_corners_.push_back(kInvalidCornerIndex); - return VertexIndex(static_cast(vertex_corners_.size() - 1)); - } - - // Sets a new left most corner for a given vertex. - void SetLeftMostCorner(VertexIndex vert, CornerIndex corner) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - if (vert != kInvalidVertexIndex) - vertex_corners_[vert] = corner; - } - - // Updates the vertex to corner map on a specified vertex. This should be - // called in cases where the mapping may be invalid (e.g. when the corner - // table was constructed manually). - void UpdateVertexToCornerMap(VertexIndex vert) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - const CornerIndex first_c = vertex_corners_[vert]; - if (first_c == kInvalidCornerIndex) - return; // Isolated vertex. - CornerIndex act_c = SwingLeft(first_c); - CornerIndex c = first_c; - while (act_c != kInvalidCornerIndex && act_c != first_c) { - c = act_c; - act_c = SwingLeft(act_c); - } - if (act_c != first_c) { - vertex_corners_[vert] = c; - } - } - - // Sets the new number of vertices. It's a responsibility of the caller to - // ensure that no corner is mapped beyond the range of the new number of - // vertices. - inline void SetNumVertices(int num_vertices) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - vertex_corners_.resize(num_vertices, kInvalidCornerIndex); - } - - // Makes a vertex isolated (not attached to any corner). - void MakeVertexIsolated(VertexIndex vert) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - vertex_corners_[vert] = kInvalidCornerIndex; - } - - // Returns true if a vertex is not attached to any face. - inline bool IsVertexIsolated(VertexIndex v) const { - return LeftMostCorner(v) == kInvalidCornerIndex; - } - - // Makes a given face invalid (all corners are marked as invalid). - void MakeFaceInvalid(FaceIndex face) { - DRACO_DCHECK(GetValenceCache().IsCacheEmpty()); - if (face != kInvalidFaceIndex) { - const CornerIndex first_corner = FirstCorner(face); - for (int i = 0; i < 3; ++i) { - corner_to_vertex_map_[first_corner + i] = kInvalidVertexIndex; - } - } - } - - // Updates mapping between faces and a vertex using the corners mapped to - // the provided vertex. - void UpdateFaceToVertexMap(const VertexIndex vertex); - - // Allows access to an internal object for caching valences. The object can - // be instructed to cache or uncache all valences and then its interfaces - // queried directly for valences with differing performance/confidence - // qualities. If the mesh or table is modified the cache should be discarded - // and not relied on as it does not automatically update or invalidate for - // performance reasons. - const draco::ValenceCache &GetValenceCache() const { - return valence_cache_; - } - - private: - // Computes opposite corners mapping from the data stored in - // |corner_to_vertex_map_|. - bool ComputeOppositeCorners(int *num_vertices); - - // Finds and breaks non-manifold edges in the 1-ring neighborhood around - // vertices (vertices themselves will be split in the ComputeVertexCorners() - // function if necessary). - bool BreakNonManifoldEdges(); - - // Computes the lookup map for going from a vertex to a corner. This method - // can handle non-manifold vertices by splitting them into multiple manifold - // vertices. - bool ComputeVertexCorners(int num_vertices); - - // Each three consecutive corners represent one face. - IndexTypeVector corner_to_vertex_map_; - IndexTypeVector opposite_corners_; - IndexTypeVector vertex_corners_; - - int num_original_vertices_; - int num_degenerated_faces_; - int num_isolated_vertices_; - IndexTypeVector non_manifold_vertex_parents_; - - draco::ValenceCache valence_cache_; -}; - -// A special case to denote an invalid corner table triangle. -static constexpr CornerTable::FaceType kInvalidFace( - {{kInvalidVertexIndex, kInvalidVertexIndex, kInvalidVertexIndex}}); - -} // namespace draco - -#endif // DRACO_MESH_CORNER_TABLE_H_ diff --git a/cloudreg_env/include/draco/mesh/corner_table_iterators.h b/cloudreg_env/include/draco/mesh/corner_table_iterators.h deleted file mode 100644 index 65869db..0000000 --- a/cloudreg_env/include/draco/mesh/corner_table_iterators.h +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_CORNER_TABLE_ITERATORS_H_ -#define DRACO_MESH_CORNER_TABLE_ITERATORS_H_ - -#include "draco/mesh/corner_table.h" - -namespace draco { - -// Class for iterating over vertices in a 1-ring around the specified vertex. -template -class VertexRingIterator - : public std::iterator { - public: - // std::iterator interface requires a default constructor. - VertexRingIterator() - : corner_table_(nullptr), - start_corner_(kInvalidCornerIndex), - corner_(start_corner_), - left_traversal_(true) {} - - // Create the iterator from the provided corner table and the central vertex. - VertexRingIterator(const CornerTableT *table, VertexIndex vert_id) - : corner_table_(table), - start_corner_(table->LeftMostCorner(vert_id)), - corner_(start_corner_), - left_traversal_(true) {} - - // Gets the last visited ring vertex. - VertexIndex Vertex() const { - CornerIndex ring_corner = left_traversal_ ? corner_table_->Previous(corner_) - : corner_table_->Next(corner_); - return corner_table_->Vertex(ring_corner); - } - - // Returns true when all ring vertices have been visited. - bool End() const { return corner_ == kInvalidCornerIndex; } - - // Proceeds to the next ring vertex if possible. - void Next() { - if (left_traversal_) { - corner_ = corner_table_->SwingLeft(corner_); - if (corner_ == kInvalidCornerIndex) { - // Open boundary reached. - corner_ = start_corner_; - left_traversal_ = false; - } else if (corner_ == start_corner_) { - // End reached. - corner_ = kInvalidCornerIndex; - } - } else { - // Go to the right until we reach a boundary there (no explicit check - // is needed in this case). - corner_ = corner_table_->SwingRight(corner_); - } - } - - // std::iterator interface. - value_type operator*() const { return Vertex(); } - VertexRingIterator &operator++() { - Next(); - return *this; - } - VertexRingIterator operator++(int) { - const VertexRingIterator result = *this; - ++(*this); - return result; - } - bool operator!=(const VertexRingIterator &other) const { - return corner_ != other.corner_ || start_corner_ != other.start_corner_; - } - bool operator==(const VertexRingIterator &other) const { - return !this->operator!=(other); - } - - // Helper function for getting a valid end iterator. - static VertexRingIterator EndIterator(VertexRingIterator other) { - VertexRingIterator ret = other; - ret.corner_ = kInvalidCornerIndex; - return ret; - } - - private: - const CornerTableT *corner_table_; - // The first processed corner. - CornerIndex start_corner_; - // The last processed corner. - CornerIndex corner_; - // Traversal direction. - bool left_traversal_; -}; - -// Class for iterating over faces adjacent to the specified input face. -template -class FaceAdjacencyIterator - : public std::iterator { - public: - // std::iterator interface requires a default constructor. - FaceAdjacencyIterator() - : corner_table_(nullptr), - start_corner_(kInvalidCornerIndex), - corner_(start_corner_) {} - - // Create the iterator from the provided corner table and the central vertex. - FaceAdjacencyIterator(const CornerTableT *table, FaceIndex face_id) - : corner_table_(table), - start_corner_(table->FirstCorner(face_id)), - corner_(start_corner_) { - // We need to start with a corner that has a valid opposite face (if - // there is any such corner). - if (corner_table_->Opposite(corner_) == kInvalidCornerIndex) - FindNextFaceNeighbor(); - } - - // Gets the last visited adjacent face. - FaceIndex Face() const { - return corner_table_->Face(corner_table_->Opposite(corner_)); - } - - // Returns true when all adjacent faces have been visited. - bool End() const { return corner_ == kInvalidCornerIndex; } - - // Proceeds to the next adjacent face if possible. - void Next() { FindNextFaceNeighbor(); } - - // std::iterator interface. - value_type operator*() const { return Face(); } - FaceAdjacencyIterator &operator++() { - Next(); - return *this; - } - FaceAdjacencyIterator operator++(int) { - const FaceAdjacencyIterator result = *this; - ++(*this); - return result; - } - bool operator!=(const FaceAdjacencyIterator &other) const { - return corner_ != other.corner_ || start_corner_ != other.start_corner_; - } - bool operator==(const FaceAdjacencyIterator &other) const { - return !this->operator!=(other); - } - - // Helper function for getting a valid end iterator. - static FaceAdjacencyIterator EndIterator(FaceAdjacencyIterator other) { - FaceAdjacencyIterator ret = other; - ret.corner_ = kInvalidCornerIndex; - return ret; - } - - private: - // Finds the next corner with a valid opposite face. - void FindNextFaceNeighbor() { - while (corner_ != kInvalidCornerIndex) { - corner_ = corner_table_->Next(corner_); - if (corner_ == start_corner_) { - corner_ = kInvalidCornerIndex; - return; - } - if (corner_table_->Opposite(corner_) != kInvalidCornerIndex) { - // Valid opposite face. - return; - } - } - } - - const CornerTableT *corner_table_; - // The first processed corner. - CornerIndex start_corner_; - // The last processed corner. - CornerIndex corner_; -}; - -// Class for iterating over corners attached to a specified vertex. -template -class VertexCornersIterator - : public std::iterator { - public: - // std::iterator interface requires a default constructor. - VertexCornersIterator() - : corner_table_(nullptr), - start_corner_(-1), - corner_(start_corner_), - left_traversal_(true) {} - - // Create the iterator from the provided corner table and the central vertex. - VertexCornersIterator(const CornerTableT *table, VertexIndex vert_id) - : corner_table_(table), - start_corner_(table->LeftMostCorner(vert_id)), - corner_(start_corner_), - left_traversal_(true) {} - - // Create the iterator from the provided corner table and the first corner. - VertexCornersIterator(const CornerTableT *table, CornerIndex corner_id) - : corner_table_(table), - start_corner_(corner_id), - corner_(start_corner_), - left_traversal_(true) {} - - // Gets the last visited corner. - CornerIndex Corner() const { return corner_; } - - // Returns true when all ring vertices have been visited. - bool End() const { return corner_ == kInvalidCornerIndex; } - - // Proceeds to the next corner if possible. - void Next() { - if (left_traversal_) { - corner_ = corner_table_->SwingLeft(corner_); - if (corner_ == kInvalidCornerIndex) { - // Open boundary reached. - corner_ = corner_table_->SwingRight(start_corner_); - left_traversal_ = false; - } else if (corner_ == start_corner_) { - // End reached. - corner_ = kInvalidCornerIndex; - } - } else { - // Go to the right until we reach a boundary there (no explicit check - // is needed in this case). - corner_ = corner_table_->SwingRight(corner_); - } - } - - // std::iterator interface. - CornerIndex operator*() const { return Corner(); } - VertexCornersIterator &operator++() { - Next(); - return *this; - } - VertexCornersIterator operator++(int) { - const VertexCornersIterator result = *this; - ++(*this); - return result; - } - bool operator!=(const VertexCornersIterator &other) const { - return corner_ != other.corner_ || start_corner_ != other.start_corner_; - } - bool operator==(const VertexCornersIterator &other) const { - return !this->operator!=(other); - } - - // Helper function for getting a valid end iterator. - static VertexCornersIterator EndIterator(VertexCornersIterator other) { - VertexCornersIterator ret = other; - ret.corner_ = kInvalidCornerIndex; - return ret; - } - - protected: - const CornerTableT *corner_table() const { return corner_table_; } - CornerIndex start_corner() const { return start_corner_; } - CornerIndex &corner() { return corner_; } - bool is_left_traversal() const { return left_traversal_; } - void swap_traversal() { left_traversal_ = !left_traversal_; } - - private: - const CornerTableT *corner_table_; - // The first processed corner. - CornerIndex start_corner_; - // The last processed corner. - CornerIndex corner_; - // Traversal direction. - bool left_traversal_; -}; - -} // namespace draco - -#endif // DRACO_MESH_CORNER_TABLE_ITERATORS_H_ diff --git a/cloudreg_env/include/draco/mesh/mesh.h b/cloudreg_env/include/draco/mesh/mesh.h deleted file mode 100644 index b8ca535..0000000 --- a/cloudreg_env/include/draco/mesh/mesh.h +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_MESH_H_ -#define DRACO_MESH_MESH_H_ - -#include - -#include "draco/attributes/geometry_indices.h" -#include "draco/core/hash_utils.h" -#include "draco/core/macros.h" -#include "draco/core/status.h" -#include "draco/draco_features.h" -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -// List of different variants of mesh attributes. -enum MeshAttributeElementType { - // All corners attached to a vertex share the same attribute value. A typical - // example are the vertex positions and often vertex colors. - MESH_VERTEX_ATTRIBUTE = 0, - // The most general attribute where every corner of the mesh can have a - // different attribute value. Often used for texture coordinates or normals. - MESH_CORNER_ATTRIBUTE, - // All corners of a single face share the same value. - MESH_FACE_ATTRIBUTE -}; - -// Mesh class can be used to represent general triangular meshes. Internally, -// Mesh is just an extended PointCloud with extra connectivity data that defines -// what points are connected together in triangles. -class Mesh : public PointCloud { - public: - typedef std::array Face; - - Mesh(); - - void AddFace(const Face &face) { faces_.push_back(face); } - - void SetFace(FaceIndex face_id, const Face &face) { - if (face_id >= static_cast(faces_.size())) { - faces_.resize(face_id.value() + 1, Face()); - } - faces_[face_id] = face; - } - - // Sets the total number of faces. Creates new empty faces or deletes - // existing ones if necessary. - void SetNumFaces(size_t num_faces) { faces_.resize(num_faces, Face()); } - - FaceIndex::ValueType num_faces() const { - return static_cast(faces_.size()); - } - const Face &face(FaceIndex face_id) const { - DRACO_DCHECK_LE(0, face_id.value()); - DRACO_DCHECK_LT(face_id.value(), static_cast(faces_.size())); - return faces_[face_id]; - } - - void SetAttribute(int att_id, std::unique_ptr pa) override { - PointCloud::SetAttribute(att_id, std::move(pa)); - if (static_cast(attribute_data_.size()) <= att_id) { - attribute_data_.resize(att_id + 1); - } - } - - void DeleteAttribute(int att_id) override { - PointCloud::DeleteAttribute(att_id); - if (att_id >= 0 && att_id < static_cast(attribute_data_.size())) { - attribute_data_.erase(attribute_data_.begin() + att_id); - } - } - - MeshAttributeElementType GetAttributeElementType(int att_id) const { - return attribute_data_[att_id].element_type; - } - - void SetAttributeElementType(int att_id, MeshAttributeElementType et) { - attribute_data_[att_id].element_type = et; - } - - // Returns the point id of for a corner |ci|. - inline PointIndex CornerToPointId(int ci) const { - if (ci == kInvalidCornerIndex.value()) - return kInvalidPointIndex; - return this->face(FaceIndex(ci / 3))[ci % 3]; - } - - // Returns the point id of a corner |ci|. - inline PointIndex CornerToPointId(CornerIndex ci) const { - return this->CornerToPointId(ci.value()); - } - - struct AttributeData { - AttributeData() : element_type(MESH_CORNER_ATTRIBUTE) {} - MeshAttributeElementType element_type; - }; - - protected: -#ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED - // Extends the point deduplication to face corners. This method is called from - // the PointCloud::DeduplicatePointIds() and it remaps all point ids stored in - // |faces_| to the new deduplicated point ids using the map |id_map|. - void ApplyPointIdDeduplication( - const IndexTypeVector &id_map, - const std::vector &unique_point_ids) override; -#endif - - private: - // Mesh specific per-attribute data. - std::vector attribute_data_; - - // Vertex indices valid for all attributes. Each attribute has its own map - // that converts vertex indices into attribute indices. - IndexTypeVector faces_; - - friend struct MeshHasher; -}; - -// Functor for computing a hash from data stored within a mesh. -// Note that this can be quite slow. Two meshes will have the same hash only -// when they have exactly the same connectivity and attribute values. -struct MeshHasher { - size_t operator()(const Mesh &mesh) const { - PointCloudHasher pc_hasher; - size_t hash = pc_hasher(mesh); - // Hash faces. - for (FaceIndex i(0); i < static_cast(mesh.faces_.size()); ++i) { - for (int j = 0; j < 3; ++j) { - hash = HashCombine(mesh.faces_[i][j].value(), hash); - } - } - return hash; - } -}; - -} // namespace draco - -#endif // DRACO_MESH_MESH_H_ diff --git a/cloudreg_env/include/draco/mesh/mesh_are_equivalent.h b/cloudreg_env/include/draco/mesh/mesh_are_equivalent.h deleted file mode 100644 index 71ef4a9..0000000 --- a/cloudreg_env/include/draco/mesh/mesh_are_equivalent.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_MESH_ARE_EQUIVALENT_H_ -#define DRACO_MESH_MESH_ARE_EQUIVALENT_H_ - -#include "draco/core/vector_d.h" -#include "draco/mesh/mesh.h" - -// This file defines a functor to compare two meshes for equivalency up -// to permutation of the vertices. -namespace draco { - -// A functor to compare two meshes for equivalency up to permutation of the -// vertices. -class MeshAreEquivalent { - public: - // Returns true if both meshes are equivalent up to permutation of - // the internal order of vertices. This includes all attributes. - bool operator()(const Mesh &mesh0, const Mesh &mesh1); - - private: - // Internal type to keep overview. - struct MeshInfo { - explicit MeshInfo(const Mesh &in_mesh) : mesh(in_mesh) {} - const Mesh &mesh; - std::vector ordered_index_of_face; - IndexTypeVector corner_index_of_smallest_vertex; - }; - - // Prepare functor for actual comparison. - void Init(const Mesh &mesh0, const Mesh &mesh1); - - // Get position as Vector3f of corner c of face f. - static Vector3f GetPosition(const Mesh &mesh, FaceIndex f, int32_t c); - // Internal helper function mostly for debugging. - void PrintPosition(const Mesh &mesh, FaceIndex f, int32_t c); - // Get the corner index of the lex smallest vertex of face f. - static int32_t ComputeCornerIndexOfSmallestPointXYZ(const Mesh &mesh, - FaceIndex f); - - // Less compare functor for two faces (represented by their indices) - // with respect to their lex order. - struct FaceIndexLess { - explicit FaceIndexLess(const MeshInfo &in_mesh_info) - : mesh_info(in_mesh_info) {} - bool operator()(FaceIndex f0, FaceIndex f1) const; - const MeshInfo &mesh_info; - }; - - void InitCornerIndexOfSmallestPointXYZ(); - void InitOrderedFaceIndex(); - - std::vector mesh_infos_; - int32_t num_faces_; -}; - -} // namespace draco - -#endif // DRACO_MESH_MESH_ARE_EQUIVALENT_H_ diff --git a/cloudreg_env/include/draco/mesh/mesh_attribute_corner_table.h b/cloudreg_env/include/draco/mesh/mesh_attribute_corner_table.h deleted file mode 100644 index b9e938f..0000000 --- a/cloudreg_env/include/draco/mesh/mesh_attribute_corner_table.h +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_MESH_ATTRIBUTE_CORNER_TABLE_H_ -#define DRACO_MESH_MESH_ATTRIBUTE_CORNER_TABLE_H_ - -#include "draco/core/macros.h" -#include "draco/mesh/corner_table.h" -#include "draco/mesh/mesh.h" -#include "draco/mesh/valence_cache.h" - -namespace draco { - -// Class for storing connectivity of mesh attributes. The connectivity is stored -// as a difference from the base mesh's corner table, where the differences are -// represented by attribute seam edges. This class provides a basic -// functionality for detecting the seam edges for a given attribute and for -// traversing the constrained corner table with the seam edges. -class MeshAttributeCornerTable { - public: - MeshAttributeCornerTable(); - bool InitEmpty(const CornerTable *table); - bool InitFromAttribute(const Mesh *mesh, const CornerTable *table, - const PointAttribute *att); - - void AddSeamEdge(CornerIndex opp_corner); - - // Recomputes vertices using the newly added seam edges (needs to be called - // whenever the seam edges are updated). - // |mesh| and |att| can be null, in which case mapping between vertices and - // attribute value ids is set to identity. - void RecomputeVertices(const Mesh *mesh, const PointAttribute *att); - - inline bool IsCornerOppositeToSeamEdge(CornerIndex corner) const { - return is_edge_on_seam_[corner.value()]; - } - - inline CornerIndex Opposite(CornerIndex corner) const { - if (corner == kInvalidCornerIndex || IsCornerOppositeToSeamEdge(corner)) - return kInvalidCornerIndex; - return corner_table_->Opposite(corner); - } - - inline CornerIndex Next(CornerIndex corner) const { - return corner_table_->Next(corner); - } - - inline CornerIndex Previous(CornerIndex corner) const { - return corner_table_->Previous(corner); - } - - // Returns true when a corner is attached to any attribute seam. - inline bool IsCornerOnSeam(CornerIndex corner) const { - return is_vertex_on_seam_[corner_table_->Vertex(corner).value()]; - } - - // Similar to CornerTable::GetLeftCorner and CornerTable::GetRightCorner, but - // does not go over seam edges. - inline CornerIndex GetLeftCorner(CornerIndex corner) const { - return Opposite(Previous(corner)); - } - inline CornerIndex GetRightCorner(CornerIndex corner) const { - return Opposite(Next(corner)); - } - - // Similar to CornerTable::SwingRight, but it does not go over seam edges. - inline CornerIndex SwingRight(CornerIndex corner) const { - return Previous(Opposite(Previous(corner))); - } - - // Similar to CornerTable::SwingLeft, but it does not go over seam edges. - inline CornerIndex SwingLeft(CornerIndex corner) const { - return Next(Opposite(Next(corner))); - } - - int num_vertices() const { - return static_cast(vertex_to_attribute_entry_id_map_.size()); - } - int num_faces() const { return static_cast(corner_table_->num_faces()); } - - VertexIndex Vertex(CornerIndex corner) const { - DRACO_DCHECK_LT(corner.value(), corner_to_vertex_map_.size()); - return ConfidentVertex(corner); - } - VertexIndex ConfidentVertex(CornerIndex corner) const { - return corner_to_vertex_map_[corner.value()]; - } - // Returns the attribute entry id associated to the given vertex. - VertexIndex VertexParent(VertexIndex vert) const { - return VertexIndex(vertex_to_attribute_entry_id_map_[vert.value()].value()); - } - - inline CornerIndex LeftMostCorner(VertexIndex v) const { - return vertex_to_left_most_corner_map_[v.value()]; - } - - inline bool IsOnBoundary(VertexIndex vert) const { - const CornerIndex corner = LeftMostCorner(vert); - if (corner == kInvalidCornerIndex) - return true; - return IsCornerOnSeam(corner); - } - - bool no_interior_seams() const { return no_interior_seams_; } - const CornerTable *corner_table() const { return corner_table_; } - - // TODO(draco-eng): extract valence functions into a reusable class/object - // also from 'corner_table.*' - - // Returns the valence (or degree) of a vertex. - // Returns -1 if the given vertex index is not valid. - int Valence(VertexIndex v) const; - // Same as above but does not check for validity and does not return -1 - int ConfidentValence(VertexIndex v) const; - // Returns the valence of the vertex at the given corner. - inline int Valence(CornerIndex c) const { - DRACO_DCHECK_LT(c.value(), corner_table_->num_corners()); - if (c == kInvalidCornerIndex) - return -1; - return ConfidentValence(c); - } - inline int ConfidentValence(CornerIndex c) const { - DRACO_DCHECK_LT(c.value(), corner_table_->num_corners()); - return ConfidentValence(Vertex(c)); - } - - // Allows access to an internal object for caching valences. The object can - // be instructed to cache or uncache all valences and then its interfaces - // queried directly for valences with differing performance/confidence - // qualities. If the mesh or table is modified the cache should be discarded - // and not relied on as it does not automatically update or invalidate for - // performance reasons. - const ValenceCache &GetValenceCache() const { - return valence_cache_; - } - - private: - template - void RecomputeVerticesInternal(const Mesh *mesh, const PointAttribute *att); - - std::vector is_edge_on_seam_; - std::vector is_vertex_on_seam_; - - // If this is set to true, it means that there are no attribute seams between - // two faces. This can be used to speed up some algorithms. - bool no_interior_seams_; - - std::vector corner_to_vertex_map_; - - // Map between vertices and their associated left most corners. A left most - // corner is a corner that is adjacent to a boundary or an attribute seam from - // right (i.e., SwingLeft from that corner will return an invalid corner). If - // no such corner exists for a given vertex, then any corner attached to the - // vertex can be used. - std::vector vertex_to_left_most_corner_map_; - - // Map between vertex ids and attribute entry ids (i.e. the values stored in - // the attribute buffer). The attribute entry id can be retrieved using the - // VertexParent() method. - std::vector vertex_to_attribute_entry_id_map_; - const CornerTable *corner_table_; - ValenceCache valence_cache_; -}; - -} // namespace draco -#endif // DRACO_MESH_MESH_ATTRIBUTE_CORNER_TABLE_H_ diff --git a/cloudreg_env/include/draco/mesh/mesh_cleanup.h b/cloudreg_env/include/draco/mesh/mesh_cleanup.h deleted file mode 100644 index b56129d..0000000 --- a/cloudreg_env/include/draco/mesh/mesh_cleanup.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_MESH_CLEANUP_H_ -#define DRACO_MESH_MESH_CLEANUP_H_ - -#include "draco/mesh/mesh.h" - -namespace draco { - -// Options used by the MeshCleanup class. -struct MeshCleanupOptions { - MeshCleanupOptions() - : remove_degenerated_faces(true), remove_unused_attributes(true) {} - // If true, the cleanup tool removes any face where two or more vertices - // share the same position index. - bool remove_degenerated_faces; - // If true, the cleanup tool removes any unused attribute value or unused - // point id. For example, it can be used to remove isolated vertices. - bool remove_unused_attributes; -}; - -// Tool that can be used for removing bad or unused data from draco::Meshes. -class MeshCleanup { - public: - // Performs in-place cleanup of the input mesh according to the input options. - bool operator()(Mesh *mesh, const MeshCleanupOptions &options); -}; - -} // namespace draco - -#endif // DRACO_MESH_MESH_CLEANUP_H_ diff --git a/cloudreg_env/include/draco/mesh/mesh_misc_functions.h b/cloudreg_env/include/draco/mesh/mesh_misc_functions.h deleted file mode 100644 index b972109..0000000 --- a/cloudreg_env/include/draco/mesh/mesh_misc_functions.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// This file contains misc functions that are needed by several mesh related -// algorithms. - -#ifndef DRACO_MESH_MESH_MISC_FUNCTIONS_H_ -#define DRACO_MESH_MESH_MISC_FUNCTIONS_H_ - -#include "draco/mesh/corner_table.h" -#include "draco/mesh/mesh.h" - -// The file contains functions that use both Mesh and CornerTable as inputs. -namespace draco { - -// Creates a CornerTable from the position attribute of |mesh|. Returns nullptr -// on error. -std::unique_ptr CreateCornerTableFromPositionAttribute( - const Mesh *mesh); - -// Creates a CornerTable from all attributes of |mesh|. Boundaries are -// automatically introduced on all attribute seams. Returns nullptr on error. -std::unique_ptr CreateCornerTableFromAllAttributes( - const Mesh *mesh); - -// Returns true when the given corner lies opposite to an attribute seam. -inline bool IsCornerOppositeToAttributeSeam(CornerIndex ci, - const PointAttribute &att, - const Mesh &mesh, - const CornerTable &ct) { - const CornerIndex opp_ci = ct.Opposite(ci); - if (opp_ci == kInvalidCornerIndex) - return false; // No opposite corner == no attribute seam. - // Compare attribute value indices on both ends of the opposite edge. - CornerIndex c0 = ct.Next(ci); - CornerIndex c1 = ct.Previous(opp_ci); - if (att.mapped_index(mesh.CornerToPointId(c0)) != - att.mapped_index(mesh.CornerToPointId(c1))) - return true; - c0 = ct.Previous(ci); - c1 = ct.Next(opp_ci); - if (att.mapped_index(mesh.CornerToPointId(c0)) != - att.mapped_index(mesh.CornerToPointId(c1))) - return true; - return false; -} - -// Interpolates an attribute value on a face using given barycentric -// coordinates. InterpolatedVectorT should be a VectorD that corresponds to the -// values stored in the attribute. -// TODO(ostava): Find a better place for this. -template -InterpolatedVectorT ComputeInterpolatedAttributeValueOnMeshFace( - const Mesh &mesh, const PointAttribute &attribute, FaceIndex fi, - const std::array &barycentric_coord) { - const Mesh::Face &face = mesh.face(fi); - // Get values for all three corners of the face. - InterpolatedVectorT val[3]; - for (int c = 0; c < 3; ++c) { - attribute.GetMappedValue(face[c], &(val[c][0])); - } - // Return an interpolated value. - return barycentric_coord[0] * val[0] + barycentric_coord[1] * val[1] + - barycentric_coord[2] * val[2]; -} - -} // namespace draco - -#endif // DRACO_MESH_MESH_MISC_FUNCTIONS_H_ diff --git a/cloudreg_env/include/draco/mesh/mesh_stripifier.h b/cloudreg_env/include/draco/mesh/mesh_stripifier.h deleted file mode 100644 index f7c1ead..0000000 --- a/cloudreg_env/include/draco/mesh/mesh_stripifier.h +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_SRC_DRACO_MESH_MESH_STRIPIFIER_H_ -#define DRACO_SRC_DRACO_MESH_MESH_STRIPIFIER_H_ - -#include "draco/mesh/mesh_misc_functions.h" - -namespace draco { - -// Class that generates triangle strips from a provided draco::Mesh data -// structure. The strips represent a more memory efficient storage of triangle -// connectivity that can be used directly on the GPU (see -// https://en.wikipedia.org/wiki/Triangle_strip ). In general, a mesh needs to -// be represented by several triangle strips and it has been proven that finding -// the optimal set of triangle strips is an NP-complete problem. The algorithm -// implemented by this class finds this set of triangle strips based on a greedy -// heuristic that always selects the longest available strip that covers the -// next unprocessed face. The longest strip is found by analyzing all strips -// that can cover the given face (three strips corresponding to three -// directions). -class MeshStripifier { - public: - MeshStripifier() - : mesh_(nullptr), - num_strips_(0), - num_encoded_faces_(0), - last_encoded_point_(kInvalidPointIndex) {} - - // Generate triangle strips for a given mesh and output them to the output - // iterator |out_it|. In most cases |out_it| stores the values in a buffer - // that can be used directly on the GPU. Note that the algorithm can generate - // multiple strips to represent the whole mesh. In such cases multiple strips - // are separated using a so called primitive restart index that is specified - // by the |primitive_restart_index| (usually defined as the maximum allowed - // value for the given type). - // https://www.khronos.org/opengl/wiki/Vertex_Rendering#Primitive_Restart - template - bool GenerateTriangleStripsWithPrimitiveRestart( - const Mesh &mesh, IndexTypeT primitive_restart_index, - OutputIteratorT out_it); - - // The same as above but disjoint triangle strips are separated by degenerate - // triangles instead of the primitive restart index. Degenerate triangles are - // zero area triangles that are automatically discarded by the GPU. Using - // degenerate triangles usually results in a slightly longer output indices - // array compared to the similar triangle strips that use primitive restart - // index. The advantage of this method is that it is supported by all hardware - // and all relevant APIs (including WebGL 1.0). - template - bool GenerateTriangleStripsWithDegenerateTriangles(const Mesh &mesh, - OutputIteratorT out_it); - - // Returns the number of strips generated by the last call of the - // GenerateTriangleStrips() method. - int num_strips() const { return num_strips_; } - - private: - bool Prepare(const Mesh &mesh) { - mesh_ = &mesh; - num_strips_ = 0; - num_encoded_faces_ = 0; - // TODO(ostava): We may be able to avoid computing the corner table if we - // already have it stored somewhere. - corner_table_ = CreateCornerTableFromPositionAttribute(mesh_); - if (corner_table_ == nullptr) - return false; - - // Mark all faces as unvisited. - is_face_visited_.assign(mesh.num_faces(), false); - return true; - } - - // Returns local id of the longest strip that can be created from the given - // face |fi|. - int FindLongestStripFromFace(FaceIndex fi) { - // There are three possible strip directions that can contain the provided - // input face. We try all of them and select the direction that result in - // the longest strip. - const CornerIndex first_ci = corner_table_->FirstCorner(fi); - int longest_strip_id = -1; - int longest_strip_length = 0; - for (int i = 0; i < 3; ++i) { - GenerateStripsFromCorner(i, first_ci + i); - if (strip_faces_[i].size() > longest_strip_length) { - longest_strip_length = static_cast(strip_faces_[i].size()); - longest_strip_id = i; - } - } - return longest_strip_id; - } - - // Generates strip from the data stored in |strip_faces_| and - // |strip_start_start_corners_| and stores it to |out_it|. - template - void StoreStrip(int local_strip_id, OutputIteratorT out_it) { - ++num_strips_; - - const int num_strip_faces = strip_faces_[local_strip_id].size(); - CornerIndex ci = strip_start_corners_[local_strip_id]; - for (int i = 0; i < num_strip_faces; ++i) { - const FaceIndex fi = corner_table_->Face(ci); - is_face_visited_[fi] = true; - ++num_encoded_faces_; - - if (i == 0) { - // Add the start face (three indices). - *out_it++ = CornerToPointIndex(ci).value(); - *out_it++ = CornerToPointIndex(corner_table_->Next(ci)).value(); - last_encoded_point_ = CornerToPointIndex(corner_table_->Previous(ci)); - *out_it++ = last_encoded_point_.value(); - } else { - // Store the point on the newly reached corner. - last_encoded_point_ = CornerToPointIndex(ci); - *out_it++ = last_encoded_point_.value(); - - // Go to the correct source corner to proceed to the next face. - if (i & 1) { - ci = corner_table_->Previous(ci); - } else { - ci = corner_table_->Next(ci); - } - } - ci = corner_table_->Opposite(ci); - } - } - - PointIndex CornerToPointIndex(CornerIndex ci) const { - return mesh_->CornerToPointId(ci); - } - - // Returns the opposite corner in case the opposite triangle does not lie - // across an attribute seam. Otherwise return kInvalidCornerIndex. - CornerIndex GetOppositeCorner(CornerIndex ci) const { - const CornerIndex oci = corner_table_->Opposite(ci); - if (oci < 0) - return kInvalidCornerIndex; - // Ensure the point ids are same on both sides of the shared edge between - // the triangles. - if (CornerToPointIndex(corner_table_->Next(ci)) != - CornerToPointIndex(corner_table_->Previous(oci))) - return kInvalidCornerIndex; - if (CornerToPointIndex(corner_table_->Previous(ci)) != - CornerToPointIndex(corner_table_->Next(oci))) - return kInvalidCornerIndex; - return oci; - } - - void GenerateStripsFromCorner(int local_strip_id, CornerIndex ci); - - const Mesh *mesh_; - std::unique_ptr corner_table_; - - // Store strip faces for each of three possible directions from a given face. - std::vector strip_faces_[3]; - // Start corner for each direction of the strip containing the processed face. - CornerIndex strip_start_corners_[3]; - IndexTypeVector is_face_visited_; - // The number of strips generated by this method. - int num_strips_; - // The number of encoded triangles. - int num_encoded_faces_; - // Last encoded point. - PointIndex last_encoded_point_; -}; - -template -bool MeshStripifier::GenerateTriangleStripsWithPrimitiveRestart( - const Mesh &mesh, IndexTypeT primitive_restart_index, - OutputIteratorT out_it) { - if (!Prepare(mesh)) - return false; - - // Go over all faces and generate strips from the first unvisited one. - for (FaceIndex fi(0); fi < mesh.num_faces(); ++fi) { - if (is_face_visited_[fi]) - continue; - - const int longest_strip_id = FindLongestStripFromFace(fi); - - // Separate triangle strips with the primitive restart index. - if (num_strips_ > 0) { - *out_it++ = primitive_restart_index; - } - - StoreStrip(longest_strip_id, out_it); - } - - return true; -} - -template -bool MeshStripifier::GenerateTriangleStripsWithDegenerateTriangles( - const Mesh &mesh, OutputIteratorT out_it) { - if (!Prepare(mesh)) - return false; - - // Go over all faces and generate strips from the first unvisited one. - for (FaceIndex fi(0); fi < mesh.num_faces(); ++fi) { - if (is_face_visited_[fi]) - continue; - - const int longest_strip_id = FindLongestStripFromFace(fi); - - // Separate triangle strips by degenerate triangles. There will be either - // three or four degenerate triangles inserted based on the number of - // triangles that are already encoded in the output strip (three degenerate - // triangles for even number of existing triangles, four degenerate - // triangles for odd number of triangles). - if (num_strips_ > 0) { - // Duplicate last encoded index (first degenerate face). - *out_it++ = last_encoded_point_.value(); - - // Connect it to the start point of the new triangle strip (second - // degenerate face). - const CornerIndex new_start_corner = - strip_start_corners_[longest_strip_id]; - const PointIndex new_start_point = CornerToPointIndex(new_start_corner); - *out_it++ = new_start_point.value(); - num_encoded_faces_ += 2; - // If we have previously encoded number of faces we need to duplicate the - // point one more time to preserve the correct orientation of the next - // strip. - if (num_encoded_faces_ & 1) { - *out_it++ = new_start_point.value(); - num_encoded_faces_ += 1; - } - // The last degenerate face will be added implicitly in the StoreStrip() - // function below as the first point index is going to be encoded there - // again. - } - - StoreStrip(longest_strip_id, out_it); - } - - return true; -} - -} // namespace draco - -#endif // DRACO_SRC_DRACO_MESH_MESH_STRIPIFIER_H_ diff --git a/cloudreg_env/include/draco/mesh/triangle_soup_mesh_builder.h b/cloudreg_env/include/draco/mesh/triangle_soup_mesh_builder.h deleted file mode 100644 index 3ae652c..0000000 --- a/cloudreg_env/include/draco/mesh/triangle_soup_mesh_builder.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_ -#define DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_ - -#include "draco/draco_features.h" - -#include "draco/mesh/mesh.h" - -namespace draco { - -// Class for building meshes directly from attribute values that can be -// specified for each face corner. All attributes are automatically -// deduplicated. -class TriangleSoupMeshBuilder { - public: - // Starts mesh building for a given number of faces. - // TODO(ostava): Currently it's necessary to select the correct number of - // faces upfront. This should be generalized, but it will require us to - // rewrite our attribute resizing functions. - void Start(int num_faces); - - // Adds an empty attribute to the mesh. Returns the new attribute's id. - int AddAttribute(GeometryAttribute::Type attribute_type, - int8_t num_components, DataType data_type); - - // Sets values for a given attribute on all corners of a given face. - void SetAttributeValuesForFace(int att_id, FaceIndex face_id, - const void *corner_value_0, - const void *corner_value_1, - const void *corner_value_2); - - // Sets value for a per-face attribute. If all faces of a given attribute are - // set with this method, the attribute will be marked as per-face, otherwise - // it will be marked as per-corner attribute. - void SetPerFaceAttributeValueForFace(int att_id, FaceIndex face_id, - const void *value); - - // Finalizes the mesh or returns nullptr on error. - // Once this function is called, the builder becomes invalid and cannot be - // used until the method Start() is called again. - std::unique_ptr Finalize(); - - private: - std::vector attribute_element_types_; - - std::unique_ptr mesh_; -}; - -} // namespace draco - -#endif // DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_ diff --git a/cloudreg_env/include/draco/mesh/valence_cache.h b/cloudreg_env/include/draco/mesh/valence_cache.h deleted file mode 100644 index f75d66f..0000000 --- a/cloudreg_env/include/draco/mesh/valence_cache.h +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_MESH_VALENCE_CACHE_H_ -#define DRACO_MESH_VALENCE_CACHE_H_ - -#include "draco/attributes/geometry_indices.h" -#include "draco/core/draco_index_type_vector.h" -#include "draco/core/macros.h" - -namespace draco { - -// ValenceCache provides support for the caching of valences off of some kind of -// CornerTable 'type' of class. -// No valences should be queried before Caching is -// performed and values should be removed/recached when changes to the -// underlying mesh are taking place. - -template -class ValenceCache { - const CornerTableT &table_; - - public: - explicit ValenceCache(const CornerTableT &table) : table_(table) {} - - // Do not call before CacheValences() / CacheValencesInaccurate(). - inline int8_t ValenceFromCacheInaccurate(CornerIndex c) const { - if (c == kInvalidCornerIndex) - return -1; - return ValenceFromCacheInaccurate(table_.Vertex(c)); - } - inline int32_t ValenceFromCache(CornerIndex c) const { - if (c == kInvalidCornerIndex) - return -1; - return ValenceFromCache(table_.Vertex(c)); - } - - inline int32_t ConfidentValenceFromCache(VertexIndex v) const { - DRACO_DCHECK_LT(v.value(), table_.num_vertices()); - DRACO_DCHECK_EQ(vertex_valence_cache_32_bit_.size(), table_.num_vertices()); - return vertex_valence_cache_32_bit_[v]; - } - - // Collect the valence for all vertices so they can be reused later. The - // 'inaccurate' versions of this family of functions clips the true valence - // of the vertices to 8 signed bits as a space optimization. This clipping - // will lead to occasionally wrong results. If accurate results are required - // under all circumstances, do not use the 'inaccurate' version or else - // use it and fetch the correct result in the event the value appears clipped. - // The topology of the mesh should be a constant when Valence Cache functions - // are being used. Modification of the mesh while cache(s) are filled will - // not guarantee proper results on subsequent calls unless they are rebuilt. - void CacheValencesInaccurate() const { - if (vertex_valence_cache_8_bit_.size() == 0) { - const VertexIndex vertex_count = VertexIndex(table_.num_vertices()); - vertex_valence_cache_8_bit_.resize(vertex_count.value()); - for (VertexIndex v = VertexIndex(0); v < vertex_count; v += 1) - vertex_valence_cache_8_bit_[v] = static_cast( - (std::min)(static_cast(std::numeric_limits::max()), - table_.Valence(v))); - } - } - void CacheValences() const { - if (vertex_valence_cache_32_bit_.size() == 0) { - const VertexIndex vertex_count = VertexIndex(table_.num_vertices()); - vertex_valence_cache_32_bit_.resize(vertex_count.value()); - for (VertexIndex v = VertexIndex(0); v < vertex_count; v += 1) - vertex_valence_cache_32_bit_[v] = table_.Valence(v); - } - } - - inline int8_t ConfidentValenceFromCacheInaccurate(CornerIndex c) const { - DRACO_DCHECK_GE(c.value(), 0); - return ConfidentValenceFromCacheInaccurate(table_.ConfidentVertex(c)); - } - inline int32_t ConfidentValenceFromCache(CornerIndex c) const { - DRACO_DCHECK_GE(c.value(), 0); - return ConfidentValenceFromCache(table_.ConfidentVertex(c)); - } - inline int8_t ValenceFromCacheInaccurate(VertexIndex v) const { - DRACO_DCHECK_EQ(vertex_valence_cache_8_bit_.size(), table_.num_vertices()); - if (v == kInvalidVertexIndex || v.value() >= table_.num_vertices()) - return -1; - return ConfidentValenceFromCacheInaccurate(v); - } - inline int8_t ConfidentValenceFromCacheInaccurate(VertexIndex v) const { - DRACO_DCHECK_LT(v.value(), table_.num_vertices()); - DRACO_DCHECK_EQ(vertex_valence_cache_8_bit_.size(), table_.num_vertices()); - return vertex_valence_cache_8_bit_[v]; - } - - // TODO(draco-eng) Add unit tests for ValenceCache functions. - inline int32_t ValenceFromCache(VertexIndex v) const { - DRACO_DCHECK_EQ(vertex_valence_cache_32_bit_.size(), table_.num_vertices()); - if (v == kInvalidVertexIndex || v.value() >= table_.num_vertices()) - return -1; - return ConfidentValenceFromCache(v); - } - - // Clear the cache of valences and deallocate the memory. - void ClearValenceCacheInaccurate() const { - vertex_valence_cache_8_bit_.clear(); - // Force erasure. - IndexTypeVector().swap(vertex_valence_cache_8_bit_); - } - void ClearValenceCache() const { - vertex_valence_cache_32_bit_.clear(); - // Force erasure. - IndexTypeVector().swap(vertex_valence_cache_32_bit_); - } - - bool IsCacheEmpty() const { - return vertex_valence_cache_8_bit_.size() == 0 && - vertex_valence_cache_32_bit_.size() == 0; - } - - private: - // Retain valences and clip them to char size. - mutable IndexTypeVector vertex_valence_cache_8_bit_; - mutable IndexTypeVector vertex_valence_cache_32_bit_; -}; - -} // namespace draco - -#endif // DRACO_MESH_VALENCE_CACHE_H_ diff --git a/cloudreg_env/include/draco/metadata/geometry_metadata.h b/cloudreg_env/include/draco/metadata/geometry_metadata.h deleted file mode 100644 index 9f668f7..0000000 --- a/cloudreg_env/include/draco/metadata/geometry_metadata.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_METADATA_GEOMETRY_METADATA_H_ -#define DRACO_METADATA_GEOMETRY_METADATA_H_ - -#include "draco/metadata/metadata.h" - -namespace draco { - -// Class for representing specifically metadata of attributes. It must have an -// attribute id which should be identical to it's counterpart attribute in -// the point cloud it belongs to. -class AttributeMetadata : public Metadata { - public: - AttributeMetadata() : att_unique_id_(0) {} - explicit AttributeMetadata(const Metadata &metadata) - : Metadata(metadata), att_unique_id_(0) {} - - void set_att_unique_id(uint32_t att_unique_id) { - att_unique_id_ = att_unique_id; - } - // The unique id of the attribute that this metadata belongs to. - uint32_t att_unique_id() const { return att_unique_id_; } - - private: - uint32_t att_unique_id_; - - friend struct AttributeMetadataHasher; - friend class PointCloud; -}; - -// Functor for computing a hash from data stored in a AttributeMetadata class. -struct AttributeMetadataHasher { - size_t operator()(const AttributeMetadata &metadata) const { - size_t hash = metadata.att_unique_id_; - MetadataHasher metadata_hasher; - hash = HashCombine(metadata_hasher(static_cast(metadata)), - hash); - return hash; - } -}; -// Class for representing the metadata for a point cloud. It could have a list -// of attribute metadata. -class GeometryMetadata : public Metadata { - public: - GeometryMetadata(){}; - explicit GeometryMetadata(const Metadata &metadata) : Metadata(metadata) {} - - const AttributeMetadata *GetAttributeMetadataByStringEntry( - const std::string &entry_name, const std::string &entry_value) const; - bool AddAttributeMetadata(std::unique_ptr att_metadata); - - void DeleteAttributeMetadataByUniqueId(int32_t att_unique_id) { - for (auto itr = att_metadatas_.begin(); itr != att_metadatas_.end(); - ++itr) { - if (itr->get()->att_unique_id() == att_unique_id) { - att_metadatas_.erase(itr); - return; - } - } - } - - const AttributeMetadata *GetAttributeMetadataByUniqueId( - int32_t att_unique_id) const { - // TODO(draco-eng): Consider using unordered_map instead of vector to store - // attribute metadata. - for (auto &&att_metadata : att_metadatas_) { - if (att_metadata->att_unique_id() == att_unique_id) { - return att_metadata.get(); - } - } - return nullptr; - } - - AttributeMetadata *attribute_metadata(int32_t att_unique_id) { - // TODO(draco-eng): Consider use unordered_map instead of vector to store - // attribute metadata. - for (auto &&att_metadata : att_metadatas_) { - if (att_metadata->att_unique_id() == att_unique_id) { - return att_metadata.get(); - } - } - return nullptr; - } - - const std::vector> &attribute_metadatas() - const { - return att_metadatas_; - } - - private: - std::vector> att_metadatas_; - - friend struct GeometryMetadataHasher; -}; - -// Functor for computing a hash from data stored in a GeometryMetadata class. -struct GeometryMetadataHasher { - size_t operator()(const GeometryMetadata &metadata) const { - size_t hash = metadata.att_metadatas_.size(); - AttributeMetadataHasher att_metadata_hasher; - for (auto &&att_metadata : metadata.att_metadatas_) { - hash = HashCombine(att_metadata_hasher(*att_metadata), hash); - } - MetadataHasher metadata_hasher; - hash = HashCombine(metadata_hasher(static_cast(metadata)), - hash); - return hash; - } -}; - -} // namespace draco - -#endif // THIRD_PARTY_DRACO_METADATA_GEOMETRY_METADATA_H_ diff --git a/cloudreg_env/include/draco/metadata/metadata.h b/cloudreg_env/include/draco/metadata/metadata.h deleted file mode 100644 index c483949..0000000 --- a/cloudreg_env/include/draco/metadata/metadata.h +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_METADATA_METADATA_H_ -#define DRACO_METADATA_METADATA_H_ - -#include -#include -#include -#include -#include - -#include "draco/core/hash_utils.h" - -namespace draco { - -// Class for storing a value of an entry in Metadata. Internally it is -// represented by a buffer of data. It can be accessed by various data types, -// e.g. int, float, binary data or string. -class EntryValue { - public: - template - explicit EntryValue(const DataTypeT &data) { - const size_t data_type_size = sizeof(DataTypeT); - data_.resize(data_type_size); - memcpy(&data_[0], &data, data_type_size); - } - - template - explicit EntryValue(const std::vector &data) { - const size_t total_size = sizeof(DataTypeT) * data.size(); - data_.resize(total_size); - memcpy(&data_[0], &data[0], total_size); - } - - EntryValue(const EntryValue &value); - explicit EntryValue(const std::string &value); - - template - bool GetValue(DataTypeT *value) const { - const size_t data_type_size = sizeof(DataTypeT); - if (data_type_size != data_.size()) { - return false; - } - memcpy(value, &data_[0], data_type_size); - return true; - } - - template - bool GetValue(std::vector *value) const { - if (data_.empty()) - return false; - const size_t data_type_size = sizeof(DataTypeT); - if (data_.size() % data_type_size != 0) { - return false; - } - value->resize(data_.size() / data_type_size); - memcpy(&value->at(0), &data_[0], data_.size()); - return true; - } - - const std::vector &data() const { return data_; } - - private: - std::vector data_; - - friend struct EntryValueHasher; -}; - -// Functor for computing a hash from data stored within an EntryValue. -struct EntryValueHasher { - size_t operator()(const EntryValue &ev) const { - size_t hash = ev.data_.size(); - for (int i = 0; i < ev.data_.size(); ++i) { - hash = HashCombine(ev.data_[i], hash); - } - return hash; - } -}; - -// Class for holding generic metadata. It has a list of entries which consist of -// an entry name and an entry value. Each Metadata could also have nested -// metadata. -class Metadata { - public: - Metadata() {} - Metadata(const Metadata &metadata); - // In theory, we support all types of data as long as it could be serialized - // to binary data. We provide the following functions for inserting and - // accessing entries of common data types. For now, developers need to know - // the type of entries they are requesting. - void AddEntryInt(const std::string &name, int32_t value); - - // Returns false if Metadata does not contain an entry with a key of |name|. - // This function does not guarantee that entry's type is int32_t. - bool GetEntryInt(const std::string &name, int32_t *value) const; - - void AddEntryIntArray(const std::string &name, - const std::vector &value); - - // Returns false if Metadata does not contain an entry with a key of |name|. - // This function does not guarantee that entry's type is a vector of int32_t. - bool GetEntryIntArray(const std::string &name, - std::vector *value) const; - - void AddEntryDouble(const std::string &name, double value); - - // Returns false if Metadata does not contain an entry with a key of |name|. - // This function does not guarantee that entry's type is double. - bool GetEntryDouble(const std::string &name, double *value) const; - - void AddEntryDoubleArray(const std::string &name, - const std::vector &value); - - // Returns false if Metadata does not contain an entry with a key of |name|. - // This function does not guarantee that entry's type is a vector of double. - bool GetEntryDoubleArray(const std::string &name, - std::vector *value) const; - - void AddEntryString(const std::string &name, const std::string &value); - - // Returns false if Metadata does not contain an entry with a key of |name|. - // This function does not guarantee that entry's type is std::string. - bool GetEntryString(const std::string &name, std::string *value) const; - - // Add a blob of data as an entry. - void AddEntryBinary(const std::string &name, - const std::vector &value); - - // Returns false if Metadata does not contain an entry with a key of |name|. - // This function does not guarantee that entry's type is a vector of uint8_t. - bool GetEntryBinary(const std::string &name, - std::vector *value) const; - - bool AddSubMetadata(const std::string &name, - std::unique_ptr sub_metadata); - const Metadata *GetSubMetadata(const std::string &name) const; - - void RemoveEntry(const std::string &name); - - int num_entries() const { return static_cast(entries_.size()); } - const std::unordered_map &entries() const { - return entries_; - } - const std::unordered_map> - &sub_metadatas() const { - return sub_metadatas_; - } - - private: - // Make this function private to avoid adding undefined data types. - template - void AddEntry(const std::string &entry_name, const DataTypeT &entry_value) { - const auto itr = entries_.find(entry_name); - if (itr != entries_.end()) - entries_.erase(itr); - entries_.insert(std::make_pair(entry_name, EntryValue(entry_value))); - } - - // Make this function private to avoid adding undefined data types. - template - bool GetEntry(const std::string &entry_name, DataTypeT *entry_value) const { - const auto itr = entries_.find(entry_name); - if (itr == entries_.end()) { - return false; - } - return itr->second.GetValue(entry_value); - } - - std::unordered_map entries_; - std::unordered_map> sub_metadatas_; - - friend struct MetadataHasher; -}; - -// Functor for computing a hash from data stored within a metadata class. -struct MetadataHasher { - size_t operator()(const Metadata &metadata) const { - size_t hash = - HashCombine(metadata.entries_.size(), metadata.sub_metadatas_.size()); - EntryValueHasher entry_value_hasher; - for (const auto &entry : metadata.entries_) { - hash = HashCombine(entry.first, hash); - hash = HashCombine(entry_value_hasher(entry.second), hash); - } - MetadataHasher metadata_hasher; - for (auto &&sub_metadata : metadata.sub_metadatas_) { - hash = HashCombine(sub_metadata.first, hash); - hash = HashCombine(metadata_hasher(*sub_metadata.second), hash); - } - return hash; - } -}; - -} // namespace draco - -#endif // DRACO_METADATA_METADATA_H_ diff --git a/cloudreg_env/include/draco/metadata/metadata_decoder.h b/cloudreg_env/include/draco/metadata/metadata_decoder.h deleted file mode 100644 index b4c4943..0000000 --- a/cloudreg_env/include/draco/metadata/metadata_decoder.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_METADATA_METADATA_DECODER_H_ -#define DRACO_METADATA_METADATA_DECODER_H_ - -#include "draco/core/decoder_buffer.h" -#include "draco/metadata/geometry_metadata.h" -#include "draco/metadata/metadata.h" - -namespace draco { - -// Class for decoding the metadata. -class MetadataDecoder { - public: - MetadataDecoder(); - bool DecodeMetadata(DecoderBuffer *in_buffer, Metadata *metadata); - bool DecodeGeometryMetadata(DecoderBuffer *in_buffer, - GeometryMetadata *metadata); - - private: - bool DecodeMetadata(Metadata *metadata); - bool DecodeEntries(Metadata *metadata); - bool DecodeEntry(Metadata *metadata); - bool DecodeName(std::string *name); - - DecoderBuffer *buffer_; -}; -} // namespace draco - -#endif // DRACO_METADATA_METADATA_DECODER_H_ diff --git a/cloudreg_env/include/draco/metadata/metadata_encoder.h b/cloudreg_env/include/draco/metadata/metadata_encoder.h deleted file mode 100644 index 5bce5d5..0000000 --- a/cloudreg_env/include/draco/metadata/metadata_encoder.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_METADATA_METADATA_ENCODER_H_ -#define DRACO_METADATA_METADATA_ENCODER_H_ - -#include "draco/core/encoder_buffer.h" -#include "draco/metadata/geometry_metadata.h" -#include "draco/metadata/metadata.h" - -namespace draco { - -// Class for encoding metadata. It could encode either base Metadata class or -// a metadata of a geometry, e.g. a point cloud. -class MetadataEncoder { - public: - MetadataEncoder() {} - - bool EncodeGeometryMetadata(EncoderBuffer *out_buffer, - const GeometryMetadata *metadata); - bool EncodeMetadata(EncoderBuffer *out_buffer, const Metadata *metadata); - - private: - bool EncodeAttributeMetadata(EncoderBuffer *out_buffer, - const AttributeMetadata *metadata); - bool EncodeString(EncoderBuffer *out_buffer, const std::string &str); -}; -} // namespace draco - -#endif // DRACO_METADATA_METADATA_ENCODER_H_ diff --git a/cloudreg_env/include/draco/point_cloud/point_cloud.h b/cloudreg_env/include/draco/point_cloud/point_cloud.h deleted file mode 100644 index e15206f..0000000 --- a/cloudreg_env/include/draco/point_cloud/point_cloud.h +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_POINT_CLOUD_POINT_CLOUD_H_ -#define DRACO_POINT_CLOUD_POINT_CLOUD_H_ - -#include "draco/draco_features.h" - -#include "draco/attributes/point_attribute.h" -#include "draco/core/bounding_box.h" -#include "draco/core/vector_d.h" -#include "draco/metadata/geometry_metadata.h" - -namespace draco { - -// PointCloud is a collection of n-dimensional points that are described by a -// set of PointAttributes that can represent data such as positions or colors -// of individual points (see point_attribute.h). -class PointCloud { - public: - PointCloud(); - virtual ~PointCloud() = default; - - // Returns the number of named attributes of a given type. - int32_t NumNamedAttributes(GeometryAttribute::Type type) const; - - // Returns attribute id of the first named attribute with a given type or -1 - // when the attribute is not used by the point cloud. - int32_t GetNamedAttributeId(GeometryAttribute::Type type) const; - - // Returns the id of the i-th named attribute of a given type. - int32_t GetNamedAttributeId(GeometryAttribute::Type type, int i) const; - - // Returns the first named attribute of a given type or nullptr if the - // attribute is not used by the point cloud. - const PointAttribute *GetNamedAttribute(GeometryAttribute::Type type) const; - - // Returns the i-th named attribute of a given type. - const PointAttribute *GetNamedAttribute(GeometryAttribute::Type type, - int i) const; - - // Returns the named attribute of a given unique id. - const PointAttribute *GetNamedAttributeByUniqueId( - GeometryAttribute::Type type, uint32_t id) const; - - // Returns the attribute of a given unique id. - const PointAttribute *GetAttributeByUniqueId(uint32_t id) const; - int32_t GetAttributeIdByUniqueId(uint32_t unique_id) const; - - int32_t num_attributes() const { - return static_cast(attributes_.size()); - } - const PointAttribute *attribute(int32_t att_id) const { - DRACO_DCHECK_LE(0, att_id); - DRACO_DCHECK_LT(att_id, static_cast(attributes_.size())); - return attributes_[att_id].get(); - } - - // Returned attribute can be modified, but it's caller's responsibility to - // maintain the attribute's consistency with draco::PointCloud. - PointAttribute *attribute(int32_t att_id) { - DRACO_DCHECK_LE(0, att_id); - DRACO_DCHECK_LT(att_id, static_cast(attributes_.size())); - return attributes_[att_id].get(); - } - - // Adds a new attribute to the point cloud. - // Returns the attribute id. - int AddAttribute(std::unique_ptr pa); - - // Creates and adds a new attribute to the point cloud. The attribute has - // properties derived from the provided GeometryAttribute |att|. - // If |identity_mapping| is set to true, the attribute will use identity - // mapping between point indices and attribute value indices (i.e., each - // point has a unique attribute value). If |identity_mapping| is false, the - // mapping between point indices and attribute value indices is set to - // explicit, and it needs to be initialized manually using the - // PointAttribute::SetPointMapEntry() method. |num_attribute_values| can be - // used to specify the number of attribute values that are going to be - // stored in the newly created attribute. Returns attribute id of the newly - // created attribute or -1 in case of failure. - int AddAttribute(const GeometryAttribute &att, bool identity_mapping, - AttributeValueIndex::ValueType num_attribute_values); - - // Creates and returns a new attribute or nullptr in case of failure. This - // method is similar to AddAttribute(), except that it returns the new - // attribute instead of adding it to the point cloud. - std::unique_ptr CreateAttribute( - const GeometryAttribute &att, bool identity_mapping, - AttributeValueIndex::ValueType num_attribute_values) const; - - // Assigns an attribute id to a given PointAttribute. If an attribute with - // the same attribute id already exists, it is deleted. - virtual void SetAttribute(int att_id, std::unique_ptr pa); - - // Deletes an attribute with specified attribute id. Note that this changes - // attribute ids of all subsequent attributes. - virtual void DeleteAttribute(int att_id); - -#ifdef DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED - // Deduplicates all attribute values (all attribute entries with the same - // value are merged into a single entry). - virtual bool DeduplicateAttributeValues(); -#endif - -#ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED - // Removes duplicate point ids (two point ids are duplicate when all of their - // attributes are mapped to the same entry ids). - virtual void DeduplicatePointIds(); -#endif - - // Get bounding box. - BoundingBox ComputeBoundingBox() const; - - // Add metadata. - void AddMetadata(std::unique_ptr metadata) { - metadata_ = std::move(metadata); - } - - // Add metadata for an attribute. - void AddAttributeMetadata(int32_t att_id, - std::unique_ptr metadata) { - if (!metadata_.get()) { - metadata_ = std::unique_ptr(new GeometryMetadata()); - } - const int32_t att_unique_id = attribute(att_id)->unique_id(); - metadata->set_att_unique_id(att_unique_id); - metadata_->AddAttributeMetadata(std::move(metadata)); - } - - const AttributeMetadata *GetAttributeMetadataByAttributeId( - int32_t att_id) const { - if (metadata_ == nullptr) - return nullptr; - const uint32_t unique_id = attribute(att_id)->unique_id(); - return metadata_->GetAttributeMetadataByUniqueId(unique_id); - } - - // Returns the attribute metadata that has the requested metadata entry. - const AttributeMetadata *GetAttributeMetadataByStringEntry( - const std::string &name, const std::string &value) const { - if (metadata_ == nullptr) - return nullptr; - return metadata_->GetAttributeMetadataByStringEntry(name, value); - } - - // Returns the first attribute that has the requested metadata entry. - int GetAttributeIdByMetadataEntry(const std::string &name, - const std::string &value) const { - if (metadata_ == nullptr) - return -1; - const AttributeMetadata *att_metadata = - metadata_->GetAttributeMetadataByStringEntry(name, value); - if (!att_metadata) - return -1; - return GetAttributeIdByUniqueId(att_metadata->att_unique_id()); - } - - // Get a const pointer of the metadata of the point cloud. - const GeometryMetadata *GetMetadata() const { return metadata_.get(); } - - // Get a pointer to the metadata of the point cloud. - GeometryMetadata *metadata() { return metadata_.get(); } - - // Returns the number of n-dimensional points stored within the point cloud. - PointIndex::ValueType num_points() const { return num_points_; } - - // Sets the number of points. It's the caller's responsibility to ensure the - // new number is valid with respect to the PointAttributes stored in the point - // cloud. - void set_num_points(PointIndex::ValueType num) { num_points_ = num; } - - protected: -#ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED - // Applies id mapping of deduplicated points (called by DeduplicatePointIds). - virtual void ApplyPointIdDeduplication( - const IndexTypeVector &id_map, - const std::vector &unique_point_ids); -#endif - - private: - // Metadata for the point cloud. - std::unique_ptr metadata_; - - // Attributes describing the point cloud. - std::vector> attributes_; - - // Ids of named attributes of the given type. - std::vector - named_attribute_index_[GeometryAttribute::NAMED_ATTRIBUTES_COUNT]; - - // The number of n-dimensional points. All point attribute values are stored - // in corresponding PointAttribute instances in the |attributes_| array. - PointIndex::ValueType num_points_; - - friend struct PointCloudHasher; -}; - -// Functor for computing a hash from data stored within a point cloud. -// Note that this can be quite slow. Two point clouds will have the same hash -// only when all points have the same order and when all attribute values are -// exactly the same. -struct PointCloudHasher { - size_t operator()(const PointCloud &pc) const { - size_t hash = pc.num_points_; - hash = HashCombine(pc.attributes_.size(), hash); - for (int i = 0; i < GeometryAttribute::NAMED_ATTRIBUTES_COUNT; ++i) { - hash = HashCombine(pc.named_attribute_index_[i].size(), hash); - for (int j = 0; j < static_cast(pc.named_attribute_index_[i].size()); - ++j) { - hash = HashCombine(pc.named_attribute_index_[i][j], hash); - } - } - // Hash attributes. - for (int i = 0; i < static_cast(pc.attributes_.size()); ++i) { - PointAttributeHasher att_hasher; - hash = HashCombine(att_hasher(*pc.attributes_[i]), hash); - } - // Hash metadata. - GeometryMetadataHasher metadata_hasher; - if (pc.metadata_.get()) { - hash = HashCombine(metadata_hasher(*pc.metadata_.get()), hash); - } - return hash; - } -}; - -} // namespace draco - -#endif // DRACO_POINT_CLOUD_POINT_CLOUD_H_ diff --git a/cloudreg_env/include/draco/point_cloud/point_cloud_builder.h b/cloudreg_env/include/draco/point_cloud/point_cloud_builder.h deleted file mode 100644 index cf55a72..0000000 --- a/cloudreg_env/include/draco/point_cloud/point_cloud_builder.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_POINT_CLOUD_POINT_CLOUD_BUILDER_H_ -#define DRACO_POINT_CLOUD_POINT_CLOUD_BUILDER_H_ - -#include "draco/point_cloud/point_cloud.h" - -namespace draco { - -// A helper class for constructing PointCloud instances from other data sources. -// Usage: -// PointCloudBuilder builder; -// // Initialize the builder for a given number of points (required). -// builder.Start(num_points); -// // Specify desired attributes. -// int pos_att_id = -// builder.AddAttribute(GeometryAttribute::POSITION, 3, DT_FLOAT32); -// // Add attribute values. -// for (PointIndex i(0); i < num_points; ++i) { -// builder.SetAttributeValueForPoint(pos_att_id, i, input_pos[i.value()]); -// } -// // Get the final PointCloud. -// constexpr bool deduplicate_points = false; -// std::unique_ptr pc = builder.Finalize(deduplicate_points); - -class PointCloudBuilder { - public: - PointCloudBuilder(); - - // Starts collecting point cloud data. - // The behavior of other functions is undefined before this method is called. - void Start(PointIndex::ValueType num_points); - - int AddAttribute(GeometryAttribute::Type attribute_type, - int8_t num_components, DataType data_type); - - // Sets attribute value for a specific point. - // |attribute_value| must contain data in the format specified by the - // AddAttribute method. - void SetAttributeValueForPoint(int att_id, PointIndex point_index, - const void *attribute_value); - - // Sets attribute values for all points. All the values must be stored in the - // input |attribute_values| buffer. |stride| can be used to define the byte - // offset between two consecutive attribute values. If |stride| is set to 0, - // the stride is automatically computed based on the format of the given - // attribute. - void SetAttributeValuesForAllPoints(int att_id, const void *attribute_values, - int stride); - - // Finalizes the PointCloud or returns nullptr on error. - // If |deduplicate_points| is set to true, the following happens: - // 1. Attribute values with duplicate entries are deduplicated. - // 2. Point ids that are mapped to the same attribute values are - // deduplicated. - // Therefore, if |deduplicate_points| is true the final PointCloud can have - // a different number of point from the value specified in the Start method. - // Once this function is called, the builder becomes invalid and cannot be - // used until the method Start() is called again. - std::unique_ptr Finalize(bool deduplicate_points); - - private: - std::unique_ptr point_cloud_; -}; - -} // namespace draco - -#endif // DRACO_POINT_CLOUD_POINT_CLOUD_BUILDER_H_ diff --git a/cloudreg_env/include/draco/unity/draco_unity_plugin.h b/cloudreg_env/include/draco/unity/draco_unity_plugin.h deleted file mode 100644 index cf0d23f..0000000 --- a/cloudreg_env/include/draco/unity/draco_unity_plugin.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2017 The Draco Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef DRACO_UNITY_DRACO_UNITY_PLUGIN_H_ -#define DRACO_UNITY_DRACO_UNITY_PLUGIN_H_ - -#include "draco/compression/config/compression_shared.h" -#include "draco/compression/decode.h" - -#ifdef BUILD_UNITY_PLUGIN - -// If compiling with Visual Studio. -#if defined(_MSC_VER) -#define EXPORT_API __declspec(dllexport) -#else -// Other platforms don't need this. -#define EXPORT_API -#endif // defined(_MSC_VER) - -namespace draco { - -extern "C" { -struct EXPORT_API DracoToUnityMesh { - DracoToUnityMesh() - : num_faces(0), - indices(nullptr), - num_vertices(0), - position(nullptr), - has_normal(false), - normal(nullptr), - has_texcoord(false), - texcoord(nullptr), - has_color(false), - color(nullptr) {} - - int num_faces; - int *indices; - int num_vertices; - float *position; - bool has_normal; - float *normal; - bool has_texcoord; - float *texcoord; - bool has_color; - float *color; -}; - -void EXPORT_API ReleaseUnityMesh(DracoToUnityMesh **mesh_ptr); - -/* To use this function, you do not allocate memory for |tmp_mesh|, just - * define and pass a null pointer. Otherwise there will be memory leak. - */ -int EXPORT_API DecodeMeshForUnity(char *data, unsigned int length, - DracoToUnityMesh **tmp_mesh); -} // extern "C" - -} // namespace draco - -#endif // BUILD_UNITY_PLUGIN - -#endif // DRACO_UNITY_DRACO_UNITY_PLUGIN_H_ diff --git a/cloudreg_env/include/python3.8 b/cloudreg_env/include/python3.8 deleted file mode 120000 index b2785b0..0000000 --- a/cloudreg_env/include/python3.8 +++ /dev/null @@ -1 +0,0 @@ -/usr/local/Cellar/python@3.8/3.8.1/Frameworks/Python.framework/Versions/3.8/include/python3.8 \ No newline at end of file diff --git a/cloudreg_env/include/site/python3.8/greenlet/greenlet.h b/cloudreg_env/include/site/python3.8/greenlet/greenlet.h deleted file mode 100644 index 1397782..0000000 --- a/cloudreg_env/include/site/python3.8/greenlet/greenlet.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; -*- */ - -/* Greenlet object interface */ - -#ifndef Py_GREENLETOBJECT_H -#define Py_GREENLETOBJECT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* This is deprecated and undocumented. It does not change. */ -#define GREENLET_VERSION "1.0.0" - -typedef struct _greenlet { - PyObject_HEAD - char* stack_start; - char* stack_stop; - char* stack_copy; - intptr_t stack_saved; - struct _greenlet* stack_prev; - struct _greenlet* parent; - PyObject* run_info; - struct _frame* top_frame; - int recursion_depth; - PyObject* weakreflist; -#if PY_VERSION_HEX >= 0x030700A3 - _PyErr_StackItem* exc_info; - _PyErr_StackItem exc_state; -#else - PyObject* exc_type; - PyObject* exc_value; - PyObject* exc_traceback; -#endif - PyObject* dict; -#if PY_VERSION_HEX >= 0x030700A3 - PyObject* context; -#endif -} PyGreenlet; - -#define PyGreenlet_Check(op) PyObject_TypeCheck(op, &PyGreenlet_Type) -#define PyGreenlet_MAIN(op) (((PyGreenlet*)(op))->stack_stop == (char*)-1) -#define PyGreenlet_STARTED(op) (((PyGreenlet*)(op))->stack_stop != NULL) -#define PyGreenlet_ACTIVE(op) (((PyGreenlet*)(op))->stack_start != NULL) -#define PyGreenlet_GET_PARENT(op) (((PyGreenlet*)(op))->parent) - -/* C API functions */ - -/* Total number of symbols that are exported */ -#define PyGreenlet_API_pointers 8 - -#define PyGreenlet_Type_NUM 0 -#define PyExc_GreenletError_NUM 1 -#define PyExc_GreenletExit_NUM 2 - -#define PyGreenlet_New_NUM 3 -#define PyGreenlet_GetCurrent_NUM 4 -#define PyGreenlet_Throw_NUM 5 -#define PyGreenlet_Switch_NUM 6 -#define PyGreenlet_SetParent_NUM 7 - -#ifndef GREENLET_MODULE -/* This section is used by modules that uses the greenlet C API */ -static void** _PyGreenlet_API = NULL; - -# define PyGreenlet_Type \ - (*(PyTypeObject*)_PyGreenlet_API[PyGreenlet_Type_NUM]) - -# define PyExc_GreenletError \ - ((PyObject*)_PyGreenlet_API[PyExc_GreenletError_NUM]) - -# define PyExc_GreenletExit \ - ((PyObject*)_PyGreenlet_API[PyExc_GreenletExit_NUM]) - -/* - * PyGreenlet_New(PyObject *args) - * - * greenlet.greenlet(run, parent=None) - */ -# define PyGreenlet_New \ - (*(PyGreenlet * (*)(PyObject * run, PyGreenlet * parent)) \ - _PyGreenlet_API[PyGreenlet_New_NUM]) - -/* - * PyGreenlet_GetCurrent(void) - * - * greenlet.getcurrent() - */ -# define PyGreenlet_GetCurrent \ - (*(PyGreenlet * (*)(void)) _PyGreenlet_API[PyGreenlet_GetCurrent_NUM]) - -/* - * PyGreenlet_Throw( - * PyGreenlet *greenlet, - * PyObject *typ, - * PyObject *val, - * PyObject *tb) - * - * g.throw(...) - */ -# define PyGreenlet_Throw \ - (*(PyObject * (*)(PyGreenlet * self, \ - PyObject * typ, \ - PyObject * val, \ - PyObject * tb)) \ - _PyGreenlet_API[PyGreenlet_Throw_NUM]) - -/* - * PyGreenlet_Switch(PyGreenlet *greenlet, PyObject *args) - * - * g.switch(*args, **kwargs) - */ -# define PyGreenlet_Switch \ - (*(PyObject * \ - (*)(PyGreenlet * greenlet, PyObject * args, PyObject * kwargs)) \ - _PyGreenlet_API[PyGreenlet_Switch_NUM]) - -/* - * PyGreenlet_SetParent(PyObject *greenlet, PyObject *new_parent) - * - * g.parent = new_parent - */ -# define PyGreenlet_SetParent \ - (*(int (*)(PyGreenlet * greenlet, PyGreenlet * nparent)) \ - _PyGreenlet_API[PyGreenlet_SetParent_NUM]) - -/* Macro that imports greenlet and initializes C API */ -/* NOTE: This has actually moved to ``greenlet._greenlet._C_API``, but we - keep the older definition to be sure older code that might have a copy of - the header still works. */ -# define PyGreenlet_Import() \ - { \ - _PyGreenlet_API = (void**)PyCapsule_Import("greenlet._C_API", 0); \ - } - -#endif /* GREENLET_MODULE */ - -#ifdef __cplusplus -} -#endif -#endif /* !Py_GREENLETOBJECT_H */