ddg.conversion package

Subpackages

Submodules

Module contents

ddg.conversion.to_smooth_net(object_, domain=None, **kwargs)[source]

Convert an object to a smooth net.

Parameters:
object_Subspace, Point, Quadric, Intersection or Join

Object to be converted. Currently supported:

  • Subspace and Point in any ambient space,

  • Quadric contained in 1D, 2D and 3D subspaces in any ambient space,

  • Intersection and Join. These will be resolved and converted if resolving produces an object of a different, supported type.

domainlist or SmoothDomain (default=None)

Optionally a domain to assign to the net. If domain is not contained in the default domain, they are intersected and a warning is raised. Uses ddg.datastructures.nets.utils.create_subdomain().

**kwargsdict

Keyword arguments to be passed to the type-specific conversion. See submodules for available options.

Returns:
SmoothNet, SmoothCurve, PointNet or EmptyNet
Raises:
TypeError

If object has a type for which conversion is not possible.

Warns:
RuntimeWarning

If domain is not contained in the default domain of the object.

ddg.conversion.to_halfedge(object_, **kwargs)[source]

Converts an object to a primitive halfedge surface depending to its type.

ddg.conversion.to_blender_object_helper(obj, name=None, location=None, hide_viewport=None, hide_render=None, scale=None, shade_smooth=False, bounding_box=None, accept_all=False, material=None, collection=None, **kwargs)[source]

Fast conversion function for ddg objects to be converted to blender.

It combines the following two utilities:

  • converting Subspaces and Quadrics to SmoothNets, SmoothNets to DiscreteNets and DiscreteNets and half-edge objects to blender objects

  • simplifies the input of commonly used arguments for the Blender object creation.

Notes for the conversion:

  • each conversion that uses a DiscreteNet at some point requires a sampling keyword, see Options for SmoothNet, respectively ddg.nets.conversion.sample_smooth_domain.

  • each ddg object may have specific conversion arguments, see below. Note that e.g. for a Quadric one can use specific arguments for the conversion from a Quadric to a SmoothNet, from a SmoothNet to a DiscreteNet and from a DiscreteNet to a Blender object.

  • conversion from 1d Subspaces or Conics use options for DiscreteCurves

Notes for the commonly used arguments:

  • All the keyword arguments of this function will be converted to a form that is readable for to_blender_object().

  • in **kwargs further keyword arguments can be given in a form required by to_blender_object().

Parameters:
objddg object

Any object of the ddg library except some types of nets with depth (see warning).

namestr (default=None)

Name of the resulting Blender object

locationiterable of shape (3,) (default=(0,0,0))

Location of the resulting Blender object.

hide_viewportbool (default=False)

Boolean to set to blender_object.hide_viewport.

hide_renderbool (default=False)

Boolean to set to blender_object.hide_render.

scale: iterable of shape (3,) (default=(1,1,1))

Scaling of the resulting Blender object set as blender_object.scale.

shade_smoothbool (default=False)

Boolean to decide whether to apply ddg.visualization.blender.mesh.shade_smooth() to the mesh of the resulting Blender object.

bounding_boxiterable of shape (3,) (default=(1,1,1))

Boolean to decide weather to apply ddg.visualization.blender.bmesh.cut_bounding_box() (respectively ddg.datastructures.nets.utils.cut_bounding_box() if blender_object.data will be of type bpy.Curves).

accept_allbool (optional default=False)

When True all options are accepted, but no warning will be given when the conversion does not support one of them.

materialstring or bpy.types.Material (optional, default=None)

Material of the created Blender object

collectionbpy.types.Collection (default=None)

Collection to link the blender object to. If set to None the object will be linked to bpy.context.scene.collection.

**kwargs

Keyword arguments to use in the conversion. Available options depend on the type of the given object (see below). All other keyword arguments (that are not type specific) will be handed over to to_blender_object(). For example this can be further (lists of) transformations of the mesh/bmesh or Blender object or attributes of the resulting objects.

Options for Subspaces:

convexbool (default=True)

Whether to use convex parametrization (see subspace_to_smooth_net()).

affinebool (default=True)

Whether the resulting smooth net should return homogeneous or affine coordinates (see subspace_to_smooth_net()).

domainlist or SmoothDomain (default=None)

Optionally a domain to assign to the SmoothNet (see ddg.datastructures.nets.utils.create_subdomain(), to_smooth_net()).

As well as all options for SmoothNet and DiscreteNet.

