Rhino C++ API  8.5
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ON_TextureMapping Class Reference

#include <opennurbs_texture_mapping.h>

Inheritance diagram for ON_TextureMapping:
ON_ModelComponent ON_Object CRhinoTextureMapping

Public Types

enum  PROJECTION : unsigned int { PROJECTION::no_projection = 0, PROJECTION::clspt_projection = 1, PROJECTION::ray_projection = 2 }
 
enum  TEXTURE_SPACE : unsigned int { TEXTURE_SPACE::single = 0, TEXTURE_SPACE::divided = 1 }
 
enum  TYPE : unsigned int {
  TYPE::no_mapping = 0, TYPE::srfp_mapping = 1, TYPE::plane_mapping = 2, TYPE::cylinder_mapping = 3,
  TYPE::sphere_mapping = 4, TYPE::box_mapping = 5, TYPE::mesh_mapping_primitive = 6, TYPE::srf_mapping_primitive = 7,
  TYPE::brep_mapping_primitive = 8, TYPE::ocs_mapping = 9, TYPE::false_colors = 10
}
 
- Public Types inherited from ON_ModelComponent
enum  Attributes : unsigned int {
  NoAttributes = 0U, ComponentSerialNumberAttribute = 0x0001U, TypeAttribute = 0x0002U, ModelSerialNumberAttribute = 0x0004U,
  IdAttribute = 0x0008U, IndexAttribute = 0x0010U, NameAttribute = 0x0020U, ParentIdAttribute = 0x0040U,
  DeletedNameAttribute = 0x0080U, ComponentStatusAttribute = 0x0100U, BinaryArchiveAttributes = 0x78U, AllAttributes = 0x1FFU,
  SystemComponentAttribute = 0x8000U
}
 
enum  Type : unsigned char {
  Type::Unset = 0, Type::Image = 1, Type::TextureMapping = 2, Type::Material = 3,
  Type::RenderMaterial = Material, Type::LinePattern = 4, Type::Layer = 5, Type::Group = 6,
  Type::TextStyle = 7, Type::DimStyle = 8, Type::RenderLight = 9, Type::HatchPattern = 10,
  Type::InstanceDefinition = 11, Type::ModelGeometry = 12, Type::HistoryRecord = 13, Type::RenderContent = 14,
  Type::EmbeddedFile = 15, Type::ObsoleteValue = 16, Type::SectionStyle = 17, Type::NumOf,
  Type::Mixed = 0xFE
}
 The ON_ModelComponent::Type enum has a value for each explicit component type and two special values, Unset and Mixed. Use an ON_ModelComponentTypeIterator instance to iterate over the ON_ModelComponent::Type values. /summary> More...
 
- Public Types inherited from ON_Object
enum  UserDataConflictResolution : unsigned char {
  UserDataConflictResolution::destination_object = 0, UserDataConflictResolution::source_object = 1, UserDataConflictResolution::source_copycount_gt = 2, UserDataConflictResolution::source_copycount_ge = 3,
  UserDataConflictResolution::destination_copycount_gt = 4, UserDataConflictResolution::destination_copycount_ge = 5, UserDataConflictResolution::delete_item = 6
}
 

Public Member Functions

 ON_TextureMapping () ON_NOEXCEPT
 
 ON_TextureMapping (const ON_TextureMapping &src)
 
virtual ~ON_TextureMapping ()
 
const ON_BrepCustomMappingBrepPrimitive (void) const
 
const ON_MeshCustomMappingMeshPrimitive (void) const
 
const ON_ObjectCustomMappingPrimitive (void) const
 
const ON_SurfaceCustomMappingSurfacePrimitive (void) const
 
void Dump (ON_TextLog &) const override
 
virtual int Evaluate (const ON_3dPoint &P, const ON_3dVector &N, ON_3dPoint *T) const
 
virtual int Evaluate (const ON_3dPoint &P, const ON_3dVector &N, ON_3dPoint *T, const ON_Xform &P_xform, const ON_Xform &N_xform) const
 
int EvaluateBoxMapping (const ON_3dPoint &P, const ON_3dVector &N, ON_3dPoint *T) const
 
int EvaluateBrepMapping (const ON_3dPoint &P, const ON_3dVector &N, const ON_Brep *brep, ON_3dPoint *T) const
 
int EvaluateCylinderMapping (const ON_3dPoint &P, const ON_3dVector &N, ON_3dPoint *T) const
 
int EvaluateMeshMapping (const ON_3dPoint &P, const ON_3dVector &N, const ON_Mesh *mesh, ON_3dPoint *T) const
 
int EvaluatePlaneMapping (const ON_3dPoint &P, const ON_3dVector &N, ON_3dPoint *T) const
 
int EvaluateSphereMapping (const ON_3dPoint &P, const ON_3dVector &N, ON_3dPoint *T) const
 
int EvaluateSurfaceMapping (const ON_3dPoint &P, const ON_3dVector &N, const ON_Surface *srf, ON_3dPoint *T) const
 
bool GetMappingBox (ON_Plane &plane, ON_Interval &dx, ON_Interval &dy, ON_Interval &dz) const
 
bool GetMappingCylinder (ON_Cylinder &cylinder) const
 
bool GetMappingPlane (ON_Plane &plane, ON_Interval &dx, ON_Interval &dy, ON_Interval &dz) const
 
bool GetMappingSphere (ON_Sphere &sphere) const
 
bool GetTextureCoordinates (const ON_Mesh &mesh, ON_SimpleArray< ON_2fPoint > &T, const ON_Xform *mesh_xform=0, bool bLazy=false, ON_SimpleArray< int > *Tside=0) const
 
bool GetTextureCoordinates (const ON_Mesh &mesh, ON_SimpleArray< ON_3fPoint > &T, const ON_Xform *mesh_xform=0, bool bLazy=false, ON_SimpleArray< int > *Tside=0) const
 
bool HasMatchingCachedTextureCoordinates (const ON_Mesh &mesh, const ON_Xform *object_xform=nullptr) const
 
bool HasMatchingTextureCoordinates (const class ON_MappingTag &tag, const ON_Xform *object_xform=nullptr) const
 
