ShapeBufferGeometry
425334
function ( shapes, curveSegments ) {

	BufferGeometry.call( this );

	this.type = '';

	this.parameters = {
		shapes: shapes,
		curveSegments: curveSegments
	};

	curveSegments = curveSegments || 12;

	// buffers

	var indices = [];
	var vertices = [];
	var normals = [];
	var uvs = [];

	// helper variables

	var groupStart = 0;
	var groupCount = 0;

	// allow single and array values for "shapes" parameter

	if ( Array.isArray( shapes ) === false ) {

		addShape( shapes );

	} else {

		for ( var i = 0; i < shapes.length; i ++ ) {

			addShape( shapes[ i ] );

			this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support

			groupStart += groupCount;
			groupCount = 0;

		}

	}

	// build geometry

	this.setIndex( indices );
	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );


	// helper functions

	function addShape( shape ) {

		var i, l, shapeHole;

		var indexOffset = vertices.length / 3;
		var points = shape.extractPoints( curveSegments );

		var shapeVertices = points.shape;
		var shapeHoles = points.holes;

		// check direction of vertices

		if ( ShapeUtils.isClockWise( shapeVertices ) === false ) {

			shapeVertices = shapeVertices.reverse();

		}

		for ( i = 0, l = shapeHoles.length; i < l; i ++ ) {

			shapeHole = shapeHoles[ i ];

			if ( ShapeUtils.isClockWise( shapeHole ) === true ) {

				shapeHoles[ i ] = shapeHole.reverse();

			}

		}

		var faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );

		// join vertices of inner and outer paths to a single array

		for ( i = 0, l = shapeHoles.length; i < l; i ++ ) {

			shapeHole = shapeHoles[ i ];
			shapeVertices = shapeVertices.concat( shapeHole );

		}

		// vertices, normals, uvs

		for ( i = 0, l = shapeVertices.length; i < l; i ++ ) {

			var vertex = shapeVertices[ i ];

			vertices.push( vertex.x, vertex.y, 0 );
			normals.push( 0, 0, 1 );
			uvs.push( vertex.x, vertex.y ); // world uvs

		}

		// incides

		for ( i = 0, l = faces.length; i < l; i ++ ) {

			var face = faces[ i ];

			var a = face[ 0 ] + indexOffset;
			var b = face[ 1 ] + indexOffset;
			var c = face[ 2 ] + indexOffset;

			indices.push( a, b, c );
			groupCount += 3;

		}

	}

}
1353340
private static Geometry computeSingleSideBuffer(Geometry geometry, double distance, BufferParameters bufferParameters){
        bufferParameters.setSingleSided(true);
        return BufferOp.bufferOp(geometry, distance, bufferParameters);
    }
1096690
def shape(self):
        """"""
        if not self.data:
            return (0, 0)
        return (len(self.data), len(self.dimensions))
726605
function convertShape (shape, tag) {
  return templates.element({
    'tag': tag,
    'width': shape.width,
    'height': shape.height,
    'fill': shape.properties.fill
  });
}
916956
Geometry getBoundingGeometry() {
		// Extracts the convex hull from the tree. Reading the tree in order from first to last is the resulting convex hull.
		Point point = new Point();
		int first = m_tree_hull.getFirst(-1);
		Polygon hull = new Polygon(m_shape.getVertexDescription());
		if (m_tree_hull.size(-1) == 0)
			return hull;
		
		m_shape.queryPoint(m_tree_hull.getElement(first), point);
		hull.startPath(point);

		for (int i = m_tree_hull.getNext(first); i != -1; i = m_tree_hull.getNext(i)) {
			m_shape.queryPoint(m_tree_hull.getElement(i), point);
			hull.lineTo(point);
		}

		return hull;
	}
622333
def check_watershed_boundary_geometry(shapefile_path):
    """"""
    wfg =  gpd.read_file(shapefile_path)
    first_shape = wfg.iloc[0].geometry
    if hasattr(first_shape, 'geoms'):
        raise ValueError(
            "Invalid watershed boundary geometry. "
            "To fix this, remove disconnected shapes or run "
            "gsshapy.modeling.GSSHAModel.clean_boundary_shapefile")
