Home > User Guide > Laws
Using law_data to Pass Classes to Laws
The unary_law, binary_law, and multiple_law classes are used if the application is passing only laws into a law class, in which case it becomes a pointer to a law or an array of pointers to laws, respectively. Numbers, positions, parametric positions, vectors, and vector fields, in addition to the law symbols, are passed as input to the api_str_to_law and become laws for these purposes.
On the other hand, the unary_data_law and multiple_data_law classes are used if the application is passing more complicated structures into a law class. These could be curves, wires, surfaces, transforms, or even laws. Instead of having a pointer to a law or an array of pointers to laws, the unary_data_law and multiple_data_law classes have a pointer to a law_data class or an array of pointers to law_data classes, respectively.
The base law_data class is used to handle the more complicated data structures from these special cases. The classes derived from law_data are wrapper classes for specific ACIS classes, such as curves, wires, surfaces, and transforms. The purpose of the wrapper law_data classes is to permit all ACIS classes to be handled in the same way as normal law classes. The wrapper functions know how to evaluate the data from the ACIS classes, how to save and restore them, and how to parse and unparse them.
curve_law_data
curve_law_data defines a wrapper class for holding data from a curve that is passed into either unary_data_law or multiple_data_law.
C++ Example
// How to create a curve law from an edge.
EDGE *my_edge;
...
// Find the bounds of the curve.
double start = my_edge->start_param();
double end = my_edge->end_param();
// Get a copy of the curve curve
*my_curve=my_edge->geometry()->trans_curve();
// Create a curve_law_data wrapper.
curve_law_data *my_c_law_data = new curve_law_data(
my_curve, start, end);
// Create a curve law.
law *my_curve_law = new curve_law(my_c_law_data);
// clean up memory.
my_c_law_data->remove();law_law_data
law_law_data defines a wrapper class for holding the data from a law that is passed into either unary_data_law or multiple_data_law.
C++ Example
// How to create a law data from a law.
curve_law_data *my_c_law_data
// see example for curve_law_data
...
// Create a law for the integer 1.
law *my_law = new constant_law(1);
// Wrap the law in a law_data class.
law_law_data *my_l_law_data = new law_law_data(my_law);
// Clean up memory.
my_law->remove();
// Make an array of two law_datas.
law_data *my_l_law_data[2];
my_l_law_data[0] = my_c_law_data;
my_l_law_data[1] = my_l_law_data;
// Create a law that returns first derivative of curve.
// The constant law in my_law_data indicates how many derivatives to take.
law *my_dcurve_law = new dcurve_law(my_l_law_data, 2);
// Clean up memory.
my_c_law_data->remove();
my_l_law_data->remove();path_law_data and surface_law_data
path_law_data defines a wrapper class for holding data which is passed into either unary_data_law or multiple_data_law. Its main purpose is to handle curves and wires in a similar manner. curve_law_data and wire_law_data are derived from this class. This law is an abstract data class that is not created directly by a programmer.
surface_law_data defines a wrapper class for holding data from a surface that is passed into either unary_data_law or multiple_data_law.
C++ Example
// How to create a surface law from a surface.
FACE *my_face; ...
// Get the surface.
surface *my_surface=my_face->geometry()->equation();
// Find the bounds of the surface.
SPAinterval u_range = my_surface->param_range_u();
SPAinterval v_range = my_surface->param_range_v();
// Create a surface_law_data wrapper.
surface_law_data *my_s_law_data = new surface_law_data(
my_surface, u_range, v_range);
// Create a surface law.
law *my_surface_law = new surface_law(my_s_law_data);
// clean up memory.
my_s_law_data->remove();transform_law_data
transform_law_data defines a wrapper class for holding data from a transform that is passed into either unary_data_law or multiple_data_law.
C++ Example
// How to create a transform law from a transform.
// This is similar to the cure law data, but bounding
// information is contained within the wire class.
SPAtransf *my_transform;
law *my_law;
...
// Create a transform_law_data wrapper.
transform_law_data *my_w_law_data = new transform_law_data(my_transform);
// Create a rotate law.
// The rotate law will rotate the vectors returned by my_law with the my_transform.
law *my_rotate_law = new rotate_law(my_law, my_t_law_data);
// clean up memory.
my_t_law_data->remove();wire_law_data
wire_law_data defines a wrapper class for holding data from a wire that is passed into either unary_data_law or multiple_data_law.
C++ Example
// How to create a wire law from a wire.
// This is similar to the cure law data, but bounding information is contained within the wire class.
WIRE *my_wire;
...
// Create a wire_law_data wrapper.
wire_law_data *my_w_law_data = new wire_law_data(my_wire);
// Create a wire law.
law *my_wire_law = new wire_law(my_w_law_data);
// clean up memory.
my_w_law_data->remove();[Top]
© 1989-2007 Spatial Corp., a Dassault Systèmes company. All rights reserved.