bool HasMatchingTextureCoordinates (const ON_Mesh &mesh, const ON_Xform *object_xform=nullptr) const
 
bool IsPeriodic (void) const
 
bool IsValid (class ON_TextLog *text_log=nullptr) const override
 
ON__UINT32 MappingCRC () const
 
ON_TextureMappingoperator= (const ON_TextureMapping &src)
 
bool Read (ON_BinaryArchive &binary_archive) override
 
bool RequiresVertexNormals () const
 
bool ReverseTextureCoordinate (int dir)
 
bool SetBoxMapping (const ON_Plane &plane, ON_Interval dx, ON_Interval dy, ON_Interval dz, bool bIsCapped)
 
void SetCustomMappingPrimitive (ON_Object *)
 
bool SetCylinderMapping (const ON_Cylinder &cylinder, bool bIsCapped)
 
bool SetOcsMapping (const ON_Plane &plane)
 
bool SetPlaneMapping (const ON_Plane &plane, const ON_Interval &dx, const ON_Interval &dy, const ON_Interval &dz)
 
bool SetSphereMapping (const ON_Sphere &sphere)
 
bool SetSurfaceParameterMapping (void)
 
const std::shared_ptr< const ON_Object > & SharedCustomMappingPrimitive (void) const
 
unsigned int SizeOf () const override
 
bool SwapTextureCoordinate (int i, int j)
 
bool TileTextureCoordinate (int dir, double count, double offset)
 
bool Write (ON_BinaryArchive &binary_archive) const override
 
- Public Member Functions inherited from ON_ModelComponent
 ON_ModelComponent () ON_NOEXCEPT
 
 ON_ModelComponent (const ON_ModelComponent &source)
 
 ON_ModelComponent (ON_ModelComponent::Type component_type) ON_NOEXCEPT
 
 ON_ModelComponent (ON_ModelComponent::Type component_type, const ON_ModelComponent &source) ON_NOEXCEPT
 Locked status of source attributes is not copied to permit copy and modify operations. More...
 
 ~ON_ModelComponent ()=default
 
bool ChangeName (const wchar_t *new_name, class ON_ComponentManifest *manifest)
 
bool ClearComponentType ()
 
bool ClearId ()
 
bool ClearIndex ()
 
unsigned int ClearModelComponentAttributes (unsigned int attributes_filter)
 
bool ClearModelComponentStatus ()
 
bool ClearModelSerialNumber ()
 
bool ClearName ()
 
bool ClearParentId ()
 
int CompareName (const ON_UUID &other_parent_id, const wchar_t *other_name) const
 
int CompareName (const wchar_t *other_name) const
 
int CompareNameExact (const ON_UUID &other_parent_id, const wchar_t *other_name) const
 
int CompareNameExact (const wchar_t *other_name) const
 
ON_ModelComponent::Type ComponentType () const
 
bool ComponentTypeIsLocked () const
 
bool ComponentTypeIsSet () const
 
ON__UINT64 ContentVersionNumber () const
 
unsigned int CopyFrom (const ON_ModelComponent &src, unsigned int attributes_filter)
 
ON__UINT32 DataCRC (ON__UINT32 current_remainder) const override
 
const ON_wString DeletedName () const
 
const ON_NameHashDeletedNameHash () const
 
bool DeletedNameIsSet () const
 
bool DeleteName ()
 
bool EraseIdentification (bool bIgnoreLocks)
 
const wchar_tGetName (ON_wString &component_name) const
 
const ON_UUIDId () const
 
bool IdIsLocked () const
 
bool IdIsNil () const
 
bool IdIsNotNil () const
 
bool IdIsSet () const
 
const ON_UUIDIfIdIsNilSetId ()
 
int Index () const
 
int Index (int unset_index_value) const
 
bool IndexIsLocked () const
 
bool IndexIsSet () const
 
unsigned int InstanceDefinitionModelSerialNumber () const
 
bool IsDeleted () const
 
bool IsHidden () const
 
bool IsLocked () const
 
bool IsReferenceComponent () const
 
bool IsSystemComponent () const
 
void LockAllSettingsExceptName ()
 
void LockComponentType ()
 
void LockId ()
 
void LockIndex ()
 
void LockModelComponentStatus ()
 
void LockModelSerialNumber ()
 
void LockName ()
 
void LockParentId ()
 
ON_ComponentStatus ModelComponentStatus () const
 
bool ModelComponentStatusIsLocked () const
 
bool ModelComponentStatusIsSet () const
 
ON_UUID ModelObjectId () const override
 
unsigned int ModelSerialNumber () const
 
bool ModelSerialNumberIsLocked () const
 
bool ModelSerialNumberIsSet () const
 
const ON_wString Name () const
 
const wchar_tNameAsPointer () const
 
const ON_NameHashNameHash () const
 
bool NameIsEmpty () const
 
bool NameIsLocked () const
 
bool NameIsNotEmpty () const
 
bool NameIsSet () const
 
const ON_NameHash NewNameHash (const wchar_t *new_name) const
 
ON_ModelComponentoperator= (const ON_ModelComponent &source)
 
const ON_UUIDParentId () const
 
bool ParentIdIsLocked () const
 
bool ParentIdIsNil () const
 
bool ParentIdIsNotNil () const
 
bool ParentIdIsSet () const
 
bool ReadModelComponentAttributes (class ON_BinaryArchive &archive)
 
unsigned int ReferenceModelSerialNumber () const
 
ON__UINT64 RuntimeSerialNumber () const
 
const ON_UUIDSetAndLockId ()
 
bool SetAsSystemComponent ()
 
bool SetAsUnsetSystemComponent ()
 
bool SetComponentType (ON_ModelComponent::Type component_component_type)
 
bool SetDeletedModelComponentState (bool bDeleted, class ON_ComponentManifest *manifest)
 
void SetHiddenModelComponentState (bool bHidden)
 
const ON_UUIDSetId ()
 
bool SetId (const ON_UUID &component_id)
 
bool SetIdentification (const class ON_ComponentManifestItem &manifest_item, const wchar_t *manifest_name, bool bSetId, bool bParentId, bool bSetName, bool bSetIndex)
 