786791
function ( radius, segments, thetaStart, thetaLength ) {

	BufferGeometry.call( this );

	this.type = '';

	this.parameters = {
		radius: radius,
		segments: segments,
		thetaStart: thetaStart,
		thetaLength: thetaLength
	};

	radius = radius || 1;
	segments = segments !== undefined ? Math.max( 3, segments ) : 8;

	thetaStart = thetaStart !== undefined ? thetaStart : 0;
	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;

	// buffers

	var indices = [];
	var vertices = [];
	var normals = [];
	var uvs = [];

	// helper variables

	var i, s;
	var vertex = new Vector3();
	var uv = new Vector2();

	// center point

	vertices.push( 0, 0, 0 );
	normals.push( 0, 0, 1 );
	uvs.push( 0.5, 0.5 );

	for ( s = 0, i = 3; s <= segments; s ++, i += 3 ) {

		var segment = thetaStart + s / segments * thetaLength;

		// vertex

		vertex.x = radius * Math.cos( segment );
		vertex.y = radius * Math.sin( segment );

		vertices.push( vertex.x, vertex.y, vertex.z );

		// normal

		normals.push( 0, 0, 1 );

		// uvs

		uv.x = ( vertices[ i ] / radius + 1 ) / 2;
		uv.y = ( vertices[ i + 1 ] / radius + 1 ) / 2;

		uvs.push( uv.x, uv.y );

	}

	// indices

	for ( i = 1; i <= segments; i ++ ) {

		indices.push( i, i + 1, 0 );

	}

	// build geometry

	this.setIndex( indices );
	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

}
1101555
def _verify_shape_bounds(shape, bounds):
    """"""
    if not isinstance(shape, (tuple, list)) or len(shape) != 2:
        raise TypeError(
            "shape must be a tuple or list with two elements: %s" % str(shape)
        )
    if not isinstance(bounds, (tuple, list)) or len(bounds) != 4:
        raise TypeError(
            "bounds must be a tuple or list with four elements: %s" % str(bounds)
        )
    shape = Shape(*shape)
    bounds = Bounds(*bounds)
    shape_ratio = shape.width / shape.height
    bounds_ratio = (bounds.right - bounds.left) / (bounds.top - bounds.bottom)
    if abs(shape_ratio - bounds_ratio) > DELTA:
        min_length = min([
            (bounds.right - bounds.left) / shape.width,
            (bounds.top - bounds.bottom) / shape.height
        ])
        proposed_bounds = Bounds(
            bounds.left,
            bounds.bottom,
            bounds.left + shape.width * min_length,
            bounds.bottom + shape.height * min_length
        )
        raise ValueError(
            "shape ratio (%s) must equal bounds ratio (%s); try %s" % (
                shape_ratio, bounds_ratio, proposed_bounds
            )
        )
