Files
Extern/Optalog/Include/cns.h
T
SaraP f6b8c50409 Extern :
- Optalog aggiornamento a versione 11.0.
2025-09-12 10:08:10 +02:00

1604 lines
72 KiB
C

/**
* CNS is a true-shape nesting library that optimizes material usage.
*
* This header file is confidential and must not be distributed without
* agreement of the authors.
*
* Authors: Nicolas Leignel and Renaud Lepere
* Copyright: 2014-2025
*/
#ifndef CNS_H
#define CNS_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CNS_WIN_DLL
#define CNS_EXPORT __declspec(dll_export)
#else
#define CNS_EXPORT
#endif
#ifdef _WIN32
#define CNS_API __stdcall
#else
#define CNS_API
#endif
#ifdef __linux__
#include "cns_linux.h"
#endif
#ifdef __APPLE__
#include "cns_linux.h"
#endif
typedef struct CNS_LaunchingOrder * CNS_LaunchingOrderPtr;
typedef struct CNS_Part * CNS_PartPtr;
typedef struct CNS_Sheet * CNS_SheetPtr;
typedef struct CNS_Computation * CNS_ComputationPtr;
typedef struct CNS_Solution * CNS_SolutionPtr;
typedef struct CNS_Nesting * CNS_NestingPtr;
typedef enum {
CNS_Ok = 0,
CNS_BadPartGeometry = 1,
CNS_TooComplexProblem = 2,
CNS_CantContactServer = 3,
CNS_CantGetSolution = 4,
CNS_PendingComputation = 9,
CNS_IntermediateResult = 10,
CNS_NotAvailable = 11,
CNS_CancelledComputation = 12,
CNS_TerminatedComputation = 13,
CNS_BadSheetGeometry = 14,
CNS_BadSheetPrices = 15,
CNS_BadCommonCutGaps = 16,
CNS_PhysicalKeyNotFound = 17,
CNS_IncompatibleFeatures = 18
} CNS_ComputationStatus;
typedef enum {
CNS_MinimizeXThenY = 0, // default
CNS_MinimizeArea = 1,
CNS_MinimizeYThenX = 2,
CNS_IntelligentMinimizeX = 3,
CNS_NoReusableOffcut = 4, // used for filling with optional parts/quantities
CNS_IntelligentMinimizeY = 5,
} CNS_Objective;
typedef enum {
CNS_BottomLeft = 0, // default,
CNS_TopLeft = 1,
CNS_BottomRight = 2,
CNS_TopRight = 3
} CNS_Origin;
typedef enum
{
CNS_Horizontal = 0, // default
CNS_Vertical = 1
} CNS_GrainDirection;
typedef enum
{
CNS_NoPreference = 0,
CNS_LittlePreference = 1,
CNS_NormalPreference = 2,
CNS_StrongPreference = 3,
CNS_AggressivePreference = 4
} CNS_MultiplicityPreference;
typedef enum
{
CNS_FreeMixOnPart = 0,
CNS_SingleOrientationAndRot180MixOnPart = 1,
CNS_SingleOrientationMixOnPart = 2
} CNS_OrientationMixOnPart;
/**
* Basic structure used for describing part inputs. They can be composed of segments and arcs
* called elements or simple polygons.
*/
typedef struct
{
double x;
double y;
double left_deflection;
} CNS_Element;
typedef struct
{
double x;
double y;
} CNS_Point;
/* =====================================================================================
*
* Creating launching order and describing inputs : parts, sheets...
*
* ===================================================================================== */
/**
* Creates a new launching order. A launching order describes all the parts to nest, their
* quantities and possible sheets.
*/
CNS_EXPORT CNS_LaunchingOrderPtr CNS_API CNS_NewLaunchingOrder();
/**
* When finished, the launching order must be destroyed to free memory
*/
CNS_EXPORT void CNS_API CNS_DeleteLaunchingOrder(CNS_LaunchingOrderPtr);
/**
* Add a part in the given launching order.
*
* The parameter @param quantity describes the number of parts to nest. The quantity can be 0
* for filler parts in this case you must call CNS_AddOptionalQuantityToPart with a non null
* optional quantity.
*
* The part has a simple external boundary described as an array of @param number_of_elements
* elements. An element's coordinates, x and y, represents the end of the current element, its
* origin is the end of the previous one. For the first element its origin is the x and y
* coordinate of the last one.
*
* If the left_deflection is 0.0, the element is a segment, otherwise the element is an arc. It
* represents the signed distance from the middle of the chord to the middle of the arc, so
* left_deflection is positive if the arc goes clockwise.
*
* The material can be either on the left side or on the right side of the contour (it can be
* clockwise or anticlockwise oriented).
*
* The contour can be self-intersecting, in this case the part is equivalent to its outer
* boundary.
*
* Note 1: do not delete/free the part, it will be freed when calling CNS_DeleteLaunchingOrder.
*
*/
CNS_EXPORT CNS_PartPtr CNS_API CNS_AddPart(CNS_LaunchingOrderPtr order,
unsigned quantity,
unsigned number_of_elements,
const CNS_Element * elements);
/**
* Add a hole to the given part.
*
* The hole has @param number_of_elements elements and is described by a simple contour defined
* by the the array @param elements.
*
* See: CNS_AddPart for description of the contour given the elements.
*/
CNS_EXPORT void CNS_API CNS_AddHoleToPart(CNS_PartPtr part,
unsigned number_of_elements,
const CNS_Element * elements);
/**
* Add another external boundary to the given part. Useful for pre-grouped parts.
*
* The boundary is described by @param number_of_elements elements and is described by the array
* @param elements.
*
* See: CNS_AddPart for description of the contour given the elements.
*/
CNS_EXPORT void CNS_API CNS_AddExternalBoundaryToPart(CNS_PartPtr part,
unsigned number_of_elements,
const CNS_Element * elements);
/**
* Add an open cutting path to the given part.
*
* An open cutting path can be used to represent a lead-in, a lead-out or a free cut. No other
* part will be nested on this cutting path.
*
* The path starts at the point @param origin and is composed of elements described by the
* parameters @param number_of_elements and the array @param elements. The thickness of the path
* must not be null.
*
* Note/Limitation: the current version retains a small gap of half the part gap around the open
* cutting path.
*/
CNS_EXPORT void CNS_API
CNS_AddOpenCuttingPathToPart(CNS_PartPtr part,
CNS_Point origin,
unsigned number_of_elements,
const CNS_Element * elements,
double thickness);
/**
* Add an optional quantity to the given part.
*
* Optional quantities are used to fill nestings in order to reduce waste and offcuts.
*
* By default, optional parts and optional quantities will be used to fill all the intermediate
* sheets and the last sheet up to its limit (maximum X or Y depending upon the set
* objective). This limit can be bypassed by the function CNS_SetFillLastNestingStrategy.
*/
CNS_EXPORT void CNS_API
CNS_AddOptionalQuantityToPart(CNS_PartPtr part, unsigned optional_quantity);
/**
* Set an extra gap on the given part.
*
* Some parts may require additional spacing in order to protect them. This is an additional gap
* above the normal gap specified by the function CNS_SetInterpartGap.
*
* Note: two adjacent nested parts with extra gaps will have an extra gap between them
* corresponding to the sum of their extra gaps.
*
* Note: If an extra gap is added a part, the extra gap will also apply on the sheet border.
*/
CNS_EXPORT void CNS_API
CNS_SetExtraGapOnPart(CNS_PartPtr part, double extra_gap);
/**
* Set the filling mode for optional/filler parts in the last nesting.
*
* If @param fill_after_frontline is true then the optional parts will be nested even this leads
* to increase the last sheet limit (maximum X or Y depending upon objective), otherwise
* optional parts will not go past the end of the nest (default).
*/
CNS_EXPORT void CNS_API
CNS_SetFillLastNestingStrategy(CNS_LaunchingOrderPtr order, int fill_after_frontline);
/**
* Add a polygon part in the given launching order.
*
* The parameter @param quantity describes the number of parts to nest.
*
* The part has a simple external boundary described as a polygon of @param number_of_points
* points whose coordinates are described by the array @param points.
*
* The material can be either on the left side or on the right side of the polygon (it does not
* matter if the polygon is defined clockwise or anticlockwise oriented). There is no need to
* repeat the first point of polygon (but you can do it). The polygon can be self-intersecting,
* in this case this is equivalent to the outer boundary of the self-intersecting polygon.
*
* Note: do not delete/free the part, it will be freed when calling CNS_DeleteLaunchingOrder.
*/
CNS_EXPORT CNS_PartPtr CNS_API CNS_AddPolygonPart(CNS_LaunchingOrderPtr order,
unsigned quantity,
unsigned number_of_points,
const CNS_Point * points);
/**
* Add a polygonal hole to the given part.
*
* The hole have @param number_of_points points and is described by a simple polygon whose
* coordinates are defined by the the array @param points.
*/
CNS_EXPORT void CNS_API CNS_AddPolygonHoleToPart(CNS_PartPtr part,
unsigned number_of_points,
const CNS_Point * points);
/**
* Add another external polygonal boundary to the given part.
*
* The boundary is described by @param number_of_points points and is described by a simple
* polygon whose coordinates are defined by the the array @param points.
*/
CNS_EXPORT void CNS_API CNS_AddExternalPolygonBoundaryToPart(CNS_PartPtr part,
unsigned number_of_points,
const CNS_Point * points);
/**
* Shortcuts for creating rectangular and circular parts and holes.
*/
CNS_EXPORT CNS_PartPtr CNS_API CNS_AddRectangularPart(CNS_LaunchingOrderPtr order,
unsigned quantity,
double x1, double y1,
double x2, double y2);
CNS_EXPORT CNS_PartPtr CNS_API CNS_AddCircularPart(CNS_LaunchingOrderPtr order,
unsigned quantity,
double x, double y, double radius);
CNS_EXPORT void CNS_API CNS_AddCircularHoleToPart(CNS_PartPtr part,
double x, double y, double radius);
CNS_EXPORT void CNS_API CNS_AddRectangularHoleToPart(CNS_PartPtr part,
double x1, double y1,
double x2, double y2);
CNS_EXPORT void CNS_API CNS_AddCircularExternalBoundaryToPart(CNS_PartPtr part,
double x, double y, double radius);
CNS_EXPORT void CNS_API CNS_AddRectangularExternalBoundaryToPart(CNS_PartPtr part,
double x1, double y1,
double x2, double y2);
/**
* Specify authorizations on the given part.
*
* @param flip_allowed boolean means that we can flip the part about the x axis.
* @param rotation boolean means that we can rotate the part.
* @param rotation_step means the rotation steps in which we can rotate the part.
* Set value of 0.0 to indicate free rotation (default). Value is in degrees.
*
* For example if rotation_step is 90, we can nest it in its 0, 90, 180, or 270 degree
* orientations.
*
* Caution: do not use small values for rotation_step if part can be freely rotated, this can
* degrade the algorithm performance. Use a value of 0.0 for free rotation instead.
*/
CNS_EXPORT void CNS_API CNS_SetPartAuthorizations(CNS_PartPtr part,
int flip_allowed,
int rotation,
double rotation_step);
/**
* Set specific authorizations for the given part.
*
* Authorizations are a set of (flip, min_angle_in_degree, double max_angle_in_degree) and this
* function must be be called several times to describe all those authorizations.
*
* Example:
* CNS_AddPartSpecificAuthorizations(part, 0, 0.0, 0.0);
* CNS_AddPartSpecificAuthorizations(part, 1, 180.0, 180.0);
* means that the part can be either nested as it, or fliped and rotated at 180.0.
*
* Note: if max_angle_in_degree < min_angle_in_degree than 0.0 is included.
* for example if min_angle_in_degree = 350 and max_angle_in_degree = 10
* then the part can only be tilted by 10deg around the normal orientation.
* Note: calling this function override normal authorizations.
*/
CNS_EXPORT void CNS_API
CNS_AddPartSpecificAuthorizations(CNS_PartPtr part, int flip,
double min_angle_in_degree, double max_angle_in_degree);
/**
* Set the priority of the given part.
*
* If different part priorities are given, the most urgent ones (the ones with the smaller
* value), will be nested first.
*
* Note 1: Parts with low priority will be nested if no higher priority parts can be nested,
* this is useful to fill the holes.
*
* Note 2: If sheet priorities are also given, sheet priorities will be respected first.
*
* The default priority is 0.
*/
CNS_EXPORT void CNS_API CNS_SetPartPriority(CNS_PartPtr part, unsigned priority);
/**
* Set user string associated with the part.
* This may be used for assigning an ID to each part.
*
* Note: the string is copied into the part object.
*/
CNS_EXPORT void CNS_API CNS_SetPartUserString(CNS_PartPtr part, const char * user_data);
/**
* Get user string associated with the part.
*
* Note: do not free/delete the returned string.
*/
CNS_EXPORT const char * CNS_API CNS_GetPartUserString(CNS_PartPtr part);
/**
* Copy the given part user_string to user_string with at most max_size character (from some
* language binding limitations).
*/
CNS_EXPORT void CNS_API CNS_GetPartUserStringEx(CNS_PartPtr part,
unsigned max_size, char * user_string);
/**
* Add a rectangular sheet to the given launching order.
*
* @param quantity is the number of sheet of the given dimension available.
* @param x and @param y describes its dimensions.
*
* Note: do not delete/free the sheet, it will be freed when calling CNS_DeleteLaunchingOrder.
*/
CNS_EXPORT CNS_SheetPtr CNS_API CNS_AddSheet(CNS_LaunchingOrderPtr order,
unsigned quantity,
double x, double y);
/**
* Set user string associated to the sheet.
* This may be used for assigning an ID to each sheet.
*
* Note: the string is copied into the sheet object.
*/
CNS_EXPORT void CNS_API CNS_SetSheetUserString(CNS_SheetPtr sheet, const char * user_data);
/**
* Set the grain direction of the sheet.
*
* If @param grain_direction is vertical then part authorizations are described relative to the
* vertical direction. For example a part which can only be nested as is (no flip, no rotation)
* can only be nested in rot90 authorization in a sheet with a vertical grain direction.
*/
CNS_EXPORT void CNS_API CNS_SetSheetGrainDirection(CNS_SheetPtr sheet,
CNS_GrainDirection grain_direction);
/**
* Set the price of the sheet.
*
* The @param price is the price assigned to the given sheet. This price is used for global
* optimization. If you set the price of one sheet, you have to give a price for all of the
* sheets. The price must not be null.
*/
CNS_EXPORT void CNS_API CNS_SetSheetPrice(CNS_SheetPtr sheet, double price);
/**
* Add an irregular sheet to the given launching order.
*
* The sheet has a simple external boundary described by an array of @param number_of_elements
* elements.
*
* The material can be either on the left side or on the right side of the polygon (the polygon
* can be clockwise or anticlockwise oriented).
*
* Note 1: do not delete/free the sheet, it will be freed when calling CNS_DeleteLaunchingOrder.
*
* Note 2: there can be a small gap of half the part gap on internal side of the holes.
*
* See: CNS_AddPart for description of the contour given by @elements.
*/
CNS_EXPORT CNS_SheetPtr CNS_API CNS_AddNonRectangularSheet(CNS_LaunchingOrderPtr order,
unsigned quantity,
unsigned number_of_elements,
const CNS_Element * elements);
/**
* Add a variable sheet length to the launching order.
*
* Variable sheet length are useful for coil based nesting, where an horizontal cut but be
* made between @param min_x and @param max_x.
*
* Note1: This mode is only compatible with objective CNS_IntelligentMinimizeX or
* CNS_IntelligentMinimizeX.
*/
CNS_EXPORT CNS_SheetPtr CNS_API CNS_AddVariableSheet(CNS_LaunchingOrderPtr order,
unsigned quantity,
double min_x, double max_x,
double y);
/**
* Add a defect/hole to the given sheet.
*
* Parts will not be nested in the holes.
*
* The holes have @param number_of_elements elements and is described by the array @elements.
*
* Note 1: Coordinates of a rectangular sheet are between (0, 0) and (x, y), the holes must be
* described in the same space.
*
* Note 2: there can be a small gap of half the part gap around the holes.
*
* See: CNS_AddPart for description of the contour given by @elements.
*/
CNS_EXPORT void CNS_API CNS_AddDefectToSheet(CNS_SheetPtr sheet,
unsigned number_of_elements,
const CNS_Element * elements);
/**
* Add another external boundary to the given sheet.
*
* The external boundary has @param number_of_elements elements and is described by the array
* @elements.
*
* Note: this can also be used to add nestable areas inside defects/holes.
*/
CNS_EXPORT void CNS_API CNS_AddExternalBoundaryToSheet(CNS_SheetPtr sheet,
unsigned number_of_elements,
const CNS_Element * elements);
/**
* Add a defect/hole to the given sheet from an open line.
*
* The path starts at the point @param origin and is composed of elements described by the
* parameters @param number_of_elements and the array @param elements. The thickness of the path
* must not be null.
*/
CNS_EXPORT void CNS_API CNS_AddOpenDefectPathToSheet(CNS_SheetPtr sheet, CNS_Point origin,
unsigned number_of_elements,
const CNS_Element * elements,
double thickness);
/**
* Helper to create defects equivalents to already nested parts.
*
* Creates a defect equivalent to the part geometry positioned at point (x, y),
* possibly flipped and rotated from angle part_angle_deg.
* Conventions for translation, flip, rotation is the same as the one
* used in CNS_GetNestedPart (part is flipped first around x_axis, then rotated
* around pivot point (0,0), then translated at point x, y to compute the geometry
* of the defect).
* Be aware that what is created from the part is pure defect geometry, which means :
* this geometry is not taken into account into length or objective computation
* this geometry is not taken into account in nested part quantity computing
* this geomerty is not taken into account in constraint interaction with other parts
* (multitorch, priority, common cut)
*/
CNS_EXPORT void CNS_API CNS_AddDefectFromNestedPart(CNS_SheetPtr sheet, CNS_PartPtr part,
double x, double y, int part_flip,
double part_angle_degree);
// Polygonal sheet and defects
CNS_EXPORT CNS_SheetPtr CNS_API CNS_AddNonRectangularPolygonSheet(CNS_LaunchingOrderPtr order,
unsigned quantity,
unsigned number_of_points,
const CNS_Point * points);
CNS_EXPORT void CNS_API CNS_AddPolygonDefectToSheet(CNS_SheetPtr sheet,
unsigned number_of_points,
const CNS_Point * points);
CNS_EXPORT void CNS_API CNS_AddExternalPolygonBoundaryToSheet(CNS_SheetPtr sheet,
unsigned number_of_points,
const CNS_Point * points);
/**
* Set the priority of the given sheet.
*
* When nesting with multiple sheets it is possible to specify a sheet priority in order to
* control which sheets will be nested first. Lower numbers indicate higher priority.
*
* If no priority is given or sheets have the same priorities, the optimizer will choose the
* sheets in order to minimize material usage.
*
* The default priority is 0.
*/
CNS_EXPORT void CNS_API CNS_SetSheetPriority(CNS_SheetPtr sheet, unsigned priority);
/** Set specific origin and objective for a given sheet.
*
* Some sheets can have specific origin or objective, you should use
* CNS_SetOrigin and CNS_SetObjective for global setting.
*/
CNS_EXPORT void CNS_API CNS_SetSpecificSheetOrigin(CNS_SheetPtr sheet, CNS_Origin origin);
CNS_EXPORT void CNS_API CNS_SetSpecificSheetObjective(CNS_SheetPtr sheet, CNS_Objective objective);
/**
* Get user string associated to the sheet.
*
* Note: do not free/delete the returned string.
*/
CNS_EXPORT const char * CNS_API CNS_GetSheetUserString(CNS_SheetPtr sheet);
/**
* Copy the given sheet user_string to user_string with at most max_size character (from some
* language binding limitations).
*/
CNS_EXPORT void CNS_API CNS_GetSheetUserStringEx(CNS_SheetPtr sheet,
unsigned max_size, char * user_string);
/**
* Add gaps around the sheet. Also known as edge spacing.
*
* For non rectangular sheet those gaps will be applied on bounding box edges.
*/
CNS_EXPORT void CNS_API CNS_SetSheetGaps(CNS_SheetPtr sheet,
double left_gap, double right_gap,
double bottom_gap, double top_gap);
/**
* When a sheet is not a rectangle, left, right, bottom, top gaps will be applied on
* the sheet bounding box and irregular_border_gap will be applied on sheet geometry
*/
CNS_EXPORT void CNS_API CNS_SetNonRectangularSheetGaps(CNS_SheetPtr sheet,
double left_gap, double right_gap,
double bottom_gap, double top_gap,
double irregular_border_gap);
/**
* Add gaps around defects/holes.
*
* Note: due to technical limitations, the gap around defects can be bigger than the specified
* one when the defect gap is less than half of the spacing between parts ("Interpart gap").
*/
CNS_EXPORT void CNS_API CNS_SetDefectGap(CNS_SheetPtr sheet, double gap);
/**
* Set the gap distance beween differents parts.
*/
CNS_EXPORT void CNS_API CNS_SetInterpartGap(CNS_LaunchingOrderPtr order, double gap);
/**
* Set the objective on the last sheet.
*
* CNS_MinimizeXThenY means that the optimizer will try to minimize x length giving less
* importance to minimizing y length.
*
* CNS_MinimizeArea means that the optimizer will try to minimize the area of the bounding box
* of the last sheet.
*
* CNS_IntelligentMininizeX minimize x if this does not lead to bad solution (long rectangular
* part oriented so as to minimize x)
*/
CNS_EXPORT void CNS_API CNS_SetObjective(CNS_LaunchingOrderPtr order, CNS_Objective objective);
/**
* Set the origin of the nesting.
*
* Nested parts will be nested around the given origin.
*/
CNS_EXPORT void CNS_API CNS_SetOrigin(CNS_LaunchingOrderPtr order, CNS_Origin origin);
/**
* Preference for repeating nests in solution (as known as "multiplicity preference").
*
* Favouring repeated nests may decrease the nesting efficiency but can lower production costs
* due to reduction in preparation times and repeatability etc.
*/
CNS_EXPORT void CNS_API
CNS_SetMultiplicityPreference(CNS_LaunchingOrderPtr order,
CNS_MultiplicityPreference multiplicity_preference);
/**
* NoMixPreference
* Preference for limiting the mix between differents kind of parts in the solution.
*
* If you have an important launching order with a large number of different parts and a large
* quantity of each part, you may face solutions where all the parts are mixed in a lot of
* different nestings. This may lead to difficulties when unloading parts.
*
* This function limits the number of active parts between nestings, it means that at the end of
* a nesting only a limited number of parts are actives (a part is called active if some of them
* were already cut before but some others remain to cut). This limitation can greatly improve
* part unloading and this is noticeably important for automatic unloading systems and/or for
* companies with limited shop floor space.
*
* @param max_number_of_active_parts is the maximum number of active parts, if 0 it means no
* limits.
*
* Note 1: This constraint may decrease nesting performance.
* Note 2: Under some special cases some small parts can be used to fill holes and the number of
* active parts can be slighty above the maximum required.
* Note 3: This function is not compatible with CNS_SetMultiplicityPreference.
*/
CNS_EXPORT void CNS_API
CNS_SetNoMixPreference(CNS_LaunchingOrderPtr order,
unsigned max_number_of_active_parts);
/**
* StrictNoMixPreferene
*
* This function is equivalent to CNS_SetNoMixPreference, however it does not have the
* limitation of note 2, that small parts are used to fill holes. This will inforce the
* limitation of @param max_number_of_active_parts number of active parts however this can
* decrease even more nesting performace.
*/
CNS_EXPORT void CNS_API
CNS_SetStrictNoMixPreference(CNS_LaunchingOrderPtr order,
unsigned max_number_of_active_parts);
/**
* SetPartIgnoreStrictNoMixPreference
*
* This function is useful if SetStrictNoMixPreference is on, in this case some parts can be
* flagged as ignore strict no mix preference. This means that they can be nested on all the
* nestings. In this case, the max_number_of_active_parts is not respected for these parts.
*
* This is useful for unloadding systems where for instance small parts are not unloaded by the
* robot where stacking space is limited but are unloaded into small boxes.
*/
CNS_EXPORT void CNS_API
CNS_SetPartIgnoreStrictNoMixPreference(CNS_PartPtr part);
/**
* NoOrientationMixOnPart
* Preference for limiting the orientation of a single part.
*
* If parts have a large number of quantities and have free rotations, it may lead to situations
* where parts are nested in a lot of different orientations. For instance, this is problem in
* sheet metal industry : the material is anisotropic and bending parts with different
* orientations requires to modify properties on the bending machine.
*
* If a given part is marked as CNS_SingleOrientationAndRot180MixOnPart, then all of them will
* be nested in the same orientation or the opposite orientation (central symmetry).
*
* If a given part is marked as CNS_SingleOrientationMixOnPart, then all of them will be nested
* in the same orientation. This can be useful for PCB industry.
*
* Note 1: This is a strong constraint as it strongly limits freedom of parts so this can reduce
* nesting performance.
*/
CNS_EXPORT void CNS_API
CNS_SetNoOrientationMixOnPart(CNS_PartPtr part, CNS_OrientationMixOnPart orientation_mix_on_part);
/**
* SetSheetNoMixPreference
*
* Preference for limiting the number of different sheets when nesting with multiple sheet
* possibilities.
*
* If multiple sheets are given to nest the parts, it may be needed to limit the number of
* different sheet sizes in the solution. For instance, one can consider to nest all the
* parts either using a machine with sheet sizes 4000x2000 or one with sheet sizes 3000x1500,
* but to nest all the parts on the same machine.
*
* @max_number_of_different_sheets describes the maximum number of different sheet used in order
* to do the nest. If this pararameter is 0 it means no limit.
*
* Note: This is a strong constraint as it limits freedom to choose sheets so this can reduce
* nesting performance.
*/
CNS_EXPORT void CNS_API
CNS_SetNoSheetMixPreference(CNS_LaunchingOrderPtr order,
unsigned max_number_of_different_sheets);
/**
* Floating mode.
*
* Parts are nested such that a minimal gap (@see CNS_SetInterpartGap) between parts is
* respected. However, sometimes a bigger gap may be used without degrading the results. Using
* bigger gap can be better for heating and cutting constraints.
*
* This function enable a mode that increases the distance between parts, spreading them out
* across the nest.
*
* For intermediate nestings in the solution, the whole sheet will be used to maximize the gap,
* while for the last one the dimensions of the nesting will be kept constant.
*
* Note: Spreading out the parts in order to maximize the distance between parts is a time
* consuming function. Therefore, this process will only be done on the last solution and may
* take time. This time is not taken into account in the given computation time.
*
* Note: this mode is incompatible with common-cut, multi-flame and shear mode.
*/
CNS_EXPORT void CNS_API
CNS_SetFloatingMode(CNS_LaunchingOrderPtr order, int enable);
/**
* Force origin packing mode.
*
* In very short time (few seconds), all parts may not be nested near the origin due to timing
* constraint, this post optimization process force the origin packing to be called at the end
* of the computation. It is called only on the final solution and it can lead to a computation
* time a bit longer (few seconds) than the given time.
*/
CNS_EXPORT void CNS_API
CNS_SetOriginPackingMode(CNS_LaunchingOrderPtr order, int enable);
/**
* EXPERIMENTAL Force small parts renesting in holes.
*
* This function is a postprocessing step that nest small parts in holes in later sheets than in
* the first sheets not in holes. This can be easier to manage, tend to group small parts
* together, and may favor reusability of offcuts. This post-processing step only apply on small
* parts with low priority (because they can be nested everywhere) and it is not compatible with
* strict part priorities.
*
* This function can lead to a computation time a bit longer (few seconds) than the given time.
*/
CNS_EXPORT void CNS_API
CNS_SetForceSmallPartsRenestingMode(CNS_LaunchingOrderPtr order, int enable);
/**
* Advanced control of offcut value.
*
* Most of the time, there is a reusable offcut at the end of a multi-sheet launching order.
* The value of this offcut must be evaluated correctly to obtain the best results especially if
* different sheet sizes are available. Also, in case of a majority of large parts, it can be
* possible to have reusable offcut for intermediate nesting. This function helps to have an
* accurate evaluation of the offcuts.
*
* By default the value of this offcut is based on its area. This is a bit optimistic since in
* real life, small offcuts can have no value and because there is labor cost associated to
* managing offcuts. Also thin offcuts can be useless because it will be very hard to use it
* again. Even the value of a big offcut on the last sheet cannot be considered to be
* equivalent to its surface because we need to unload it before using it again so it can be
* more convenient to use a smaller sheet even if the resultant material efficiency (fill-ratio)
* is a bit worse.
*
* If the offcut is smaller than @param min_dimension in X or Y, its value is 0 because it is
* too thin and will not be reusable.
*
* If the offcut area is smaller than @param min_area its value will be 0. If the offcut area is
* greater than @param min_area the value will be based on the difference of area (by
* continuity).
*
* For a reusable offcut, the value will be deprecated by @param unusable_ratio. This is useful
* to generate a small offcut in a smaller sheet even if the fill-ratio considering that the
* offcut is reusable. A reasonnable value such as 0.4 will favor using small sheets if possible
* even if the fill-ratio is worse. A value between 0.1 and 0.9 is possible.
*
* Note1: @param min_area must be in the same unit as @param min_dimension. If mm then it
* must be mm^2.
*
* Note2: if @param_min_area is 0.0 and @param_min_distance is 0.0, an automatic value will be
* used for interemdiate offcut to avoid considering that a very small offcut could have a
* value.
*/
CNS_EXPORT void CNS_API
CNS_SetOffcutEvaluation(CNS_LaunchingOrderPtr order,
double min_dimension,
double min_area,
double unusable_ratio);
/**
* Control of part priorities.
*
* By default, priorities are not strict, if parts with high priority can not be nested a part
* with a lower priorities will be nested. In case of strict priorities, parts with lower
* priority will be nested only when all the parts of higher priorities will have been nested.
*
* Note: this function may degrades the performance of the nesting.
*/
CNS_EXPORT void CNS_API
CNS_SetStrictPrioritiesOnParts(CNS_LaunchingOrderPtr order, int strict);
/**
* Ignore priority on some parts.
*
* In strict priorities on part mode, some parts can be flagged as ignore to priority. This
* means that they can be nested on all the nestings without considering them having a fixed
* priority.
*/
CNS_EXPORT void CNS_API
CNS_SetPartIgnorePriority(CNS_PartPtr part);
/**
* Control of part priorities position.
*
* By default, parts with high priority will be nested in the first sheets,
* however they may not be nested near to the origin. This parameter enable to
* nest high priority parts near to the origin.
*
* Note: this function may degrades the performance of the nesting.
*/
CNS_EXPORT void CNS_API
CNS_SetOriginPrioritiesOnParts(CNS_LaunchingOrderPtr order, int enable);
/* =====================================================================================
*
* Launching nesting computation.
*
* ===================================================================================== */
/**
* Launch a non-blocking cloud computation of the given launching order on optalog servers.
*
* @param server the cloud nest server ip (or fully qualified name).
* @param login the login used for running the computation.
* @param computation_time the time you want to give to obtain the results (a longer time will
* yield better results).
* 30 seconds is the minimum advised time to obtain good results.
*
* Note: do not delete/free the computation, it will be freed when calling
* CNS_DeleteLaunchingOrder.
*
* Note: the @param server can contains multiple servers separated by ";" for high availability.
*/
CNS_EXPORT CNS_ComputationPtr CNS_API CNS_LaunchComputation(CNS_LaunchingOrderPtr order,
const char * server,
const char * login,
double computation_time);
/**
* Launch a non-blocking local computation of the given launching order.
*
* @param computation_time the time you want to give to obtain the results (a longer time will
* yield better results). 30 seconds is the minimum advised time to obtain very good
*
* The computation can be launched in infinite mode by giving a computation time value of -1.0.
* In this mode the user is responsible for collecting intermediate results and stopping the
* engine himself with CNS_CancelComputation or CNS_TerminateComputation.
*
* Note: do not delete/free the computation, it will be freed when calling
* CNS_DeleteLaunchingOrder.
*
* Note: this function launch an asynchronous computation and creates some working threads.
* This function may not be available in the given version.
*/
CNS_EXPORT CNS_ComputationPtr CNS_API CNS_LaunchLocalComputation(CNS_LaunchingOrderPtr order,
double computation_time);
/**
* Wait for the given computation to terminate and return the computation status.
*/
CNS_EXPORT CNS_ComputationStatus CNS_API
CNS_WaitComputationTermination(CNS_ComputationPtr computation);
CNS_EXPORT CNS_ComputationStatus CNS_API
CNS_WaitNextSolution(CNS_ComputationPtr computation);
/**
* Return the status of the given computation.
*
* This function is non-blocking so we recommend you sleep the thread between calls in the loop.
*/
CNS_EXPORT CNS_ComputationStatus CNS_API
CNS_GetComputationStatus(CNS_ComputationPtr computation);
/**
* Cancel the given computation without returning solution
*
* This function is blocking and may take a little time to execute (time to find a cancel
* point), but it will stop as fast as possible even if no solution is computed.
*/
CNS_EXPORT CNS_ComputationStatus CNS_API
CNS_CancelComputation(CNS_ComputationPtr computation);
/**
* Cancel all computations and delete the launching order in a detached thread.
*
* To cancel computation and return immediatly you can call the following function that will
* cancel all the computations of the given launching order and delete the order immediately
* after
*
* Note: This function encapsulates the cancellation and deletion in a detached thread so the
* CPU can still be busy during a small time on very large problems.
*
* Note2: Do not use CNS_DeleteLaunchingOrder if this function is called.
*/
CNS_EXPORT void CNS_API
CNS_AsyncCancelAllComputationsAndDeleteLaunchingOrder(CNS_LaunchingOrderPtr order);
/**
* Terminate the given computation with a valid optimized solution
*
* This function is blocking and may take a little time to execute (time to find a cancel
* point), but it will stop as fast as possible and will return a valid and optimized solution.
*/
CNS_EXPORT CNS_ComputationStatus CNS_API
CNS_TerminateComputation(CNS_ComputationPtr computation);
/* =====================================================================================
*
* Querying the results.
*
* ===================================================================================== */
/**
* return the solution computed by the computation.
*
* precondition : Status of the computation must be CNS_Ok or CNS_IntermediateResult.
*
* Note: do not delete/free the solution, it will be freed when calling
* CNS_DeleteLaunchingOrder.
*/
CNS_EXPORT CNS_SolutionPtr CNS_API CNS_GetSolution(CNS_ComputationPtr computation);
/**
* return the number of different nestings in the solution.
*/
CNS_EXPORT unsigned CNS_API CNS_GetNumberOfNestings(CNS_SolutionPtr solution);
/**
* return the nesting given @param nesting_number in the solution @param solution
*
* Note: do not delete/free the nesting, it will be freed when calling CNS_DeleteLaunchingOrder.
*/
CNS_EXPORT CNS_NestingPtr CNS_API CNS_GetNesting(CNS_SolutionPtr solution,
unsigned nesting_number);
/**
* return the repeat count (or "multiplicity") of the given nesting.
*/
CNS_EXPORT unsigned CNS_API CNS_GetMultiplicity(CNS_NestingPtr nesting);
/**
* return the sheet used for the given nesting.
*/
CNS_EXPORT CNS_SheetPtr CNS_API CNS_GetSheet(CNS_NestingPtr nesting);
/**
* return the number of nested parts in the given nesting.
*/
CNS_EXPORT unsigned CNS_API CNS_GetNumberOfNestedParts(CNS_NestingPtr nesting);
/**
* Returns information of @param nested_part_number nested part in the given nesting
*
* @param x and @param y describe the position of the origin (0, 0) of the part's coordinates
* @param flip if the part is fliped (first)
* @param angle_in_deg, the angle of the nested part (rotated counter clockwise).
*
* If we take the part by (0, 0) this function return in @param x and @param y, the translation
* required to move the original part into position.
*
* see illustration: images/pivot.svg
*
* For example if we nest 2 rectangles of dimensions 250x500 described by the coordinates (100,
* 100), (350, 100), (350, 600), (100, 600), in a sheet of dimensions 2000x1000. We can nest
* one part in (-100, -100) and this part will be in the bottom_left of the sheet, while the
* second one will be nested at (-100,400) and the part will be in the top left of the sheet.
*
* The part can be also flipped and rotated around the (0, 0). For example, if we want to nest
* the same two parts in a sheet of dimensions 2000x500 ; we can rotate the part by 90 counter
* clock-wise, the coordinates will be (-100,100), (-100, 350), (-600, 350), (-600, 100).
*
* We can nest a first part at (600, -100) rotated by 90 and a second one at (1100, -100)
* rotated by 90, to obtain a nesting of length 1000.
*/
CNS_EXPORT void CNS_API CNS_GetNestedPart(CNS_NestingPtr nesting, unsigned nested_part_number,
CNS_PartPtr * part,
double * x, double * y,
int * flip, double * angle_in_deg);
/**
* return an invalid part.
*
* precondition : status of the computation must be CNS_BadPartGeometry.
*/
CNS_EXPORT CNS_PartPtr CNS_API
CNS_GetPartWithBadGeometry(CNS_ComputationPtr computation);
/**
* Enable guillotine shear mode
*
* This is adapted from shear machines, that can only cut nesting from one border to another
* either horizontaly or verticaly. This is suited for rectangular parts only., otherwise material
* loss will occur.
*
* Limitations : this mode is incompatible with part priorities, filler parts, and also
* non-rectangular sheets.
*
* If @param shear is not 0 then shear mode will be activated.
*/
CNS_EXPORT void CNS_API CNS_SetShearMode(CNS_LaunchingOrderPtr order, int shear);
/**
* Enable guillotine shear mode with rows patterns.
*/
CNS_EXPORT void CNS_API CNS_SetShearRowMode(CNS_LaunchingOrderPtr order, int shear);
/**
* Enable guillotine shear mode with columns patterns.
*/
CNS_EXPORT void CNS_API CNS_SetShearColumnMode(CNS_LaunchingOrderPtr order, int shear);
/**
* Set shear gap.
*
* When cutting with a shear machine or when cutting glass, it can be impossible to cut twice
* within a small distance, the parameter @param shear_gap describes this distance.
*/
CNS_EXPORT void CNS_API CNS_SetShearGap(CNS_LaunchingOrderPtr order, double shear_gap);
/**
* Set maximum shear length.
*
* Some shear machines can have a limited size of maximum shear length.
*/
CNS_EXPORT void CNS_API CNS_SetShearMaxLength(CNS_LaunchingOrderPtr order,
double shear_max_length);
/**
* Repulse parts from borders.
*
* For PCB nesting it is better to push parts far from borders to avoid cutting problems.
*/
CNS_EXPORT void CNS_API CNS_SetShearRepulseFromBorders(CNS_LaunchingOrderPtr order,
int repulse);
/* =====================================================================================
*
* Common Line Nesting
*
* ===================================================================================== */
/**
* Enable or disable common cut
*
* This function allows to enable common cut between identical parts.
*
* Note: common cut mode is currently exclusive from multitorch mode (and shear mode).
*/
CNS_EXPORT void CNS_API CNS_SetCommonCutMode(CNS_LaunchingOrderPtr launching_order,
int enable, double common_cut_gap);
/**
* Enable or disable common cut between different parts
*
* This experimental mode allows to generate common cut between different parts.
* This function must be called instead of CNS_SetCommonCutMode in order to generate
* nestings with common cut on different parts.
*
* This mode is useful if you have a large set of different parts with small quantities and long
* straight edges that could be cut in common cut. In this case, this common cut mode allows
* to save both cutting time and material.
*
* Note: this mode does not take into account limits given by functions
* CNS_SetPartCommonCutMaxBlockSize
*/
CNS_EXPORT void CNS_API
CNS_SetCommonCutDifferentPartMode(CNS_LaunchingOrderPtr order,
int common_cut,
double common_cut_gap);
/**
* Enable or disable common cut on a specific part.
*
* Some parts should never be cut in common line configurations. This function gives control to
* enable or disable common line cutting on a part-by-part basis.
*/
CNS_EXPORT void CNS_API CNS_SetPartCommonCutMode(CNS_PartPtr part, int enable);
/**
* Enable or disable common cut with hole boundaries.
*
* In some circumstances it may be forbidden to nest in common cut with hole boundaries. By
* default, it is allowed to do common cut with hole boundaries.
*/
CNS_EXPORT void CNS_API CNS_SetCommonCutOnHoles(CNS_LaunchingOrderPtr order,
int common_cut_on_holes_boundary);
/**
* Controlling common line cutting safety.
*/
typedef enum
{
CNS_RestrictedCommonCut = 0, // only bi modules with very fast leaving conditions
CNS_SafeCommonCut = 1, // fast leaving conditions on border of common cuts
// (default)
CNS_StrongCommnCut = 2, // intermediate
CNS_AggressiveCommonCut = 3 // aggressive common cut (may lead to cutting problems)
} CNS_CommonCutSafetyPreference;
/**
* Simple control of the quality of a common cut.
*
* see: CNS_SetCommonCutAuthorizations for finer control
*/
CNS_EXPORT void CNS_API
CNS_SetCommonCutSafetyPreference(CNS_LaunchingOrderPtr launching_order,
CNS_CommonCutSafetyPreference safety_preference);
/**
* Common cut leadin check. A small leadin check can be done on the extremities of common-cut to
* obtain easy to cut common-cuts.
*/
typedef enum
{
CNS_FreeCommonCutLeadin = 0, // no leadin check
CNS_LinearTangentialCommonCutLeadin = 1, // simple prolongating linear leadin (can be
// tangential to one of the part)
CNS_LinearSeparatingCommonCutLeadin = 2 // simple prolongating linear leadin is fully valid
// and not on the border of any part. This will
// forbid partial common cut.
} CNS_CommonCutLeadin;
/**
* Advanced common cut authorization control
*
* @param min_cutting_length the minimum length of a common cut.
* @param max_regarding_ratio control the leaving condition. If the edges around a common cut
* edge are nearer than the normal part_gap this may introduce heating or cut problems if two
* edges remain close to each others during too much time. This "bad zone" is approximated by a
* length called the "regarding length". The parameter @parameter max_regarding_ratio allows to
* control the maximum length of the regarding_length relatively to the normal part gap. A value
* of 2.0 is strict while a value of 8.0 is permissive.
* @param leadin_type controls possible leading around the common_cut. This parameter allows to
* check for a simple prolongating linear leadin around common cut edges, the length of the
* leadin is equal to half the interpart gap.
* @param no_holes do not introduce holes while doing common_cut
* @param only do common cut by grouping 2 parts together
*/
CNS_EXPORT void CNS_API CNS_SetCommonCutAuthorizations(CNS_LaunchingOrderPtr launching_order,
double min_cutting_length,
double max_regarding_ratio,
CNS_CommonCutLeadin leadin_type,
int no_holes,
int only_bi_module);
/**
* Perfect alignment of common cuts.
*
* It some cases, it is only possible to align same length and perfect alignment of common cuts.
* This limits the number of possible common cuts.
*/
CNS_EXPORT void CNS_API CNS_SetCommonCutPerfectAlignment(CNS_LaunchingOrderPtr launching_order,
int enable);
/**
* Common cut objective settings (favor common cut or material usage).
*/
/**
* Control of the tradeoff between material and cutting time.
* see: CNS_SetCommonCutObjective for more accurate control
*/
typedef enum
{
CNS_MaterialPreference = 0, // maximize material and give no specific value to
// common-cutting
CNS_WeakCuttingPreference = 1, // give some light preference for common-cutting
// (default)
CNS_AverageCuttingPreference = 2, // more preference for cutting
CNS_StrongCuttingPreference = 3 // return solutions with lots of common line cutting
// (may lose material)
} CNS_CommonCutCuttingPreference;
CNS_EXPORT void CNS_API
CNS_SetCommonCutCuttingPreference(CNS_LaunchingOrderPtr launching_order,
CNS_CommonCutCuttingPreference cutting_preference);
/**
* Give real material cost and cutting cost to obtain the best result (minimize cost).
*
* @param material_cost the cost of 1 unit of area of material (e.g. cost per mm^2)
* @param cutting_cost the cost of 1 unit of cutting (e.g. cost per mm)
* Cutting in common cut while reduce the cutting length by cutting 2 parts together.
*/
CNS_EXPORT void CNS_API
CNS_SetCommonCutObjective(CNS_LaunchingOrderPtr launching_order,
double material_cost, double cutting_cost);
/**
* Limit the size of common cut blocks to a maximum dimension.
*
* If parts are cut in common cut, this can lead to very big blocks. Those big blocks lead to
* skeleton rigidity problems. It is possible to limit their maximum size. @param
* max_block_size the maximum size of common cut block.
*/
CNS_EXPORT void CNS_API
CNS_SetCommonCutMaxBlockSize(CNS_LaunchingOrderPtr launching_order, double max_block_size);
/**
* Limit the size of common cut blocks to a maximum dimension in x and in y.
*
* If parts are cut in common cut, this can lead to very big blocks. Those big blocks lead to
* skeleton rigidity problems. It is possible to limit their maximum size.
* @param max_block_size_x the maximum size of common cut block in x
* @param max_block_size_y the maximum size of common cut block in y
*/
CNS_EXPORT void CNS_API
CNS_SetCommonCutMaxBlockSizeXY(CNS_LaunchingOrderPtr launching_order,
double max_block_size_x,
double max_block_size_y);
/**
* Limit the size of common cut blocks to a maximum number of parts.
*
* If small parts are cut in common cut, this can lead to a huge number of parts in a common cut
* block. If a cutting problem occurs, all the parts can have a problem. This limit the maximum
* number of parts in a block.
*/
CNS_EXPORT void CNS_API
CNS_SetPartCommonCutMaxBlockSize(CNS_PartPtr part,
unsigned max_number_of_parts_in_block);
/**
* Limit the size of common cut blocks to a maximum dimension in x and in y for the given part.
*
* If parts are cut in common cut, this can lead to very big blocks. Those big blocks lead to
* skeleton rigidity problems. It is possible to limit their maximum size.
* @param max_block_size_x the maximum size of common cut block in x
* @param max_block_size_y the maximum size of common cut block in y
*
* Note: all algorithms are not compatible with this setting and using this function may reduce
* a little bit nesting performance.
*/
CNS_EXPORT void CNS_API
CNS_SetPartCommonCutMaxBlockSizeXY(CNS_PartPtr part,
double max_block_size_x,
double max_block_size_y);
/**
* Allows to disable some advanced common cut checks.
*
* Warning: this can allows to generate small holes between common cuts.
*/
CNS_EXPORT void CNS_API
CNS_SetCommonCutAdvancedQualityCheck(CNS_LaunchingOrderPtr order,
int advanced_quality_check);
/**
* return the number of common cuts in the given nesting.
*/
CNS_EXPORT unsigned CNS_API CNS_GetNumberOfCommonCuts(CNS_NestingPtr nesting);
typedef struct
{
double x_origin;
double y_origin;
double x_extremity;
double y_extremity;
} CNS_Segment;
/**
* Return informations associated to the given common_cut.
*
* This function returns the guessed common_cut in @param *common_cut, the indexes of the
* nested_parts in @param *left_nested_part_index and in @param right_nested_part_index, and the
* corresponding left and right segments in @param *left_segment and @param *right_segment.
*/
CNS_EXPORT void CNS_API CNS_GetCommonCut(CNS_NestingPtr nesting, unsigned common_cut_number,
CNS_Segment * common_cut,
unsigned * left_nested_part_index,
CNS_Segment * left_segment,
unsigned * right_nested_part_index,
CNS_Segment * right_segment);
/* =====================================================================================
*
* Multi Torch Cutting
*
* ===================================================================================== */
/**
* Enable or disable multi-torch and set basic multi-torch constraints.
* max_torch_distance = 0.0 means no max_torch_distance;
*
* Note: multi torch mode is exclusive from common cut mode and shear mode
*
* Warning : beta version
* Multi-torch mode is still in beta and some edge cases are not yet managed:
* - For the moment multi-torch works only when trying to minimize x and nest on bottom in
* last sheet.
* Advanced mode and special offcuts are not managed
* - Different kind of algorithms are used to produce multitorch result and the best results
* are chosen automatically. For some specific geometries or situations new algorithms need
* to be implemented to improve results but on average results are already ok.
* - Multi-torch takes specific constraints such as min distance between torches and
* auto or manual torch distance changes (e.g. during nesting on sheet or between sheets only).
* Parameter vertical_torches_alignment should be true on most machines. For machines where
* torches are aligned on the other axis, set it to false.
*
* These constraints are managed and results always take these constraints into account but
* sometimes results may be suboptimal in terms of cutting time or used area
* because specific algorithms are needed to handle complex situations.
*
* Feedback: If you find problems were results are clearly suboptimal compared to manual nesting
* please report it so we can feed into the next round of development.
*/
CNS_EXPORT void CNS_API CNS_SetMultiTorchMode(CNS_LaunchingOrderPtr launching_order,
int enable, int max_nb_torches,
double min_torch_distance,
double max_torch_distance,
int vertical_torches_alignment);
typedef enum
{
CNS_TorchWeakCuttingPreference = 1, // give some light preference for cutting time
// vs losing material
CNS_TorchAverageCuttingPreference = 2, // more preference for cutting time
CNS_TorchStrongCuttingPreference = 3, // return solutions that strongly favor cutting
// time
CNS_TorchExtremeCuttingPreference = 4 //use multiple torches as much as possible
// even at hight material cost
} CNS_MultiTorchCuttingPreference;
/**
* Simple control of the tradeoff between material and cutting time.
*
* @param manual_torch_move indicates that the torch must be moved manually. In this case the
* algorithm will reduce the number of times the gap between torches must be changed when
* cutting a given plate.
*
* Note: Use either this function or CNS_SetMultiTorchObjective. If the two are called, only
* last call will be taken into account
*
* see: CNS_SetMultiTorchObjective for more accurate control
*/
CNS_EXPORT void CNS_API
CNS_SetMultiTorchCuttingPreference(CNS_LaunchingOrderPtr launching_order,
CNS_MultiTorchCuttingPreference cutting_preference,
int manual_torch_move);
typedef enum
{
//Change torch distance inside a nesting as often as needed
//usually because the change is done by the machine CN during the cut
//equivalent to manual_torch_move = 0
CNS_TorchDistanceAutomatic = 0,
//Change torch distance inside a nesting only
//if it allows to cut more parts together
CNS_TorchDistanceFewChanges = 1,
//Try to find the best distance for cutting a nesting plate
//and avoid changing torch distance inside a nesting,
//usually because this operation is manual and takes time
//equivalent to manual_torch_move = 1
CNS_TorchDistanceManual = 2,
} CNS_MultiTorchTorchDistancePreference;
CNS_EXPORT void CNS_API
CNS_SetMultiTorchCuttingPreferenceDistancePreference(CNS_LaunchingOrderPtr launching_order,
CNS_MultiTorchCuttingPreference cutting_preference,
CNS_MultiTorchTorchDistancePreference distance_preference);
/**
* Advance control of the trade off between material, cutting time cost and moving torch cost
* by giving real material cost and cutting time cost to obtain the best result (minimize cost).
*
* @param material_cost the cost of 1 unit of area of material (e.g. cost per mm^2)
* @param cutting_cost the cost of time lost by cutting 1mm of material
* @param torch_moving_cost the time cost of changing gap between torches while cutting a
* plate. This operation may take time or not, depending on the machine (Sometimes the torch gap
* can be controlled by the NC and sometimes the operator must change it manually).
*
* Note: Use either this function or CNS_SetMultiTorchCuttingPreference. If the two are called,
* only last call will be taken into account
*/
CNS_EXPORT void CNS_API
CNS_SetMultiTorchObjective(CNS_LaunchingOrderPtr launching_order,
double material_cost, double cutting_time_cost,
int torches_can_move, double torch_moving_cost);
/**
* Another way to define the tradeoff between material and cutting cost by giving machine speed
* and hourly cost rate of the machine when cutting.
*
* @param material_cost the cost of 1 unit of area of material (e.g. cost per mm^2)
* @param single_torch_cost_per_hour is hourly rate of the machine when cutting with one torch
* @param extra_torch_cost_per_hour is extra hourly rate when cutting with an extra torch
* So hourly rate of the machine when cutting with 3 torches is single_torch_cost_per_hour + 2 *
* extra_torch_cost_per_hour.
* @param mm_per_hour_machine_cutting_speed for describing maching cutting speed
* @param torch_can_move describes if torches gap can be moved in a nesting
* @param torch_moving_cost is the cost of changing gap between torches. This operation may take
* time or not, depending on the machine (Sometimes the torch gap can be controlled by the NC
* and sometimes the operator must change it manually).
*
* Use this instead of CNS_SetMultiTorchCuttingPreference if you prefer.
*/
CNS_EXPORT void CNS_API
CNS_SetDetailedMultiTorchObjective(CNS_LaunchingOrderPtr launching_order,
double material_cost,
double single_torch_cost_per_hour,
double extra_torch_cost_per_hour,
double mm_per_hour_machine_cutting_speed,
int torches_can_move, double torch_moving_cost);
/**
* Get multitorch infos for each part of the given nesting.
*
* There are three kinds of multitorch infos :
* - the group_number is the same for all parts that must be cut at the same time.
* - For parts that have the same group number, all torch_numbers are different.
* On a given part the torch number indicates what torch is cutting the part. The group
* always has a part that has torch number 0 that is the bottom part of the group.
* - torch distance indicates how the torch are set up. A distance of 400mm on a 4 torches
* system indicates that torches positions are 0, 400, 800, 1200. For parts of the same group
* the distance is always the same.
* Parts in group -1 are standalone parts.
* Part_index is the index of the part in the nesting, from 0 to (nb_nested_parts - 1)
*
* An example : you have nested parts A1 (100, 100), A2(100, 200), A3(100,300), A4(100, 400),
* A5(100,500) B1(200,100) B2(200, 350), C(200,500), D(200,600) in the same nesting on a 3
* torches system with a minimum distance of 150 between torches. You will cut {A1,A3,A5}
* together, {A2, A4} together and {B1, B2} together. C and D are standalone You will get the
* following (group_number, torch_number, torch_distance) values for each part : A1 (0,0,200.0),
* A2 (1,0,200.0), A3(0,1,200.0), A4(1,1,200.0), A5(0,2,200.0), B1(2,0,250.0), B2(2,1,250.0),
* C(-1,0,0.0), D(-1,0,0.0)
*/
CNS_EXPORT void CNS_API
CNS_GetPartTorchInfos(CNS_NestingPtr nesting, unsigned part_index,
int * group_number, unsigned * torch_number, double * torch_distance);
/**
* Renest the holes in order to ensure that the holes with the same parts are nested the same
* way.
*
* In some particular case such as micro-attached parts with automatic unloading system, it may
* be useful that the holes with the same parts are nested exactly the same way in order to
* unload the nested parts on the same stack.
*/
CNS_EXPORT void CNS_API
CNS_SetHoleRenester(CNS_LaunchingOrderPtr launching_order,
int hole_renester_enable);
/* =====================================================================================
*
* Statistics
*
* ===================================================================================== */
/**
* Return the fill ratio of the solution.
*
* Note that the fill ratio may not be strictly decreasing in intermediate solutions because some
* value is given to minimize the number of nestings, to reusable intermediate sheets, to
* pushing the parts in corners and to cutting costs.
*/
CNS_EXPORT double CNS_API
CNS_GetFillRatio(CNS_SolutionPtr solution);
/**
* Return dimensions of the nesting.
* This function return in *x and in *y the dimensions of the nesting (relatively to its origin).
*/
CNS_EXPORT void CNS_API
CNS_GetNestingDimensions(CNS_NestingPtr nesting, double * x, double * y);
/**
* Return the fill ratio of the given nesting.
*
* For the last sheet the considered used surface in the fill ratio is up to the frontline, or
* area.
*/
CNS_EXPORT double CNS_API
CNS_GetNestingFillRatio(CNS_NestingPtr nesting);
/* =====================================================================================
*
* Debug and html drawing
*
* ===================================================================================== */
/**
* Generate an html report of the inputs (parts, sheets...).
*
* This function is useful to check if the inputs are corrects.
*/
CNS_EXPORT void CNS_API
CNS_GenerateHtmlLaunchingOrderReport(CNS_LaunchingOrderPtr launching_order,
const char * filename);
/**
* Generate an html report for the given solution.
*/
CNS_EXPORT void CNS_API
CNS_GenerateHtmlSolutionReport(CNS_SolutionPtr solution, const char * filename);
/**
* Generate DXF file for the corresponding nesting.
*/
CNS_EXPORT void CNS_API
CNS_GenerateDxfNesting(CNS_NestingPtr nesting, const char * filename);
/**
* Generate a json problem description.
*
* This function is useful to report problem descriptions. This allow us to reproduce the
* nesting problem and run it.
*/
CNS_EXPORT void CNS_API
CNS_GenerateLaunchingOrderProblem(CNS_LaunchingOrderPtr launching_order,
const char * filename);
/**
* Some functionalities may be activated only by calling this unlock key function
*/
CNS_EXPORT void CNS_API
CNS_UnLockLaunchingOrder(CNS_LaunchingOrderPtr launching_order, unsigned unlock_key);
/**
* Return informations about the current build.
*/
CNS_EXPORT const char * CNS_API CNS_GetMajorVersion();
CNS_EXPORT const char * CNS_API CNS_GetBuildDate();
CNS_EXPORT const char * CNS_API CNS_GetBuildVersion();
CNS_EXPORT const char * CNS_API CNS_GetBuildVersionNumber();
#ifdef __cplusplus
}
#endif
#endif