bool SetIndex (int component_index)
 
bool SetLocalizedSystemComponentName (const wchar_t *system_component_localized_name)
 
void SetLockedModelComponentState (bool bLocked)
 
bool SetModelComponentStatus (ON_ComponentStatus component_status)
 
bool SetModelSerialNumber (unsigned int model_serial_number)
 
bool SetModelSerialNumber (unsigned int model_serial_number, unsigned int reference_model_serial_number, unsigned int instance_definition_model_serial_number)
 
bool SetName (const wchar_t *component_name)
 
bool SetParentId (const ON_UUID &parent_id)
 
bool UndeleteName ()
 
bool WriteModelComponentAttributes (class ON_BinaryArchive &archive, unsigned int attributes_filter) const
 
- Public Member Functions inherited from ON_Object
 ON_Object () ON_NOEXCEPT
 
 ON_Object (const ON_Object &)
 
virtual ~ON_Object ()
 
virtual ON_AggregateComponentStatus AggregateComponentStatus () const
 
bool AttachUserData (class ON_UserData *pUserData)
 
unsigned int ClearAllComponentStates () const
 
virtual unsigned int ClearComponentStates (ON_COMPONENT_INDEX component_index, ON_ComponentStatus states_to_clear) const
 
virtual unsigned int ClearComponentStates (ON_ComponentStatus states_to_clear) const
 
void CopyUserData (const ON_Object &source_object)
 
unsigned int CopyUserData (const ON_Object &source_object, ON_UUID source_userdata_item_id, ON_Object::UserDataConflictResolution userdata_conflict_resolution)
 
virtual bool DeleteComponents (const ON_COMPONENT_INDEX *ci_list, size_t ci_count)
 
virtual void DestroyRuntimeCache (bool bDelete=true)
 
bool DetachUserData (class ON_UserData *pUserData)
 
void EmergencyDestroy ()
 
class ON_UserDataFirstUserData () const
 
virtual unsigned int GetComponentsWithSetStates (ON_ComponentStatus states_filter, bool bAllEqualStates, ON_SimpleArray< ON_COMPONENT_INDEX > &components) const
 
class ON_UserDataGetUserData (const ON_UUID &userdata_uuid) const
 
bool GetUserString (const wchar_t *key, ON_wString &string_value) const
 
int GetUserStringKeys (ON_ClassArray< ON_wString > &user_string_keys) const
 
int GetUserStrings (ON_ClassArray< ON_UserString > &user_strings) const
 
bool IsCorrupt (bool bRepair, bool bSilentError, class ON_TextLog *text_log) const
 
bool IsKindOf (const ON_ClassId *pClassId) const
 
virtual void MarkAggregateComponentStatusAsNotCurrent () const
 
virtual void MemoryRelocate ()
 
void MoveUserData (ON_Object &source_object)
 
unsigned int MoveUserData (ON_Object &source_object, ON_UUID source_userdata_item_id, ON_Object::UserDataConflictResolution userdata_conflict_resolution, bool bDeleteAllSourceItems)
 
virtual ON::object_type ObjectType () const
 
ON_Objectoperator= (const ON_Object &)
 
void PurgeUserData ()
 
virtual unsigned int SetComponentStates (ON_COMPONENT_INDEX component_index, ON_ComponentStatus states_to_set) const
 
virtual unsigned int SetComponentStatus (ON_COMPONENT_INDEX component_index, ON_ComponentStatus status_to_copy) const
 
bool SetUserString (const wchar_t *key, const wchar_t *string_value)
 
int SetUserStrings (int count, const ON_UserString *user_strings, bool bReplace)
 
bool ThisIsNullptr (bool bSilentError) const
 
void TransformUserData (const class ON_Xform &xform)
 
virtual bool UpdateReferencedComponents (const class ON_ComponentManifest &source_manifest, const class ON_ComponentManifest &destination_manifest, const class ON_ManifestMap &manifest_map)
 
int UserStringCount () const
 

Static Public Member Functions

static const ON_TextureMappingFromModelComponentRef (const class ON_ModelComponentReference &model_component_reference, const ON_TextureMapping *none_return_value)
 
static ON_TextureMapping::PROJECTION ProjectionFromUnsigned (unsigned int projection_as_unsigned)
 
static const ON_wString ProjectionToString (ON_TextureMapping::PROJECTION texture_mapping_projection)
 
static void SetAdvancedBrepMappingToolFunctions (TEXMAP_INTERSECT_LINE_SURFACE, TEXMAP_BREP_FACE_CLOSEST_POINT)
 
static const ON_wString SpaceToString (ON_TextureMapping::TEXTURE_SPACE texture_mapping_space)
 
static ON_TextureMapping::TEXTURE_SPACE TextureSpaceFromUnsigned (unsigned int texture_space_as_unsigned)
 
static ON_TextureMapping::TYPE TypeFromUnsigned (unsigned int type_as_unsigned)
 
static const ON_wString TypeToString (ON_TextureMapping::TYPE texture_mapping_type)
 
