536ac52055722b168e4482f612302fa754dc4f72cilix/*
536ac52055722b168e4482f612302fa754dc4f72cilix * Generic auxiliary routines for 3D axes
536ac52055722b168e4482f612302fa754dc4f72cilix *
536ac52055722b168e4482f612302fa754dc4f72cilix * Authors:
536ac52055722b168e4482f612302fa754dc4f72cilix * Maximilian Albert <Anhalter42@gmx.de>
536ac52055722b168e4482f612302fa754dc4f72cilix *
536ac52055722b168e4482f612302fa754dc4f72cilix * Copyright (C) 2007 authors
536ac52055722b168e4482f612302fa754dc4f72cilix *
536ac52055722b168e4482f612302fa754dc4f72cilix * Released under GNU GPL, read the file 'COPYING' for more information
536ac52055722b168e4482f612302fa754dc4f72cilix */
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix#ifndef SEEN_AXIS_MANIP_H
536ac52055722b168e4482f612302fa754dc4f72cilix#define SEEN_AXIS_MANIP_H
536ac52055722b168e4482f612302fa754dc4f72cilix
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. White#include <cassert>
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. White#include <string>
ef494f75ca77f36881ad59e94263a07c146c3649Krzysztof Kosiński#include <utility>
536ac52055722b168e4482f612302fa754dc4f72cilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixnamespace Proj {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixenum VPState {
396d5aa732c14fad8d67a143132eb232a45dd7f2johanengelen VP_FINITE = 0,
396d5aa732c14fad8d67a143132eb232a45dd7f2johanengelen VP_INFINITE
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix};
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// The X-/Y-/Z-axis corresponds to the first/second/third digit
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// in binary representation, respectively.
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixenum Axis {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix X = 0,
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix Y = 1,
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix Z = 2,
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix W = 3,
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix NONE
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix};
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixextern Axis axes[4];
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. Whiteinline char const*
23f621800bcb9751456da3f838dff49ddd207ae9pjrmstring_from_axis(Proj::Axis axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix switch (axis) {
23f621800bcb9751456da3f838dff49ddd207ae9pjrm case X: return "X"; break;
23f621800bcb9751456da3f838dff49ddd207ae9pjrm case Y: return "Y"; break;
23f621800bcb9751456da3f838dff49ddd207ae9pjrm case Z: return "Z"; break;
23f621800bcb9751456da3f838dff49ddd207ae9pjrm case W: return "W"; break;
23f621800bcb9751456da3f838dff49ddd207ae9pjrm case NONE: return "NONE"; break;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix }
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return "";
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix} // namespace Proj
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
536ac52055722b168e4482f612302fa754dc4f72cilixnamespace Box3D {
536ac52055722b168e4482f612302fa754dc4f72cilix
fbdfd8486b6e079ebac503d948d77131bffaa600cilixconst double epsilon = 1e-6;
fbdfd8486b6e079ebac503d948d77131bffaa600cilix
536ac52055722b168e4482f612302fa754dc4f72cilix// The X-/Y-/Z-axis corresponds to the first/second/third digit
536ac52055722b168e4482f612302fa754dc4f72cilix// in binary representation, respectively.
536ac52055722b168e4482f612302fa754dc4f72cilixenum Axis {
536ac52055722b168e4482f612302fa754dc4f72cilix X = 1,
536ac52055722b168e4482f612302fa754dc4f72cilix Y = 2,
536ac52055722b168e4482f612302fa754dc4f72cilix Z = 4,
536ac52055722b168e4482f612302fa754dc4f72cilix XY = 3,
536ac52055722b168e4482f612302fa754dc4f72cilix XZ = 5,
536ac52055722b168e4482f612302fa754dc4f72cilix YZ = 6,
536ac52055722b168e4482f612302fa754dc4f72cilix XYZ = 7,
536ac52055722b168e4482f612302fa754dc4f72cilix NONE = 0
536ac52055722b168e4482f612302fa754dc4f72cilix};
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix// We use the fourth bit in binary representation
536ac52055722b168e4482f612302fa754dc4f72cilix// to indicate whether a face is front or rear.
536ac52055722b168e4482f612302fa754dc4f72cilixenum FrontOrRear { // find a better name
536ac52055722b168e4482f612302fa754dc4f72cilix FRONT = 0,
536ac52055722b168e4482f612302fa754dc4f72cilix REAR = 8
536ac52055722b168e4482f612302fa754dc4f72cilix};
536ac52055722b168e4482f612302fa754dc4f72cilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// converts X, Y, Z respectively to 0, 1, 2 (for use as array indices, e.g)
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixinline int axis_to_int(Box3D::Axis axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix switch (axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::X:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return 0;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::Y:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return 1;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::Z:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return 2;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::NONE:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return -1;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix default:
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. White assert(false);
8fa3758e375c4354e2ad7fdaba8792e7d010bed5Johan B. C. Engelen return -1; // help compiler's flow analysis (-Werror=return-value)
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix }
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixinline Proj::Axis toProj(Box3D::Axis axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix switch (axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::X:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Proj::X;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::Y:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Proj::Y;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::Z:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Proj::Z;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Box3D::NONE:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Proj::NONE;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix default:
8fa3758e375c4354e2ad7fdaba8792e7d010bed5Johan B. C. Engelen assert(false);
8fa3758e375c4354e2ad7fdaba8792e7d010bed5Johan B. C. Engelen return Proj::NONE; // help compiler's flow analysis (-Werror=return-value)
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix }
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
536ac52055722b168e4482f612302fa754dc4f72cilixextern Axis axes[3];
536ac52055722b168e4482f612302fa754dc4f72cilixextern Axis planes[3];
536ac52055722b168e4482f612302fa754dc4f72cilixextern FrontOrRear face_positions [2];
536ac52055722b168e4482f612302fa754dc4f72cilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix} // namespace Box3D
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixnamespace Proj {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixinline Box3D::Axis toAffine(Proj::Axis axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix switch (axis) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Proj::X:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Box3D::X;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Proj::Y:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Box3D::Y;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Proj::Z:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Box3D::Z;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case Proj::NONE:
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Box3D::NONE;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix default:
8fa3758e375c4354e2ad7fdaba8792e7d010bed5Johan B. C. Engelen assert(false);
8fa3758e375c4354e2ad7fdaba8792e7d010bed5Johan B. C. Engelen return Box3D::NONE; // help compiler's flow analysis (-Werror=return-value)
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix }
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix} // namespace Proj
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilixnamespace Box3D {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix/*
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix * Identify the axes X, Y, Z with the numbers 0, 1, 2.
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix * A box's face is identified by the axis perpendicular to it.
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix * For a rear face, add 3.
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix */
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// Given a bit sequence that unambiguously specifies the face of a 3D box,
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// return a number between 0 and 5 corresponding to that particular face
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// (which is normally used to index an array). Return -1 if the bit sequence
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// does not specify a face. A face can either be given by its plane (e.g, XY)
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix// or by the axis that is orthogonal to it (e.g., Z).
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. Whiteinline int face_to_int (unsigned int face_id) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix switch (face_id) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 1: return 0;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 2: return 1;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 4: return 2;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 3: return 2;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 5: return 1;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 6: return 0;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 9: return 3;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 10: return 4;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 12: return 5;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 11: return 5;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 13: return 4;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 14: return 3;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix default: return -1;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix }
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. Whiteinline int int_to_face (unsigned id) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix switch (id) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 0: return Box3D::YZ ^ Box3D::FRONT;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 1: return Box3D::XZ ^ Box3D::FRONT;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 2: return Box3D::XY ^ Box3D::FRONT;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 3: return Box3D::YZ ^ Box3D::REAR;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 4: return Box3D::XZ ^ Box3D::REAR;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix case 5: return Box3D::XY ^ Box3D::REAR;
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix }
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return Box3D::NONE; // should not be reached
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. Whiteinline bool is_face_id (unsigned int face_id) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return !((face_id & 0x7) == 0x7);
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix/**
315c94766449a5049ab19ccaf3b3c9dc9517bc0dcilixinline gint opposite_face (guint face_id) {
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix return face_id + (((face_id % 2) == 0) ? 1 : -1);
b9314c4c1c56471487e07aa368f0e311d29bee58cilix}
4358ff6156766a315e38e72a5c3c83d6d5f7486bcilix**/
b9314c4c1c56471487e07aa368f0e311d29bee58cilix
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. Whiteinline unsigned int number_of_axis_directions (Box3D::Axis axis) {
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. White unsigned int num = 0;
e0c254c4445696f4e88690a2d35da1e3a760867ecilix if (axis & Box3D::X) num++;
e0c254c4445696f4e88690a2d35da1e3a760867ecilix if (axis & Box3D::Y) num++;
e0c254c4445696f4e88690a2d35da1e3a760867ecilix if (axis & Box3D::Z) num++;
e0c254c4445696f4e88690a2d35da1e3a760867ecilix
e0c254c4445696f4e88690a2d35da1e3a760867ecilix return num;
e0c254c4445696f4e88690a2d35da1e3a760867ecilix}
e0c254c4445696f4e88690a2d35da1e3a760867ecilix
e0c254c4445696f4e88690a2d35da1e3a760867ecilixinline bool is_plane (Box3D::Axis plane) {
e0c254c4445696f4e88690a2d35da1e3a760867ecilix return (number_of_axis_directions (plane) == 2);
e0c254c4445696f4e88690a2d35da1e3a760867ecilix}
e0c254c4445696f4e88690a2d35da1e3a760867ecilix
536ac52055722b168e4482f612302fa754dc4f72cilixinline bool is_single_axis_direction (Box3D::Axis dir) {
536ac52055722b168e4482f612302fa754dc4f72cilix // tests whether dir is nonzero and a power of 2
536ac52055722b168e4482f612302fa754dc4f72cilix return (!(dir & (dir - 1)) && dir);
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix/**
536ac52055722b168e4482f612302fa754dc4f72cilix * Given two axis directions out of {X, Y, Z} or the corresponding plane, return the remaining one
536ac52055722b168e4482f612302fa754dc4f72cilix * We don't check if 'plane' really specifies a plane (i.e., if it consists of precisely two directions).
536ac52055722b168e4482f612302fa754dc4f72cilix */
536ac52055722b168e4482f612302fa754dc4f72cilixinline Box3D::Axis third_axis_direction (Box3D::Axis dir1, Box3D::Axis dir2) {
536ac52055722b168e4482f612302fa754dc4f72cilix return (Box3D::Axis) ((dir1 + dir2) ^ 0x7);
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilixinline Box3D::Axis third_axis_direction (Box3D::Axis plane) {
536ac52055722b168e4482f612302fa754dc4f72cilix return (Box3D::Axis) (plane ^ 0x7);
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix/* returns the first/second axis direction occuring in the (possibly compound) expression 'dirs' */
536ac52055722b168e4482f612302fa754dc4f72cilixinline Box3D::Axis extract_first_axis_direction (Box3D::Axis dirs) {
536ac52055722b168e4482f612302fa754dc4f72cilix if (dirs & Box3D::X) return Box3D::X;
536ac52055722b168e4482f612302fa754dc4f72cilix if (dirs & Box3D::Y) return Box3D::Y;
536ac52055722b168e4482f612302fa754dc4f72cilix if (dirs & Box3D::Z) return Box3D::Z;
536ac52055722b168e4482f612302fa754dc4f72cilix return Box3D::NONE;
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilixinline Box3D::Axis extract_second_axis_direction (Box3D::Axis dirs) {
536ac52055722b168e4482f612302fa754dc4f72cilix return extract_first_axis_direction ((Box3D::Axis) (dirs ^ extract_first_axis_direction(dirs)));
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilix
e0c254c4445696f4e88690a2d35da1e3a760867ecilixinline Box3D::Axis orth_plane_or_axis (Box3D::Axis axis) {
536ac52055722b168e4482f612302fa754dc4f72cilix return (Box3D::Axis) (Box3D::XYZ ^ axis);
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix/* returns an axis direction perpendicular to the ones occuring in the (possibly compound) expression 'dirs' */
536ac52055722b168e4482f612302fa754dc4f72cilixinline Box3D::Axis get_perpendicular_axis_direction (Box3D::Axis dirs) {
536ac52055722b168e4482f612302fa754dc4f72cilix if (!(dirs & Box3D::X)) return Box3D::X;
536ac52055722b168e4482f612302fa754dc4f72cilix if (!(dirs & Box3D::Y)) return Box3D::Y;
536ac52055722b168e4482f612302fa754dc4f72cilix if (!(dirs & Box3D::Z)) return Box3D::Z;
536ac52055722b168e4482f612302fa754dc4f72cilix return Box3D::NONE;
536ac52055722b168e4482f612302fa754dc4f72cilix}
536ac52055722b168e4482f612302fa754dc4f72cilix
44ed6dfe15487cdc5a4c78b7d07fcfcd0164bc42Liam P. Whitechar * string_from_axes (Box3D::Axis axis);
3616fc4f881e624b50093cef5f017751ddf51b07cilixstd::pair <Axis, Axis> get_remaining_axes (Axis axis);
3616fc4f881e624b50093cef5f017751ddf51b07cilix
536ac52055722b168e4482f612302fa754dc4f72cilix} // namespace Box3D
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix#endif /* !SEEN_AXIS_MANIP_H */
536ac52055722b168e4482f612302fa754dc4f72cilix
536ac52055722b168e4482f612302fa754dc4f72cilix/*
536ac52055722b168e4482f612302fa754dc4f72cilix Local Variables:
536ac52055722b168e4482f612302fa754dc4f72cilix mode:c++
536ac52055722b168e4482f612302fa754dc4f72cilix c-file-style:"stroustrup"
536ac52055722b168e4482f612302fa754dc4f72cilix c-file-offsets:((innamespace . 0)(inline-open . 0))
536ac52055722b168e4482f612302fa754dc4f72cilix indent-tabs-mode:nil
536ac52055722b168e4482f612302fa754dc4f72cilix fill-column:99
536ac52055722b168e4482f612302fa754dc4f72cilix End:
536ac52055722b168e4482f612302fa754dc4f72cilix*/
536ac52055722b168e4482f612302fa754dc4f72cilix// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :