FormIt C++ API  v23.0.0 (2023.0.0)
utils.h File Reference
#include "WSM/WSMApi.h"
#include "interfaces.h"
#include "pickray.h"
#include <array>
#include <map>
#include <set>
#include <vector>

Classes

class  WSM::Utils::MaterialData
 Data that stores all the material properties to be collected by GetAllRenderingInformation. More...
 
class  WSM::Utils::MeshData
 Data that can be used to draw a single mesh. More...
 
class  WSM::Utils::MeshesAndTransformsData
 Data that packages meshes and transforms together. More...
 
class  WSM::Utils::RayFireFilterHidden
 Implemetation of IRayFireFilterAndAbort that filters hidden objects. More...
 
class  WSM::Utils::RayFireFilterHiddenOrSectioned
 Implemetation of IRayFireFilterAndAbort that filters hidden and/or sectioned objects. More...
 
class  WSM::Utils::RayFireFilterHiddenOrNonPickable
 Implemetation of IRayFireFilterAndAbort that filters hidden and and non pickable objects Note that this implementation does not use a pick ray, as it is used by area seletion where no pick ray exists. More...
 

Namespaces

 WSM
 forward declaration
 
 WSM::Utils
 

Macros

#define WSMID(id)   id.m_nHistory, id.m_nObject
 < namespace WSM More...
 

Typedefs

using WSM::Utils::ObjectIDsAndPickPoints = 1::vector< 1::pair< size_t, WSM::Point3d >>
 The selection related functions below that do not take a history ID obtain an IToolAppHelper from the InferenceEngine and use its interface functions to determine the history and in-context editing settings to use. More...
 
using WSM::Utils::ObjectsAndPickPoints = 1::vector< 1::pair< GroupInstancePath, WSM::Point3d >>
 

Enumerations

enum  WSM::Utils::CoordSystem { WSM::Utils::CoordSystem::HCS = 0, WSM::Utils::CoordSystem::LCS = 1, WSM::Utils::CoordSystem::WHCS = 2, WSM::Utils::CoordSystem::WLCS = 3 }
 
enum  WSM::Utils::PickRayPlaneIntersection { WSM::Utils::PickRayPlaneIntersection::WorkPlane = 0, WSM::Utils::PickRayPlaneIntersection::GroundPlane = 1, WSM::Utils::PickRayPlaneIntersection::CameraPlane = 2 }
 enum for return value of GetPickrayIntersectionWithWorkPlane More...
 

Functions

WSM_UTILS_EXPORT void WSM::Utils::RegisterAppHelper (1::unique_ptr< IAppHelper > pAppHelper)
 Register a concrete instance of the IAppHelper interface. More...
 
WSM_UTILS_EXPORT void WSM::Utils::UnregisterAppHelper ()
 Unregister the previously registered IAppHelper instance. More...
 
WSM_UTILS_EXPORT IAppHelper * WSM::Utils::GetAppHelper ()
 Get the currently registered IAppHelper object. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjectType (size_t nHistoryID, size_t id, nObjectType type)
 IsObjectType takes a WSM 'id' and returns true if the object (id) is of the given 'type'. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjectType (size_t nHistoryID, size_t id, 1::vector< nObjectType > const &aTypes)
 IsObjectType takes a WSM 'id' and returns true if the object (id) is of any of the given 'types'. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsLayerHidden (size_t nHistoryID, size_t id)
 Takes a WSM 'id' and returns true if the layer is hidden. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsLayerNotPickable (size_t nHistoryID, size_t id)
 Takes a WSM 'id' and returns true if the layer is not pickable. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjectNotPickable (size_t nHistoryID, size_t id)
 Takes a WSM 'id' and returns true if the object is on a non pickable layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjectNotPickableByPath (GroupInstancePath const &groupInstancePath)
 Takes a WSM 'id' and returns true if the object is on a non pickable layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjectHidden (size_t nHistoryID, size_t id)
 Takes a WSM 'id' and returns true if the object is on a hidden layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjectHiddenByPath (GroupInstancePath const &groupInstancePath)
 Takes a WSM path and returns true if the object is on a hidden layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::ObjectCanBeHidden (size_t nHistoryID, size_t nObjectID)
 Can this object be hidden directly? This means that it's non-owned or an instance. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::ObjectCanBeNotPickable (size_t nHistoryID, size_t nObjectID)
 Can this object be not pickable directly? This means that it's non-owned or an instance. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsTopLevelObjectHidden (size_t nHistoryID, size_t id)
 Takes a WSM 'id' and returns true if the object's top level owner is on a hidden layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsTopLevelObjectNotPickable (size_t nHistoryID, size_t id)
 Takes a WSM 'id' and returns true if the object's top level owner is on a non pickable layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsTopLevelObjectHiddenByPath (GroupInstancePath const &groupInstancePath)
 Takes a WSM path and returns true if the top level owner of any object in the path is on a hidden layer. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsTopLevelObjectNotPickableByPath (GroupInstancePath const &groupInstancePath)
 Takes a WSM path and returns true if the top level owner of the final object in the path is on a not pickable layer. More...
 