701746
function createGeometry (data) {
  var geometryType = data.primitive;
  var GeometryClass = geometries[geometryType] && geometries[geometryType].Geometry;
  var geometryInstance = new GeometryClass();

  if (!GeometryClass) { throw new Error('Unknown geometry `' + geometryType + '`'); }

  geometryInstance.init(data);
  return toBufferGeometry(geometryInstance.geometry, data.buffer);
}
1232990
private void ShapePostParsing() {
        if (!gvrRenderingDataUSEd) {
            // SHAPE node not being USEd (shared) elsewhere

            // Shape containts Text
            if (gvrTextViewSceneObject != null) {
                gvrTextViewSceneObject.setTextColor((((0xFF << 8)
                        + (int) (shaderSettings.diffuseColor[0] * 255) << 8)
                        + (int) (shaderSettings.diffuseColor[1] * 255) << 8)
                        + (int) (shaderSettings.diffuseColor[2] * 255));
                gvrTextViewSceneObject = null;
            }

            {
                // UNIVERSAL_LIGHTS

                if (!gvrMaterialUSEd) { // if GVRMaterial is NOT set by a USE statement.

                    if (meshAttachedSceneObject == null) {
                        gvrMaterial = shaderSettings.material;
                        gvrRenderData.setMaterial(gvrMaterial);
                    } else {
                        // This GVRSceneObject came with a GVRRenderData and GVRMaterial
                        // already attached.  Examples of this are Text or primitives
                        // such as the Box, Cone, Cylinder, Sphere

                        DefinedItem definedGRRenderingData = null;
                        if (gvrRenderData != null) {
                            // <Shape> node created an unused gvrRenderData
                            // Check if we had a DEF in Shape node so that we can point to
                            // the new gvrRenderData
                            for (DefinedItem definedItem : mDefinedItems) {
                                if (definedItem.getGVRRenderData() == gvrRenderData) {
                                    definedGRRenderingData = definedItem;
                                    break;
                                }
                            }
                        }
                        gvrRenderData = meshAttachedSceneObject.getRenderData();
                        // reset the DEF item to now point to the shader
                        if (definedGRRenderingData != null)
                            definedGRRenderingData.setGVRRenderData(gvrRenderData);
                        gvrMaterial = gvrRenderData.getMaterial();
                    }
                    // X3D doesn't have an ambient color so need to do color
                    // calibration tests on how to set this.
                    gvrMaterial.setVec4("diffuse_color",
                            shaderSettings.diffuseColor[0],
                            shaderSettings.diffuseColor[1],
                            shaderSettings.diffuseColor[2],
                            (1.0f - shaderSettings.getTransparency()) );
                    gvrMaterial.setVec4("specular_color",
                            shaderSettings.specularColor[0],
                            shaderSettings.specularColor[1],
                            shaderSettings.specularColor[2], 1.0f);
                    gvrMaterial.setVec4("emissive_color",
                            shaderSettings.emissiveColor[0],
                            shaderSettings.emissiveColor[1],
                            shaderSettings.emissiveColor[2], 1.0f);
                    gvrMaterial.setFloat("specular_exponent",
                            128.0f * shaderSettings.shininess);

                    if (!shaderSettings.getMaterialName().isEmpty()) {
                        DefinedItem definedItem = new DefinedItem(
                                shaderSettings.getMaterialName());
                        definedItem.setGVRMaterial(gvrMaterial);
                        mDefinedItems.add(definedItem); // Add gvrMaterial to Array list
                        // of DEFined items Clones
                        // objects with USE
                    }

                    if ( shaderSettings.getMultiTexture()) {
                        if ( !shaderSettings.getMultiTextureName().isEmpty() ) {
                            DefinedItem definedItem = new DefinedItem(
                                    shaderSettings.getMultiTextureName() );
                            definedItem.setGVRMaterial(gvrMaterial);
                            mDefinedItems.add(definedItem); // Add gvrMaterial to Array list
                        }
                        gvrMaterial.setTexture("diffuseTexture", shaderSettings.getMultiTextureGVRTexture(0) );
                        gvrMaterial.setTexture("diffuseTexture1", shaderSettings.getMultiTextureGVRTexture(1) );
                        // 0:Mul; 1=for ADD; 2 for SUBTRACT; 3 for DIVIDE; 4=smooth add; 5=Signed add
                        gvrMaterial.setInt("diffuseTexture1_blendop", shaderSettings.getMultiTextureMode().ordinal());
                        gvrMaterial.setTexCoord("diffuseTexture", "a_texcoord", "diffuse_coord");
                        gvrMaterial.setTexCoord("diffuseTexture1", "a_texcoord", "diffuse_coord1");

                    }
                    else if (shaderSettings.texture != null) {
                        gvrMaterial.setTexture("diffuseTexture",
                                shaderSettings.texture);
                        // if the TextureMap is a DEFined item, then set the
                        // GVRMaterial to it as well to help if we set the
                        // in a SCRIPT node.
                        for (DefinedItem definedItem: mDefinedItems) {
                            if ( definedItem.getGVRTexture() == shaderSettings.texture) {
                                definedItem.setGVRMaterial(gvrMaterial);
                                break;
                            }
                        }
                    }

                    if ( !shaderSettings.movieTextures.isEmpty()) {
                        try {
                            GVRVideoSceneObjectPlayer<?> videoSceneObjectPlayer = null;
                            try {
                                videoSceneObjectPlayer = utility.makeExoPlayer(shaderSettings.movieTextures.get(0));
                            }
                            catch (Exception e) {
                                Log.e(TAG, "Exception getting videoSceneObjectPlayer: " + e);
                            }
                            videoSceneObjectPlayer.start();

                            GVRVideoSceneObject gvrVideoSceneObject =
                                    new GVRVideoSceneObject(gvrContext, gvrRenderData.getMesh(), videoSceneObjectPlayer,
                                            GVRVideoSceneObject.GVRVideoType.MONO);
                            currentSceneObject.addChildObject(gvrVideoSceneObject);
                            // Primitives such as Box, Cone, etc come with their own mesh
                            // so we need to remove these.
                            if ( meshAttachedSceneObject != null) {
                                GVRSceneObject primitiveParent = meshAttachedSceneObject.getParent();
                                primitiveParent.removeChildObject(meshAttachedSceneObject);
                            }
                            meshAttachedSceneObject = gvrVideoSceneObject;

                            if (shaderSettings.getMovieTextureName() != null) {
                                gvrVideoSceneObject.setName(shaderSettings.getMovieTextureName());
                                DefinedItem item = new DefinedItem(shaderSettings.getMovieTextureName());
                                item.setGVRVideoSceneObject(gvrVideoSceneObject);
                                mDefinedItems.add(item);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            Log.e(TAG, "X3D MovieTexture Exception:\n" + e);
                        }
                    }  // end MovieTexture

                    // Texture Transform
                    // If DEFined iteam, add to the DeFinedItem list. Maay be interactive
                    // GearVR may not be doing texture transforms on primitives or text
                    // crash otherwise.

                    if (meshAttachedSceneObject == null) {
                        if (!shaderSettings.getTextureTransformName().isEmpty()) {
                            DefinedItem definedItem = new DefinedItem(
                                    shaderSettings.getTextureTransformName());
                            definedItem.setGVRMaterial(gvrMaterial);
                            definedItem.setTextureTranslation(shaderSettings.getTextureTranslation());
                            definedItem.setTextureCenter(shaderSettings.getTextureCenter());
                            definedItem.setTextureScale(shaderSettings.getTextureScale());
                            definedItem.setTextureRotation(shaderSettings.getTextureRotation().getValue());
                            definedItem.setName(shaderSettings.getTextureTransformName());
                            mDefinedItems.add(definedItem); // Add gvrMaterial to Array list
                        }
                        // Texture Transform Matrix equation:
                        // TC' = -C * S * R * C * T * TC
                        //where TC' is the transformed texture coordinate
                        //   TC is the original Texture Coordinate
                        //   C = center, S = scale, R = rotation, T = translation
                        Matrix3f textureTransform = animationInteractivityManager.SetTextureTransformMatrix(
                                shaderSettings.getTextureTranslation(),
                                shaderSettings.getTextureCenter(),
                                shaderSettings.getTextureScale(),
                                shaderSettings.getTextureRotation());

                        shaderSettings.textureMatrix = textureTransform;
                        float[] texMtx = new float[9];
                        shaderSettings.textureMatrix.get(texMtx);
                        gvrMaterial.setFloatArray("texture_matrix", texMtx);
                    }

                    // Appearance node thus far contains properties of GVRMaterial
                    // node
                    if (!shaderSettings.getAppearanceName().isEmpty()) {
                        DefinedItem definedItem = new DefinedItem(
                                shaderSettings.getAppearanceName());
                        definedItem.setGVRMaterial(gvrMaterial);
                        mDefinedItems.add(definedItem);
                        // Add gvrMaterial to Array list
                        // of DEFined items Clones
                        // objects with USE
                    }

                    if ((shaderSettings.getTransparency() != 0) && (shaderSettings.getTransparency() != 1)) {
                        gvrRenderData.setRenderingOrder(GVRRenderingOrder.TRANSPARENT);
                    }

                } // end ! gvrMaterialUSEd

                gvrTexture = null;
            }
        } // end !gvrRenderingDataUSEd

        if (meshAttachedSceneObject != null) {
            // gvrRenderData already attached to a GVRSceneObject such as a
            // Cone or Cylinder or a Movie Texture
            meshAttachedSceneObject = null;
        } else
            currentSceneObject.attachRenderData(gvrRenderData);

        if (lodManager.shapeLODSceneObject != null) {
            // if this Shape node was a direct child of a
            // Level-of-Detial (LOD),then restore the parent object
            // since we had to add a GVRSceneObject to support
            // the Shape node's attachement to LOD.
            currentSceneObject = currentSceneObject.getParent();
            lodManager.shapeLODSceneObject = null;
        }

        gvrMaterialUSEd = false; // for DEFine and USE, true if we encounter a
        // USE
        gvrRenderingDataUSEd = false; // for DEFine and USE gvrRenderingData for
        // x3d SHAPE node
        gvrRenderData = null;

    }
1063385
function createVoxelMesh(gl, voxels, voxelSideTextureIDs, voxelSideTextureSizes, position, pad, that) {
  //Create mesh
  var vert_data = createAOMesh(voxels, voxelSideTextureIDs, voxelSideTextureSizes)
  var vertexArrayObjects = {}

  if (vert_data === null) {
    // no vertices allocated
  } else {
    //Upload triangle mesh to WebGL
    var vert_buf = createBuffer(gl, vert_data)
    var triangleVAO = createVAO(gl, [
      { "buffer": vert_buf,
        "type": gl.UNSIGNED_BYTE,
        "size": 4,
        "offset": 0,
        "stride": 8,
        "normalized": false
      },
      { "buffer": vert_buf,
        "type": gl.UNSIGNED_BYTE,
        "size": 4,
        "offset": 4,
        "stride": 8,
        "normalized": false
      }
    ])
    triangleVAO.length = Math.floor(vert_data.length/8)

    vertexArrayObjects.surface = triangleVAO
  }

  // move the chunk into place
  var modelMatrix = mat4.create()
  var w = voxels.shape[2] - pad  // =[1]=[0]=game.chunkSize
  var translateVector = [
    position[0] * w,
    position[1] * w,
    position[2] * w]

  mat4.translate(modelMatrix, modelMatrix, translateVector)

  //Bundle result and return
  var result = {
    vertexArrayObjects: vertexArrayObjects, // other plugins can add their own VAOs
    center: [w>>1, w>>1, w>>1],
    radius: w,
    modelMatrix: modelMatrix
  }

  if (that) that.emit('meshed', result, gl, vert_data, voxels)

  return result
}
570311
def shapes(self):
        """"""
        shp = self.__getFileObj(self.shp)
        shp.seek(100)
        shapes = []
        while shp.tell() < self.shpLength:
            shapes.append(self.__shape())
        return shapes
659216
function getGeometry(data) {
  if (data.attributes) {
    validateGeometryAttributes(data.attributes);
    if (data instanceof Geometry) {
      return data;
    } else {
      return new Geometry(data);
    }
  } else if (data.positions || data.POSITION) {
    validateGeometryAttributes(data);
    return new Geometry({
      attributes: data
    });
  }
  throw Error('Invalid mesh');
}
1296307
def shape(self):
        ""
        num = len(self)
        if num <= self._max_cols:
            return (1, num)
        nrows = num // self._max_cols
        last_row_cols = num % self._max_cols
        return nrows+(1 if last_row_cols else 0), min(num, self._max_cols)
539518
function ( path, tubularSegments, radius, radialSegments, closed ) {

	BufferGeometry.call( this );

	this.type = '';

	this.parameters = {
		path: path,
		tubularSegments: tubularSegments,
		radius: radius,
		radialSegments: radialSegments,
		closed: closed
	};

	tubularSegments = tubularSegments || 64;
	radius = radius || 1;
	radialSegments = radialSegments || 8;
	closed = closed || false;

	var frames = path.computeFrenetFrames( tubularSegments, closed );

	// expose internals

	this.tangents = frames.tangents;
	this.normals = frames.normals;
	this.binormals = frames.binormals;

	// helper variables

	var vertex = new Vector3();
	var normal = new Vector3();
	var uv = new Vector2();
	var P = new Vector3();

	var i, j;

	// buffer

	var vertices = [];
	var normals = [];
	var uvs = [];
	var indices = [];

	// create buffer data

	generateBufferData();

	// build geometry

	this.setIndex( indices );
	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

	// functions

	function generateBufferData() {

		for ( i = 0; i < tubularSegments; i ++ ) {

			generateSegment( i );

		}

		// if the geometry is not closed, generate the last row of vertices and normals
		// at the regular position on the given path
		//
		// if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ)

		generateSegment( ( closed === false ) ? tubularSegments : 0 );

		// uvs are generated in a separate function.
		// this makes it easy compute correct values for closed geometries

		generateUVs();

		// finally create faces

		generateIndices();

	}

	function generateSegment( i ) {

		// we use getPointAt to sample evenly distributed points from the given path

		P = path.getPointAt( i / tubularSegments, P );

		// retrieve corresponding normal and binormal

		var N = frames.normals[ i ];
		var B = frames.binormals[ i ];

		// generate normals and vertices for the current segment

		for ( j = 0; j <= radialSegments; j ++ ) {

			var v = j / radialSegments * Math.PI * 2;

			var sin = Math.sin( v );
			var cos = - Math.cos( v );

			// normal

			normal.x = ( cos * N.x + sin * B.x );
			normal.y = ( cos * N.y + sin * B.y );
			normal.z = ( cos * N.z + sin * B.z );
			normal.normalize();

			normals.push( normal.x, normal.y, normal.z );

			// vertex

			vertex.x = P.x + radius * normal.x;
			vertex.y = P.y + radius * normal.y;
			vertex.z = P.z + radius * normal.z;

			vertices.push( vertex.x, vertex.y, vertex.z );

		}

	}

	function generateIndices() {

		for ( j = 1; j <= tubularSegments; j ++ ) {

			for ( i = 1; i <= radialSegments; i ++ ) {

				var a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
				var b = ( radialSegments + 1 ) * j + ( i - 1 );
				var c = ( radialSegments + 1 ) * j + i;
				var d = ( radialSegments + 1 ) * ( j - 1 ) + i;

				// faces

				indices.push( a, b, d );
				indices.push( b, c, d );

			}

		}

	}

	function generateUVs() {

		for ( i = 0; i <= tubularSegments; i ++ ) {

			for ( j = 0; j <= radialSegments; j ++ ) {

				uv.x = i / tubularSegments;
				uv.y = j / radialSegments;

				uvs.push( uv.x, uv.y );

			}

		}

	}

}
256549
function fillRect(x, y, width, height) {
         if (this.backBufferContext2D.globalAlpha < 1 / 255) {
           // Fast path: don't draw fully transparent
           return;
         }

         this.backBufferContext2D.fillRect(x, y, width, height);
       }
55324
function BufferGeometry() {

	Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } );

	this.uuid = _Math.generateUUID();

	this.name = '';
	this.type = 'BufferGeometry';

	this.index = null;
	this.attributes = {};

	this.morphAttributes = {};

	this.groups = [];

	this.boundingBox = null;
	this.boundingSphere = null;

	this.drawRange = { start: 0, count: Infinity };

	this.userData = {};

}