- Static Public Member Functions inherited from ON_ModelComponent
static int CompareId (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareIdAndName (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareName (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareNameAndId (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static int CompareNameExact (const ON_ModelComponent &a, const ON_ModelComponent &b)
 
static ON_ModelComponent::Type ComponentTypeFromUnsigned (unsigned int component_type_as_unsigned)
 
static bool ComponentTypeIsValid (ON_ModelComponent::Type component_type)
 
static bool ComponentTypeIsValidAndNotMixed (ON_ModelComponent::Type component_type)
 
static const ON_wString ComponentTypeToString (ON_ModelComponent::Type)
 
static bool IndexRequired (ON_ModelComponent::Type component_type)
 
static unsigned int Internal_SystemComponentHelper ()
 For internal use. Never call this function. More...
 
static const wchar_tIsNamePathSeparator (const wchar_t *s)
 
*static const wchar_tIsReferencePrefixDelimiter (const wchar_t *s)
 
static const wchar_tIsReferencePrefixSeparator (const wchar_t *s)
 
static bool IsValidComponentName (const class ON_ComponentManifest &model_manfest, const ON_ModelComponent &model_component, bool bPermitReferencePrefix, ON_wString &valid_name)
 
static bool IsValidComponentName (const ON_wString &candidate_component_name)
 
static bool IsValidComponentName (const wchar_t *candidate_component_name)
 
static bool IsValidComponentName (size_t length, const wchar_t *candidate_component_name)
 
static bool IsValidComponentNameFirstCodePoint (int length, const wchar_t *candidate_component_name)
 
static bool IsValidComponentNameFirstCodePoint (ON__UINT32 unicode_code_point)
 
static const ON_wString NameLeaf (const wchar_t *name)
 
static const ON_wString NameParent (const wchar_t *name, bool bIncludeReference)
 
static const ON_wString NameReferencePrefix (const wchar_t *name)
 
static ON__UINT64 NextRuntimeSerialNumber ()
 
static const ON_wString RemoveAllReferencePrefixDelimiters (const wchar_t *name)
 
static const ON_wString RemoveReferencePrefix (const wchar_t *name)
 
static const ON_wString RemoveTrailingNamePathSeparator (const wchar_t *name)
 
static const ON_wString RemoveTrailingReferencePrefixDelimiter (const wchar_t *name)
 
static const ON_wString RemoveTrailingReferencePrefixSeparator (const wchar_t *name)
 
static void SplitName (const wchar_t *name, ON_wString &reference_prefix, ON_wString &name_parent, ON_wString &name_leaf)
 
static bool UniqueNameIgnoresCase (ON_ModelComponent::Type component_type)
 
static bool UniqueNameIncludesParent (ON_ModelComponent::Type component_type)
 
static bool UniqueNameRequired (ON_ModelComponent::Type component_type)
 

Public Attributes

bool m_bCapped = false
 
ON_Xform m_Nxyz = ON_Xform::IdentityTransformation
 
ON_TextureMapping::PROJECTION m_projection = ON_TextureMapping::PROJECTION::no_projection
 
ON_Xform m_Pxyz = ON_Xform::IdentityTransformation
 
ON_TextureMapping::TEXTURE_SPACE m_texture_space = ON_TextureMapping::TEXTURE_SPACE::single
 
ON_TextureMapping::TYPE m_type = ON_TextureMapping::TYPE::no_mapping
 
ON_Xform m_uvw = ON_Xform::IdentityTransformation
 

Static Public Attributes

static const ON_TextureMapping SurfaceParameterTextureMapping
 m_type = ON_TextureMapping::srfp_mapping m_id = ON_TextureMapping::SurfaceParameterTextureMappingId More...
 
static const ON_UUID SurfaceParameterTextureMappingId
 {B988A6C2-61A6-45a7-AAEE-9AED7EF4E316} More...
 
static const ON_TextureMapping Unset
 m_type = ON_TextureMapping::TYPE::no_mapping m_id = nil id More...
 
- Static Public Attributes inherited from ON_ModelComponent
static const ON_wString NamePathSeparator
 
static const ON_wString ReferencePrefixDelimiter
 
static const ON_wString ReferencePrefixSeparator
 
static const ON_ModelComponent Unset
 
*static const ON_wString WorksessionReferencePrefix *const wchar_t
 

Additional Inherited Members

- Protected Member Functions inherited from ON_ModelComponent
void IncrementContentVersionNumber () const
 

Member Enumeration Documentation

◆ PROJECTION

enum ON_TextureMapping::PROJECTION : unsigned int
strong

Projection:

When a mapping primitive, like a plane, sphere, box, or cylinder, is used, there are two projection options.

clspt_projection: world xyz maps to the point on the mapping primitive that is closest to xyz. In this case, ON_TextureMapping::Evaluate ignores the vector argument.

ray_projection: world xyz + world vector defines a world line. The world line is intersected with the mapping primitive and the intersection point that is closest to the world xyz point is used to calculate the mapping parameters.

The value of m_projection can be changed as needed.

If m_type = srfp_mapping, then m_projection is ignored.

Enumerator
no_projection 
clspt_projection 
ray_projection 

◆ TEXTURE_SPACE

enum ON_TextureMapping::TEXTURE_SPACE : unsigned int
strong

Texture space

When a mapping primitive is a box or a capped cylinder, there are two options for the mapping. Either the sides all map to (0,1)x(0,1) (so the either texture map appears on each side, or the sides map to distinct regions of the texture space.

Enumerator
single 

sides and caps map to same texture space

divided 

sides and caps map to distinct vertical regions of texture space. (0, 1/4, 2/4, 3/4, 1) for uncapped boxes. (0, 1/6, 2/6, 3/6, 4/6, 5/6, 1) for capped boxes. (0, 4/6, 5/6, 1) for capped cylinders.

◆ TYPE

enum ON_TextureMapping::TYPE : unsigned int
strong

Mapping types:

You can either calculate texture coordinates based on the parameterization of the surface used to create a mesh, or project the natural parameterization from a mapping primitive, like a plane, sphere, box, or cylinder. Do not change TYPE enum values - they are saved in 3dm files.

Enumerator
no_mapping 
srfp_mapping 

u,v = linear transform of surface params,w = 0

plane_mapping 

u,v,w = 3d coordinates wrt frame

cylinder_mapping 

u,v,w = longitude, height, radius

sphere_mapping 

(u,v,w) = longitude,latitude,radius

box_mapping 
mesh_mapping_primitive 

m_mapping_primitive is an ON_Mesh

srf_mapping_primitive 

m_mapping_primitive is an ON_Surface

brep_mapping_primitive 

m_mapping_primitive is an ON_Brep

ocs_mapping 

same as plane_mapping - used to differentiate between OCS and plane mapping in the UI

false_colors 

some kind of false color mapping used to set per vertex colors.

Constructor & Destructor Documentation

◆ ON_TextureMapping() [1/2]

ON_TextureMapping::ON_TextureMapping ( )

◆ ON_TextureMapping() [2/2]

ON_TextureMapping::ON_TextureMapping ( const ON_TextureMapping src)

◆ ~ON_TextureMapping()

virtual ON_TextureMapping::~ON_TextureMapping ( )
virtual

Member Function Documentation

◆ CustomMappingBrepPrimitive()

const ON_Brep* ON_TextureMapping::CustomMappingBrepPrimitive ( void  ) const

Returns a valid brep if the custom mapping primitive is a brep. Otherwise nullptr. Implementation is return ON_Brep::Cast(CustomMappingPrimitive());

◆ CustomMappingMeshPrimitive()

const ON_Mesh* ON_TextureMapping::CustomMappingMeshPrimitive ( void  ) const

Returns a valid mesh if the custom mapping primitive is a mesh. Otherwise nullptr. Implementation is return ON_Mesh::Cast(CustomMappingPrimitive());

◆ CustomMappingPrimitive()

const ON_Object* ON_TextureMapping::CustomMappingPrimitive ( void  ) const

Custom mapping primitive. Returns nullptr if no custom mapping primitive is stored in this texture mapping definition.

◆ CustomMappingSurfacePrimitive()

const ON_Surface* ON_TextureMapping::CustomMappingSurfacePrimitive ( void  ) const

Returns a valid surface if the custom mapping primitive is a surface. Otherwise nullptr. Implementation is return ON_Surface::Cast(CustomMappingPrimitive());

◆ Dump()

void ON_TextureMapping::Dump ( ON_TextLog ) const
overridevirtual

Description: Creates a text dump of the object. Remarks: Dump() is intended for debugging and is not suitable for creating high quality text descriptions of an object.

The default implementations of this virtual function prints the class's name.

Reimplemented from ON_ModelComponent.

◆ Evaluate() [1/2]

virtual int ON_TextureMapping::Evaluate ( const ON_3dPoint P,
const ON_3dVector N,
ON_3dPoint T 
) const
virtual

Description: Evaluate the mapping to get a texture coordinate. Parameters: P - [in] Vertex location N - [in] If the mapping projection is ray_projection, then this is the vertex unit normal. Otherwise N is ignored. T - [out] Texture coordinate (u,v,w)

P_xform -[in] Transformation to be applied to P before performing the mapping calculation. N_xform - [in] Transformation to be applied to N before performing the mapping calculation. One way to calculate N_xform is to use the call P_xform::GetVectorTransform(N_xform).

Returns: Nonzero if evaluation is successful. When the mapping is a box or capped cylinder mapping, the value indicates which side was evaluated.

Cylinder mapping: 1 = cylinder wall, 2 = bottom cap, 3 = top cap Box mapping: 1 = front 2 = right 3 = back 4 = left 5 = bottom 6 = top

See Also: ON_TextureMapping::GetTextureCoordinates ON_Mesh::SetTextureCoordinates

◆ Evaluate() [2/2]

virtual int ON_TextureMapping::Evaluate ( const ON_3dPoint P,
const ON_3dVector N,
ON_3dPoint T,
const ON_Xform P_xform,
const ON_Xform N_xform 
) const
virtual

◆ EvaluateBoxMapping()

int ON_TextureMapping::EvaluateBoxMapping ( const ON_3dPoint P,
const ON_3dVector N,
ON_3dPoint T 
) const

◆ EvaluateBrepMapping()

int ON_TextureMapping::EvaluateBrepMapping ( const ON_3dPoint P,
const ON_3dVector N,
const ON_Brep brep,
ON_3dPoint T 
) const

◆ EvaluateCylinderMapping()

int ON_TextureMapping::EvaluateCylinderMapping ( const ON_3dPoint P,
const ON_3dVector N,
ON_3dPoint T 
) const

◆ EvaluateMeshMapping()

int ON_TextureMapping::EvaluateMeshMapping ( const ON_3dPoint P,
const ON_3dVector N,
const ON_Mesh mesh,
ON_3dPoint T 
) const

◆ EvaluatePlaneMapping()

int ON_TextureMapping::EvaluatePlaneMapping ( const ON_3dPoint P,
const ON_3dVector N,
ON_3dPoint T 
) const

◆ EvaluateSphereMapping()

int ON_TextureMapping::EvaluateSphereMapping ( const ON_3dPoint P,
const ON_3dVector N,
ON_3dPoint T 
) const

◆ EvaluateSurfaceMapping()

int ON_TextureMapping::EvaluateSurfaceMapping ( const ON_3dPoint P,
const ON_3dVector N,
const ON_Surface srf,
ON_3dPoint T 
) const

◆ FromModelComponentRef()

static const ON_TextureMapping* ON_TextureMapping::FromModelComponentRef ( const class ON_ModelComponentReference model_component_reference,
const ON_TextureMapping none_return_value 
)
static

Parameters: model_component_reference - [in] none_return_value - [in] value to return if ON_Material::Cast(model_component_ref.ModelComponent()) is nullptr Returns: If ON_Material::Cast(model_component_ref.ModelComponent()) is not nullptr, that pointer is returned. Otherwise, none_return_value is returned.

◆ GetMappingBox()

bool ON_TextureMapping::GetMappingBox ( ON_Plane plane,
ON_Interval dx,
ON_Interval dy,
ON_Interval dz 
) const

Get a box projection from the texture mapping. Parameters: plane - [out]
The center of the box is at plane.origin and the sides of the box are parallel to the plane's coordinate planes. dx - [out] The "front" and "back" sides of the box are in spanned by the vectors plane.yaxis and plane.zaxis. The back plane contains the point plane.PointAt(dx[0],0,0) and the front plane contains the point plane.PointAt(dx[1],0,0). dy - [out] The "left" and "right" sides of the box are in spanned by the vectors plane.zaxis and plane.xaxis. The left plane contains the point plane.PointAt(0,dx[0],0) and the back plane contains the point plane.PointAt(0,dy[1],0). dz - [out] The "top" and "bottom" sides of the box are in spanned by the vectors plane.xaxis and plane.yaxis. The bottom plane contains the point plane.PointAt(0,0,dz[0]) and the top plane contains the point plane.PointAt(0,0,dz[1]). Returns: True if a valid box is returned. Remarks: Generally, GetMappingBox will not return the same parameters passed to SetBoxMapping. However, the location of the box will be the same.

◆ GetMappingCylinder()

bool ON_TextureMapping::GetMappingCylinder ( ON_Cylinder cylinder) const

Description: Get a cylindrical projection parameters from this texture mapping. Parameters: cylinder - [out]
Returns: True if a valid cylinder is returned. Remarks: Generally, GetMappingCylinder will not return the same parameters passed to SetCylinderMapping. However, the location of the cylinder will be the same.
If this mapping is not cylindrical, the cylinder will approximate the actual mapping primitive.

◆ GetMappingPlane()

bool ON_TextureMapping::GetMappingPlane ( ON_Plane plane,
ON_Interval dx,
ON_Interval dy,
ON_Interval dz 
) const

Description: Get plane mapping parameters from this texture mapping. Parameters: plane - [out] dx - [out] Portion of the plane's x axis that is mapped to [0,1] dy - [out] Portion of the plane's y axis that is mapped to [0,1] dz - [out] Portion of the plane's z axis that is mapped to [0,1] Returns: True if valid plane mapping parameters were returned. Remarks: NOTE WELL: Generally, GetMappingPlane will not return the same parameters passed to SetPlaneMapping. However, the location of the plane will be the same.

◆ GetMappingSphere()

bool ON_TextureMapping::GetMappingSphere ( ON_Sphere sphere) const

Description: Get a spherical projection parameters from this texture mapping. Parameters: sphere - [out]
Returns: True if a valid sphere is returned. Remarks: Generally, GetMappingShere will not return the same parameters passed to SetSphereMapping. However, the location of the sphere will be the same. If this mapping is not cylindrical, the cylinder will approximate the actual mapping primitive.

◆ GetTextureCoordinates() [1/2]

bool ON_TextureMapping::GetTextureCoordinates ( const ON_Mesh mesh,
ON_SimpleArray< ON_2fPoint > &  T,
const ON_Xform mesh_xform = 0,
bool  bLazy = false,
ON_SimpleArray< int > *  Tside = 0 
) const

◆ GetTextureCoordinates() [2/2]

bool ON_TextureMapping::GetTextureCoordinates ( const ON_Mesh mesh,
ON_SimpleArray< ON_3fPoint > &  T,
const ON_Xform mesh_xform = 0,
bool  bLazy = false,
ON_SimpleArray< int > *  Tside = 0 
) const

Description: Get texture coordinates. This calculation is expensive. When possible, use a MappingMatch() query to avoid unnecessary calculations. Parameters: mesh - [in] T - [out] Texture coordinates returned here. mesh_xform - [in] (optional) If the mesh has been transformed since the texture mapping was set up, pass the transformation here. Typically this is the value of ON_Mesh::m_mapping_xform or ON_MappingRef::m_object_xform bLazy - [in] If true and the mesh.m_T[] values were calculated using this mapping, they are simply copied to the T[] array and no calculations are performed. If you are calling the 3d point version and you care about the z-coordinate, then do not use the lazy option (meshes only store 2d texture coordinates). Tside - [out] In the case of divided textures, side information is returned here if a lazy mapping is not done. Otherwise Tside->Count() will be zero. Cylinder mapping: 1 = cylinder wall, 2 = bottom cap, 3 = top cap Box mapping: 1 = front 2 = right 3 = back 4 = left 5 = bottom 6 = top
Example:

    ON_TextureMapping mapping = ...;
    const ON_Mesh* mesh = ...;
    bool bLazy = true;
    ON_SimpleArray<ON_3dPoint> T(mesh->VertexCount());
    T.SetCount(mesh->m_VertexCount());
    if ( !mapping.GetTextureCoordinates(mesh,3,3,&T[0].x,bLazy) )
      T.SetCount(0).

Returns: True if successful.

◆ HasMatchingCachedTextureCoordinates()

bool ON_TextureMapping::HasMatchingCachedTextureCoordinates ( const ON_Mesh mesh,
const ON_Xform object_xform = nullptr 
) const

Description: Quickly check to see if a mesh has cached texture coordinates set by this mapping. Parameters: mesh - [in] object_xform - [in] (optional) If this transform is not nullptr, then true will be returned only if the mapping function is the same and the tag's m_mesh_xform field is the same as mesh_xform. This parameter is typically nullptr or the value of ON_MappingRef::m_object_xform. Returns: True if the mesh contains cached texture coordinates set by this mapping.

◆ HasMatchingTextureCoordinates() [1/2]

bool ON_TextureMapping::HasMatchingTextureCoordinates ( const class ON_MappingTag tag,
const ON_Xform object_xform = nullptr 
) const

◆ HasMatchingTextureCoordinates() [2/2]

bool ON_TextureMapping::HasMatchingTextureCoordinates ( const ON_Mesh mesh,
const ON_Xform object_xform = nullptr 
) const

Description: Quickly check to see if a mesh or tag has texture coordinates set by this mapping. Parameters: mesh - [in] tag - [in] object_xform - [in] (optional) If this transform is not nullptr, then true will be returned only if the mapping function is the same and the tag's m_mesh_xform field is the same as mesh_xform. This parameter is typically nullptr or the value of ON_MappingRef::m_object_xform. Returns: True if the meshes texture coordinates were set by this mapping.

◆ IsPeriodic()

bool ON_TextureMapping::IsPeriodic ( void  ) const

◆ IsValid()

bool ON_TextureMapping::IsValid ( class ON_TextLog text_log = nullptr) const
overridevirtual

Description: Tests an object to see if its data members are correctly initialized. Parameters: text_log - [in] if the object is not valid and text_log is not nullptr, then a brief englis description of the reason the object is not valid is appened to the log. The information appended to text_log is suitable for low-level debugging purposes by programmers and is not intended to be useful as a high level user interface tool. Returns: @untitled table true object is valid false object is invalid, uninitialized, etc.

Reimplemented from ON_ModelComponent.

◆ MappingCRC()

ON__UINT32 ON_TextureMapping::MappingCRC ( ) const

◆ operator=()

ON_TextureMapping& ON_TextureMapping::operator= ( const ON_TextureMapping src)

◆ ProjectionFromUnsigned()

static ON_TextureMapping::PROJECTION ON_TextureMapping::ProjectionFromUnsigned ( unsigned int  projection_as_unsigned)
static

◆ ProjectionToString()

static const ON_wString ON_TextureMapping::ProjectionToString ( ON_TextureMapping::PROJECTION  texture_mapping_projection)
static

◆ Read()

bool ON_TextureMapping::Read ( ON_BinaryArchive binary_archive)
overridevirtual

Description: Low level archive writing tool used by ON_BinaryArchive::ReadObject(). Parameters: binary_archive - archive to read from Returns: Returns true if the read is successful. Remarks: Use ON_BinaryArchive::ReadObject() to read objects. This Read() function should read the objects definition back into its data members.

The default implementation of this virtual function returns false and does nothing.

Reimplemented from ON_Object.

◆ RequiresVertexNormals()

bool ON_TextureMapping::RequiresVertexNormals ( ) const

Determines whether the mapping, as currently set up, requires vertex normals to be present on the mesh in order to evaluate the mapping correctly.

◆ ReverseTextureCoordinate()

bool ON_TextureMapping::ReverseTextureCoordinate ( int  dir)

Description: Reverses the texture in the specified direction. Parameters: dir - [in] 0 = reverse "u", 1 = reverse "v", 2 = reverse "w". Remarks: Modies m_uvw so that the specified direction transforms the texture coordinate t to 1-t. Returns: True if input is valid.

◆ SetAdvancedBrepMappingToolFunctions()

static void ON_TextureMapping::SetAdvancedBrepMappingToolFunctions ( TEXMAP_INTERSECT_LINE_SURFACE  ,
TEXMAP_BREP_FACE_CLOSEST_POINT   
)
static

◆ SetBoxMapping()

bool ON_TextureMapping::SetBoxMapping ( const ON_Plane plane,
ON_Interval  dx,
ON_Interval  dy,
ON_Interval  dz,
bool  bIsCapped 
)

Description: Create a box projection texture mapping. Parameters: plane - [in]
The sides of the box the box are parallel to the plane's coordinate planes. The dx, dy, dz intervals determine the location of the sides. dx - [in] Determines the location of the front and back planes. The vector plane.xaxis is perpendicular to these planes and they pass through plane.PointAt(dx[0],0,0) and plane.PointAt(dx[1],0,0), respectively. dy - [in] Determines the location of the left and right planes. The vector plane.yaxis is perpendicular to these planes and they pass through plane.PointAt(0,dy[0],0) and plane.PointAt(0,dy[1],0), respectively. dz - [in] Determines the location of the top and bottom planes. The vector plane.zaxis is perpendicular to these planes and they pass through plane.PointAt(0,0,dz[0]) and plane.PointAt(0,0,dz[1]), respectively. bIsCapped - [in] If true, the box is treated as a finite capped box.
Returns: True if input is valid. Remarks: When m_texture_space = divided, the box is mapped to texture space as follows:

If the box is not capped, then each side maps to 1/4 of the texture map.

  v=1+---------+---------+---------+---------+
     | x=dx[1] | y=dy[1] | x=dx[0] | y=dy[0] |
     | Front   | Right   | Back    | Left    |
     | --y->   | <-x--   | <-y--   | --x->   |
  v=0+---------+---------+---------+---------+
    0/4 <=u<= 1/4 <=u<= 2/4 <=u<= 3/4 <=u<= 4/4

If the box is capped, then each side and cap gets 1/6 of the texture map.

  v=1+---------+---------+---------+---------+---------+---------+
     | x=dx[1] | y=dy[1] | x=dx[0] | y=dy[0] | z=dx[1] | z=dz[0] |
     | Front   | Right   | Back    | Left    | Top     |  Bottom |
     | --y->   | <-x--   | <-y--   | --x->   | --x->   | --x->   |
  v=0+---------+---------+---------+---------+---------+---------+
    0/6 <=u<= 1/6 <=u<= 2/6 <=u<= 3/6 <=u<= 4/6 <=u<= 5/6 <=u<= 6/6 

◆ SetCustomMappingPrimitive()

void ON_TextureMapping::SetCustomMappingPrimitive ( ON_Object )

◆ SetCylinderMapping()

bool ON_TextureMapping::SetCylinderMapping ( const ON_Cylinder cylinder,
bool  bIsCapped 
)

Description: Create a cylindrical projection texture mapping. Parameters: cylinder - [in]
cylinder in world space used to define a cylindrical coordinate system. The angular parameter maps (0,2pi) to texture "u" (0,1), The height parameter maps (height[0],height[1]) to texture "v" (0,1), and the radial parameter maps (0,r) to texture "w" (0,1). bIsCapped - [in] If true, the cylinder is treated as a finite capped cylinder.
Returns: True if input is valid. Remarks: When the cylinder is capped and m_texture_space = divided, the cylinder is mapped to texture space as follows: The side is mapped to 0 <= "u" <= 2/3. The bottom is mapped to 2/3 <= "u" <= 5/6. The top is mapped to 5/6 <= "u" <= 5/6. This is the same convention box mapping uses.

◆ SetOcsMapping()

bool ON_TextureMapping::SetOcsMapping ( const ON_Plane plane)

Description: Create a Ocs texture mapping. Note that OCS mappings must be placed on mapping channel ON_ObjectRenderingAttributes::OCSMappingChannelId() otherwise they will not work. Parameters: plane - [in] Returns: True if input is valid.

◆ SetPlaneMapping()

bool ON_TextureMapping::SetPlaneMapping ( const ON_Plane plane,
const ON_Interval dx,
const ON_Interval dy,
const ON_Interval dz 
)

Description: Create a planar projection texture mapping. Parameters: plane - [in] dx - [in] portion of the plane's x axis that is mapped to [0,1] (can be a decreasing interval)
dy - [in] portion of the plane's x axis that is mapped to [0,1] (can be a decreasing interval)
dz - [in] portion of the plane's x axis that is mapped to [0,1] (can be a decreasing interval)
projection_method - [in] 1: Closest point mapping. A target point P is mapped to the point on the plane that is closest to P. The target normal is ignored. 2: Target line mapping. A target point-vector pair (P, N), are mapped to the point on the plane where the line through P, parallel to N, intersects the plane. If the line is parallel to the plane, the closest point mapping is used. Example: Create a mapping that maps the world axis aligned rectangle in the world yz plane with corners at (0,3,5) and (0,7,19) to the texture coordinate unit square.

  ON_3dVector plane_xaxis(0.0,1.0,0.0);
  ON_3dVector plane_yaxis(0.0,0,0,1.0);
  ON_3dPoint plane_origin(0.0,2.0,4.0);
  ON_Plane plane(plane_origin,plane_xaxis,plane_yaxis);
  ON_Interval dx( 0.0, 7.0 - 3.0);
  ON_Interval dy( 0.0, 19.0 - 5.0);
  ON_Interval dz( 0.0, 1.0 );
  ON_TextureMapping mapping;
  mapping.CreatePlaneMapping(plane,dx,dy,dz);

Returns: True if input is valid.

◆ SetSphereMapping()

bool ON_TextureMapping::SetSphereMapping ( const ON_Sphere sphere)

Description: Create a spherical projection texture mapping. Parameters: sphere - [in]
sphere in world space used to define a spherical coordinate system. The longitude parameter maps (0,2pi) to texture "u" (0,1). The latitude parameter maps (-pi/2,+pi/2) to texture "v" (0,1). The radial parameter maps (0,r) to texture "w" (0,1). Returns: True if input is valid.

◆ SetSurfaceParameterMapping()

bool ON_TextureMapping::SetSurfaceParameterMapping ( void  )

Description: Create a mapping that will convert surface parameters into normalized (0,1)x(0,1) texture coordinates.

◆ SharedCustomMappingPrimitive()

const std::shared_ptr<const ON_Object>& ON_TextureMapping::SharedCustomMappingPrimitive ( void  ) const

◆ SizeOf()

unsigned int ON_TextureMapping::SizeOf ( ) const
overridevirtual

Returns: An estimate of the amount of memory the class uses in bytes.

Reimplemented from ON_ModelComponent.

◆ SpaceToString()

static const ON_wString ON_TextureMapping::SpaceToString ( ON_TextureMapping::TEXTURE_SPACE  texture_mapping_space)
static

◆ SwapTextureCoordinate()

bool ON_TextureMapping::SwapTextureCoordinate ( int  i,
int  j 
)

Description: Swaps the specified texture coordinates. Parameters: i - [in] j - [in] Remarks: Modifies m_uvw so that the specified texture coordinates are swapped. Returns: True if input is valid.

◆ TextureSpaceFromUnsigned()

static ON_TextureMapping::TEXTURE_SPACE ON_TextureMapping::TextureSpaceFromUnsigned ( unsigned int  texture_space_as_unsigned)
static

◆ TileTextureCoordinate()

bool ON_TextureMapping::TileTextureCoordinate ( int  dir,
double  count,
double  offset 
)

Description: Tiles the specified texture coordinates. Parameters: dir - [in] 0 = "u", 1 = "v", 2 = "w". count - [in] number of tiles offset - [in] offset of the tile Remarks: Modies m_uvw so that the specified texture coordinate is tiled. Returns: True if input is valid.

◆ TypeFromUnsigned()

static ON_TextureMapping::TYPE ON_TextureMapping::TypeFromUnsigned ( unsigned int  type_as_unsigned)
static

◆ TypeToString()

static const ON_wString ON_TextureMapping::TypeToString ( ON_TextureMapping::TYPE  texture_mapping_type)
static

◆ Write()

bool ON_TextureMapping::Write ( ON_BinaryArchive binary_archive) const
overridevirtual

Description: Low level archive writing tool used by ON_BinaryArchive::WriteObject(). Parameters: binary_archive - archive to write to Returns: Returns true if the write is successful. Remarks: Use ON_BinaryArchive::WriteObject() to write objects. This Write() function should just write the specific definition of this object. It should not write and any chunk typecode or length information.

The default implementation of this virtual function returns false and does nothing.

Reimplemented from ON_Object.

Member Data Documentation

◆ m_bCapped

bool ON_TextureMapping::m_bCapped = false

The m_bCapped applies to planar, cylinder and box mappings. If m_bCapped is false, the cylinder or box is "infinite", if m_bCapped is true, they are finite. In planar mappings, m_bCapped=false means "the Z texture coordinate will always be 0.0" this is now the default behaviour in Rhino 5.0 - it's what users expect apparently.

◆ m_Nxyz

ON_Xform ON_TextureMapping::m_Nxyz = ON_Xform::IdentityTransformation

◆ m_projection

◆ m_Pxyz

ON_Xform ON_TextureMapping::m_Pxyz = ON_Xform::IdentityTransformation

For primitive based mappings, these transformations are used to map the world coordinate (x,y,z) point P and surface normal N before it is projected to the normalized mapping primitive. The surface normal transformation, m_Nxyz, is always calculated from m_Pxyz. It is a runtime setting that is not saved in 3dm files. If m_type is srfp_mapping, then m_Pxyz and m_Nxyz are ignored.

◆ m_texture_space

◆ m_type

◆ m_uvw

ON_Xform ON_TextureMapping::m_uvw = ON_Xform::IdentityTransformation

Transform applied to mapping coordinate (u,v,w) to convert it into a texture coordinate.

◆ SurfaceParameterTextureMapping

const ON_TextureMapping ON_TextureMapping::SurfaceParameterTextureMapping
static

m_type = ON_TextureMapping::srfp_mapping m_id = ON_TextureMapping::SurfaceParameterTextureMappingId

◆ SurfaceParameterTextureMappingId

const ON_UUID ON_TextureMapping::SurfaceParameterTextureMappingId
static

{B988A6C2-61A6-45a7-AAEE-9AED7EF4E316}

◆ Unset

const ON_TextureMapping ON_TextureMapping::Unset
static

m_type = ON_TextureMapping::TYPE::no_mapping m_id = nil id