WSM_UTILS_EXPORT Line3d WSM::Utils::GetEdgeLine (size_t nHistoryID, size_t edge)
 GetEdgeLine returns the line the 'edge' lies on. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::GetCoedgePoints (size_t nHistoryID, size_t coedgeID, WSM::Point3d &begin, WSM::Point3d &end)
 GetCoedgePoints returns the begin/end points of coedge. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::GetFacePoints (const GroupInstancePath &facePath, 1::vector< WSM::Point3d > &aPoints)
 Get all points of a face. More...
 
WSM_UTILS_EXPORT size_t WSM::Utils::GetEdgeIDFromCoedge (size_t nHistoryID, size_t coedgeID)
 Get edge Id from the given coedge. More...
 
WSM_UTILS_EXPORT size_t WSM::Utils::GetFaceIDFromCoedge (size_t nHistoryID, size_t coedgeID)
 Get face id from the given coedge. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::ComputeFaceNormal (size_t historyID, size_t faceID, WSM::UnitVector3d &faceNormal)
 ComputeFaceNormal returns the face normal of the given face. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::ComputeFaceCentroid (size_t historyID, size_t faceID, WSM::Point3d &centroid)
 ComputeFaceCentroid returns the centroid (average of all points) of the given face. More...
 
WSM_UTILS_EXPORT double WSM::Utils::AngleFullCircleInRadians (const WSM::UnitVector3d &normal, const WSM::Vector3d &vecA, const WSM::Vector3d &vecB, bool returnPositive=false)
 Calculates the radian angle counterclockwise from vector A to B on the plane with normal 'normal' If returnPositive, returns [0, 2PI) If not returnPositive, returns (-PI,PI]. More...
 
WSM_UTILS_EXPORT WSM::Result WSM::Utils::PickObjectsWithRay (PickRay const &pickRay, const ObjectTypeFilter &filter, bool bAllowAdjustRayRadius, bool bIgnoreInContext, ObjectIDsAndPickPoints &aObjectsAndPickPoints, bool bCullAgainstSectionPlanes=false)
 PickObjectsWithRay returns all objects that can be picked via the given pick ray, which is all objects up to the first face, as the face obscures everything behind it from picking. More...
 
WSM_UTILS_EXPORT WSM::Result WSM::Utils::PickObjectsWithRay (PickRay pickRay, const ObjectTypeFilter &filter, bool bAllowAdjustRayRadius, bool bAllowGroupGeometry, bool bRestrictGroupGeometryToEditingPath, bool bIgnoreInContext, ObjectsAndPickPoints &aObjectsAndPickPoints, bool bCullAgainstSectionPlanes=false)
 PickObjectsWithRay returns all objects that can be picked via the given pick ray, which is all objects up to the first face, as the face obscures everything behind it from picking. More...
 
WSM_UTILS_EXPORT void WSM::Utils::PickObjectsWithFilter (const PickRay &pickray, const ObjectTypeFilter &filter, SelectionLevel currentSelectionLevel, WSM::GroupInstancePath &firstSelectedObject, 1::vector< WSM::GroupInstancePath > &allSelectedObjects, ObjectsAndPickPoints &aObjectsAndPickPoints, bool bCullAgainstSectionPlanes=false)
 Common picking code for non-window. More...
 
WSM_UTILS_EXPORT void WSM::Utils::RemoveHiddenObjects (size_t nHistoryID, 1::vector< size_t > const &aObjectIDs, 1::vector< WSM::GroupInstancePath > const &aObjectsInGroupsVec, 1::vector< 1::pair< double, ptrdiff_t >> &paramIndexVec, const PickRay &pickray, bool bCullAgainstSectionPlanes=false)
 Removes objects on hidden layers from the data returned by the selection functions. More...
 
WSM_UTILS_EXPORT void WSM::Utils::RemoveNonPickableObjects (size_t nHistoryID, 1::vector< size_t > const &aObjectIDs, 1::vector< WSM::GroupInstancePath > const &aObjectsInGroupsVec, 1::vector< 1::pair< double, ptrdiff_t >> &paramIndexVec)
 Removes objects on non pickabke layers from the data returned by the selection functions. More...
 