Options for Quadrics:

affinebool (default=False)

Whether the resulting SmoothNet should return affine or homogeneous coordinates (see quadric_to_smooth_net()).

domainlist or SmoothDomain (default=None)

Optionally a domain to assign to the SmoothNet (see ddg.datastructures.nets.utils.create_subdomain(), to_smooth_net()).

As well as all options for SmoothNet and DiscreteNet.

Options for Spheres:

No options.

Options for SmoothNet:

samplinglist, int or float

See ddg.datastructures.nets.conversion.sample_smooth_domain().

anchorlist or None

Anchor point for sampling process.

atollist, int or float

Tolerance(s) for sampling process.

Options for DiscreteNet:

boundingint (default=10)

Used to bound unbounded domains of nets.

only_wirebool (default=False)

When True, only the wireframe of the net will be created.

Options for DiscreteCurve:

boundingint (default=10)

Used to bound unbounded domains of nets.

curve_typestring (default=’POLY’)

Blender curve type. See the Blender docs for all available types.

curve_propertiesdictionary (default={‘bevel_depth’: 0.015})

Dictionary containing Blender curve properties. See the Blender docs for all available properties.

Options for PointNet:

sphere_radiusfloat (default=0)

Radius of the sphere representing a point.

sphere_subdivisionint (default=3)

How many subdivisions will be applied to the sphere.

Options for Half-Edge:

co_attrstr (default=’co’)

Name of the vertex attribute that stores the coordinates.

Returns:
Blender object

Blender object associated with the ddg object.

Warning

This function can only handle DiscreteNets and DiscreteCurves as nets with depth. Not supported for SmoothNets and SmoothCurves. Also in the case of DiscreteNets and DiscreteCurves the net must consist of either

  • EmptyNets

  • PointNets

  • DiscreteNets

  • Half-edge Objects

  • Collections of either

ddg.conversion.to_blender_object(obj, accept_all=False, depth_bounding=10, attributes={}, material=None, collection=None, mesh_transformations=[], bmesh_transformations=[], obj_transformations=[], link=True, **options)[source]

Create and link a Blender object from a given DDG object.

Parameters:
objddg.datastructure

DDG datastructure to convert into a Blender object.

accept_allbool (optional default=False)

When True all options are accepted, but no warning will be given when the conversion does not support one of them.

depth_boundingint (optional, default=10)

Bounding used for the highest layer of Nets with depth

attributesdict (optional, default={})

Attributes that will be assigned to the resulting Blender object such as name, parent, matrix_world, location, hide_viewport etc. in a dictionary as {‘attribute’: value}

materialstring or bpy.types.Material (optional, default=None)

Material of the created Blender object

collectionbpy.types.Collection (optional, default=None)

Collection to link the blender object to. If set to None the object will be linked to bpy.context.scene.collection.

mesh_transformationsfunction or list of functions (optional, default=[])

Functions which should be applied to the mesh of the object. The transformation functions need to be defined such that they only take one (required) parameter, namely the mesh.

bmesh_transformationsfunction or list of functions (optional, default=[])

Functions which should be applied to the bmesh of the object. The transformation functions need to be defined such that they only take one (required) parameter, namely the bmesh.

obj_transformationsfunction or list of functions (optional, default=[])

Functions which should be applied to the object. The transformation functions need to be defined such that they only take one (required) parameter, namely the object.

link: bool (optional, default=True)

If set to True, the object will be linked to the given collection. If set to False, the object will be created but not linked to any collection.

**options

Options to use in the conversion. Available options depend on the type of the given object.

Options for DiscreteNet:

boundingint (default=10)

Used to bound unbounded domains of nets.

only_wirebool (default=False)

When True, only the wireframe of the net will be created.

Options for DiscreteCurve:

boundingint (default=10)

Used to bound unbounded domains of nets.

curve_typestring (default=’POLY’)

Blender curve type. See the Blender docs for all available types.

curve_propertiesdictionary (default={‘bevel_depth’: 0.015})

Dictionary containing Blender curve properties. See the Blender docs for all available properties.

options for PointNet:

sphere_radiusfloat (default=0)

Radius of the sphere representing a point.

sphere_subdivisionint (default=3)

How many subdivisions will be applied to the sphere.

Options for HalfEdge surfaces:

co_attrstr (default=’co’)

The name of the vertex attribute that contains the coordinates.

Returns:
Blender object

Blender object associated with the DDG object.

Raises:
TypeError

if object is not convertible.