WSM_UTILS_EXPORT void WSM::Utils::RemoveNonPickableObjects (size_t nHistoryID, 1::vector< size_t > &aObjectIDs, 1::vector< WSM::GroupInstancePath > &aObjectsInGroupsVec, 1::vector< WSM::Transf3d > &aGroupAggregateTransf3dVec)
 Removes objects on non pickable layers from the data returned by the selection functions. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::SetToOwnerBody (WSM::GroupInstancePath &path)
 Returns true if the path was changed to the object's owner body. More...
 
WSM_UTILS_EXPORT void WSM::Utils::SelectionToGroupInstancePathArray (1::vector< size_t > const &aInput, 1::vector< GroupInstancePath > &aOutput)
 Takes a vector of objects ID values, and populates the GroupInstancePath vector with that data and the current in-context editing settings from IToolAppHelper. More...
 
WSM_UTILS_EXPORT void WSM::Utils::SelectionToGroupInstancePathArray (1::vector< ObjectHistoryID > const &aInput, 1::vector< GroupInstancePath > &aOutput)
 Takes a vector of objects ID values, and populates the GroupInstancePath vector with that data and the current in-context editing settings from IToolAppHelper. More...
 
WSM_UTILS_EXPORT GroupInstancePath WSM::Utils::SelectionToGroupInstancePath (size_t aObjectID)
 Takes an object ID value, and return a GroupInstancePath with that data and the current in-context editing settings from IToolAppHelper. More...
 
WSM_UTILS_EXPORT void WSM::Utils::AppendSelectionToGroupInstancePathArray (1::vector< size_t > const &aInput, 1::vector< GroupInstancePath > &aOutput)
 Takes a vector of objects ID values, and populates the GroupInstancePath vector with that data and the current in-context editing settings from IToolAppHelper. More...
 
WSM_UTILS_EXPORT void WSM::Utils::AppendSelectionToGroupInstancePathArray (1::vector< ObjectHistoryID > const &aInput, 1::vector< GroupInstancePath > &aOutput)
 Takes a vector of objects ID values, and populates the GroupInstancePath vector with that data and the current in-context editing settings from IToolAppHelper. More...
 
WSM_UTILS_EXPORT void WSM::Utils::SelectionFromGroupInstancePathArray (1::vector< size_t > &aOutput, 1::vector< GroupInstancePath > const &aInput)
 Takes a vector of GroupInstancePath objects, and populates the vector with the IDs of those compatible with the in-context editing settings from IToolAppHelper. More...
 
WSM_UTILS_EXPORT size_t WSM::Utils::PickGeometry (const PickRay &originalPickray, const ObjectTypeFilter &filter, bool bAllowAdjustRayRadius=true)
 PickGeometry is exactly the same as PickObjectsWithRay except that it returns the first result instead of an array of objects and pick points. More...
 
WSM_UTILS_EXPORT size_t WSM::Utils::PickBody (const PickRay &pickRay)
 PickBody returns the id of the body picked by pickRay. More...
 
WSM_UTILS_EXPORT size_t WSM::Utils::TestPickImages (size_t nHistoryID, const 1::vector< size_t > &imageIds, const PickRay &pickRay, Point3d &pickPointOnImage)
 Try picking the given Images with a pick ray If hits an image, returns the id of the picked image and the 3d point that was picked. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::RayFireWithObjects (const 1::set< size_t > &objectIds, const PickRay &ray, WSM::Point3d &pickPointOnObject)
 Core ray fire function that tests ray intersection against a given set of objects. More...
 
WSM_UTILS_EXPORT::vector< size_t > WSM::Utils::GetAllNonOwnedGeometricObjects (size_t nHistoryID)
 Returns all non owned Objects of geometric type (Body, Face or Edge) in the given History. More...
 
WSM_UTILS_EXPORT SurfaceType WSM::Utils::GetFaceSurfaceType (size_t nHistoryID, size_t edgeId, size_t *pAttribID=nullptr)
 Returns Face surface type in surfaceType and also returns the surface attribute ID if attribID != nullptr. More...
 
WSM_UTILS_EXPORT CurveType WSM::Utils::GetEdgeCurveType (size_t nHistoryID, size_t edgeId, size_t *pAttribID=nullptr)
 Returns Edge curve type in curveType and also returns the curve attribute ID if attribID != nullptr. More...
 
WSM_UTILS_EXPORT void WSM::Utils::GetPointsOnEdgeCurve (size_t nHistoryID, size_t edgeId, const 1::vector< double > &params, 1::vector< WSM::Point3d > &points)
 Get points on the curve of an edge. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsSilhouetteEdge (size_t nHistoryID, size_t edgeId, const Point3d &cameraPos, const Vector3d &cameraDir, bool perspectiveView)
 Determines if given edge is silhouette. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsFreeEdge (size_t nHistoryID, size_t edgeId)
 Determines if given edge is an edge that is not between two faces ("free"). More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsBackFace (const WSM::GroupInstancePath &face, const Point3d &cameraPos, const Vector3d &cameraDir, bool perspectiveView)
 Check whether the given face is pointing away from the camera i.e. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsSmooth (size_t nHistoryID, size_t objectID)
 Returns whether an edge or vertex is marked as smooth. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::HasSmoothEdge (size_t nHistoryID, size_t objectID)
 Returns whether the provided object has any smooth edges. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::ExpandSelection (size_t nHistoryID, size_t objectID, 1::vector< size_t > &expandedSelection, SelectionLevel selectionlevel, ObjectTypeFilter const *pFilter, bool bCanExpandInstances, WSM::Utils::PickRay const *pPickRay=nullptr)
 ExpandSelection expands the selection starting with objectID. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::ExpandSelection (WSM::GroupInstancePath const &objectID, 1::vector< WSM::GroupInstancePath > &expandedSelection, SelectionLevel selectionlevel, ObjectTypeFilter const *pFilter, bool bCanExpandInstances, WSM::Utils::PickRay const *pPickRay=nullptr)
 
WSM_UTILS_EXPORT bool WSM::Utils::IsVertexOnCurve (size_t historyID, size_t vertexID)
 Returns whether a vertex is on an arc or hermite spline curve. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::GetVertexCurveAttributes (size_t historyID, size_t vertexID, 1::vector< 1::pair< size_t, size_t >> &aAttributeIDs)
 GetVertexCurveAttributes looks at all the Edges hanging off the vertices and returns a vector of pairs (EdgeID, AttributeID) (aAttributeIDs) that have a curve attribute. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsVertexEditable (size_t historyID, size_t vertexID)
 Returns whether a vertex is editable. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsSelectAllConnected (size_t nHistoryID, const 1::vector< size_t > &selectedObjectIDs)
 Checks whether all the objects in the given vector are the result of select connected action (i.e. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsSelectAllConnected (const 1::vector< WSM::GroupInstancePath > &selectedObjectPaths)
 Checks whether all the objects in the given vector are the result of select connected action (i.e. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::MatchesSelectionType (const 1::vector< WSM::GroupInstancePath > &selectedObjectIDs, const 1::vector< WSM::GroupInstancePath > &aNewSelectedObjects, bool bSelectAll)
 Checks whether all the objects in the given vector are compatible with the selection action (i.e. More...
 
WSM_UTILS_EXPORT void WSM::Utils::DeleteObjectsIncludeSmoothAttachments (size_t nHistoryID, const 1::vector< size_t > &toDelete)
 This is the delete method for a formIt selection set. More...
 
WSM_UTILS_EXPORT void WSM::Utils::ConvertToTopLevel (size_t nHistoryID, size_t &nObjectID, bool bAllowInstances, bool bAllowOwnedFaces)
 Converts a single entity to its top level parent, except does not convert instances/faces to their owning groups/bodies if bAllowInstances/bAllowOwnedFaces is true. More...
 
WSM_UTILS_EXPORT void WSM::Utils::ConvertToTopLevel (WSM::GroupInstancePath &path, bool bAllowInstances, bool bAllowOwnedFaces)
 Converts a single entity to its top level parent, except does not convert instances/faces to their owning groups/bodies if bAllowInstances/bAllowOwnedFaces is true. More...
 
WSM_UTILS_EXPORT void WSM::Utils::ConvertToTopLevel (size_t nHistoryID, 1::vector< size_t > &aIDs, bool bAllowInstances, bool bAllowOwnedFaces)
 Converts a vector of entities to their top level parents and then removes duplicates. More...
 
WSM_UTILS_EXPORT void WSM::Utils::ConvertToTopLevel (1::vector< WSM::GroupInstancePath > &aPaths, bool bAllowInstances, bool bAllowOwnedFaces)
 Converts a vector of entities to their top level parents and then removes duplicates. More...
 
WSM_UTILS_EXPORT void WSM::Utils::ConvertToFaces (1::vector< WSM::GroupInstancePath > &aPaths)
 Converts a vector of entities to all faces. More...
 
WSM_UTILS_EXPORT void WSM::Utils::MakePathsHaveUniqueTopology (1::set< WSM::GroupInstancePath > &aPaths)
 Removes topological duplicates making each object unique and does not contain any child topology in the set. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsOnCurveJunction (size_t nHistoryID, size_t nVertexID, bool bInferencing=true)
 Check to see if we have a junction vertex where the number of non smooth edges is equal to two for inferencing or greater than 2 for all other cases. More...
 
WSM_UTILS_EXPORT void WSM::Utils::GetGroupInstanceNonOwnedGeometricObjects (const GroupInstancePath &instance, 1::vector< GroupInstancePath > &nonOwnedObjects)
 For a group instance, get all top level objects (edges, faces, bodies) in the referenced history. More...
 
WSM_UTILS_EXPORT void WSM::Utils::GetMemoryInfo (size_t nHistoryID, 1::vector< size_t > &aRefdHistoryIDs, size_t &nFullSize, size_t &nCollapsedSize)
 Get the size of the memory occupied by all Histories, including referenced ones. More...
 
WSM_UTILS_EXPORT::vector< WSM::Point3dWSM::Utils::GetImageCorners (size_t nHistoryId, size_t nImageId)
 Get the four corner points of an image object. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::MultipleDeltasInHistoryOrSubHistories (size_t nHistoryID)
 Returns true if nHistoryID or any of the referenced sub-Histories from nHistoryID have multiple Deltas. More...
 
WSM_UTILS_EXPORT size_t WSM::Utils::GetReferenceHistoryID (1::map< 1::string, size_t > &mapFileNameToID, const 1::string &filename)
 if the history reference ID is bad or it has been changed ,return an invalid reference ID, telling the contentlibarywidget to load a new file More...
 
WSM_UTILS_EXPORT WSM::Interval3d WSM::Utils::GetAxisAlignedBoundingBox (const 1::vector< WSM::GroupInstancePath > &aPaths, WSM::Utils::CoordSystem CS)
 Calculates the bounding box of the given objects in the given WSM::Utils::CoordSystem. More...
 
WSM_UTILS_EXPORT WSM::Point3d WSM::Utils::SnapScalePoint (const WSM::Point3d &inPoint, const WSM::Line3d &scaleAxis)
 Adjust the input point so that its distance along the given line represents a scale factor that is a whole number (in percent). More...
 
WSM_UTILS_EXPORT bool WSM::Utils::SetOrCreateStringAttributeForObject (size_t nHistoryID, size_t nObjectID, const 1::string &key, const 1::string &value, WSM::nCopyBehavior nCB=WSM::nCopyBehavior::nShareOrCopy, bool bIsSharedOnSplit=true)
 Sets the value of a string attribute of a given object, if that object has such an attribute with the given key. More...
 
WSM_UTILS_EXPORT double WSM::Utils::DegreesToRadians (double degrees)
 Convert degrees to radians. More...
 
WSM_UTILS_EXPORT double WSM::Utils::RadiansToDegrees (double radians)
 Convert radians to degrees. More...
 
WSM_UTILS_EXPORT PickRayPlaneIntersection WSM::Utils::GetPickrayIntersectionWithWorkPlane (const WSM::Utils::PickRay &pickRay, WSM::Point3d &intersectPt, WSM::Plane *intersectionPlane=nullptr)
 Get the intersection of a pickray with the current work plane or ground plane It also creates some default point if the intersection with the plane fails to be in front of the pick ray origin (i.e. More...
 
WSM_UTILS_EXPORT void WSM::Utils::ComputeUVsForMeshData (const MeshData &md, double dUScale, double dVScale, 1::vector< float > &aUVs)
 Helper function that computes mesh UV data. More...
 
WSM_UTILS_EXPORT void WSM::Utils::GetAllRenderingInformation (size_t nHistID, 1::vector< MeshesAndTransformsData > &aMeshesAndTransformsDataVec, 1::vector< MaterialData > &aMaterialVec)
 GetAllRenderingInformation() function. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsObjecHiddenFunc (const WSM::GroupInstancePath &path, const WSM::Utils::PickRay &pickray, double dParam)
 IsObjecHiddenFunc() function. More...
 
WSM_UTILS_EXPORT bool WSM::Utils::IsOwnerOf (const WSM::GroupInstancePath &parent, const WSM::GroupInstancePath &child)
 Checks whether parent is an owner of child. More...
 

Macro Definition Documentation

#define WSMID (   id)    id.m_nHistory, id.m_nObject

< namespace WSM

Macro that takes a WSM::ObjectHistoryID and makes it easy to call a WSM API.