acis_tutorials_(math_classes).htm

来自「acis说明文档」· HTM 代码 · 共 600 行 · 第 1/4 页

HTM
600
字号
<li class="toclevel-1"><a href="#SPApar_vec"><span class="tocnumber">9</span> <span class="toctext">SPApar_vec</span></a></li><li class="toclevel-1"><a href="#SPApar_dir"><span class="tocnumber">10</span> <span class="toctext">SPApar_dir</span></a></li><li class="toclevel-1"><a href="#SPAinterval"><span class="tocnumber">11</span> <span class="toctext">SPAinterval</span></a></li><li class="toclevel-1"><a href="#SPAbox"><span class="tocnumber">12</span> <span class="toctext">SPAbox</span></a></li><li class="toclevel-1"><a href="#SPApar_box"><span class="tocnumber">13</span> <span class="toctext">SPApar_box</span></a></li><li class="toclevel-1"><a href="#Laws"><span class="tocnumber">14</span> <span class="toctext">Laws</span></a></li><li class="toclevel-1"><a href="#A_C.2B.2B_Example"><span class="tocnumber">15</span> <span class="toctext">A C++ Example</span></a></li></ul></td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script><p>In this tutorial we shall introduce you to some of the ACIS classes that represent generalized mathematical concepts, such as positions, vectors, and bounding boxes.  Some of these classes function in the 3-dimensional model space, some of these classes function in the 2-dimensional parametric space of a surface, and some function in both. Our intent is to familiarize you with some of the most frequently used classes, their member functions and operators, and some of the global functions that operate upon these classes.  We have included links to the documentation for each of these classes.  Please take a few moments to scan through the documentation on the functions and operators for each of the classes to get a sense of capabilites of each of the classes.  </p><a name="SPAposition"></a><h2> <span class="mw-headline"> SPAposition </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAposition.html class="external text">SPAposition</a></b> is a point (i.e., a position vector) in a 3D Cartesian space.  SPApositions are defined in position.hxx.</p><a name="SPAvector"></a><h2> <span class="mw-headline"> SPAvector </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAvector.html class="external text">SPAvector</a></b> is a displacement vector in a 3D Cartesian space.  SPAvectors are defined in vector.hxx.</p><a name="SPAunit_vector"></a><h2> <span class="mw-headline"> SPAunit_vector </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAunit_vector.html class="external text">SPAunit_vector</a></b> is a direction in 3D Cartesian space that has unit length. It is derived from the vector class; therefore, it inherits all the functionality of vectors. There are very few operations that are unique to unit vectors, although several functions have been overloaded for unit_vectors to make them more efficient. SPAvectors are defined in unitvec.hxx.</p><a name="SPAmatrix"></a><h2> <span class="mw-headline"> SPAmatrix </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAmatrix.html class="external text">SPAmatrix</a></b> is a 3x3 Euclidean affine transformation.  It is NOT a tensor.  SPAmatrices are defined in matrix.hxx.</p><blockquote class="templatequote"><div><p><i><b>Note:</b>  Application developers will generally use an instance of the SPAtransf class rather than an instance of the SPAmatrix class. The SPAmatrix class is described here so you will be aware it exists inside a transformation.</i></p></div></blockquote> <a name="SPAtransf"></a><h2> <span class="mw-headline"> SPAtransf </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAtransf.html class="external text">SPAtransf</a></b> is a general transformation for a 3D vector.  It is in effect a 4 x 3 matrix to multiply a homogeneous vector, but is stored specially for efficiency.  Transformations are applied to 3D positions and vectors.  SPAtransfs are defined in transf.hxx.</p><a name="SPAparameter"></a><h2> <span class="mw-headline"> SPAparameter </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAparameter.html class="external text">SPAparameter</a></b> is a curve parameter value. It is a essentially a double, but it has been declared as a class entity for consistency.  SPAparameters participate in virtually all of the arithmetic operations one would expect for a double.  SPAparameters are defined in param.hxx.</p><a name="SPApar_pos"></a><h2> <span class="mw-headline"> SPApar_pos </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPApar_pos.html class="external text">SPApar_pos</a></b> is a position in the parameter-space of a surface.  It defines a (u, v) parameter-space coordinate that, when evaluated on a surface, produces a 3D object space coordinate.   SPApar_pos'es are defined in param.hxx.</p><a name="SPApar_vec"></a><h2> <span class="mw-headline"> SPApar_vec </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPApar_vec.html class="external text">SPApar_vec</a></b> is a vector (du, dv) in the parameter-space of a surface.  SPApar_vecs are defined in param.hxx.</p><a name="SPApar_dir"></a><h2> <span class="mw-headline"> SPApar_dir </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPApar_dir.html class="external text">SPApar_dir</a></b> is a direction vector (du, dv) in the parameter-space of a surface.  (This is the parameter-space analogy to a SPAunit_vector.)  It is derived from the SPApar_vec class; therefore, it inherits all the functionality of SPApar_vecs. There are very few operations that are unique to SPApar_dir, although several functions are overloaded for SPApar_dirs to make them more efficient. SPApar_dirs are defined in param.hxx.</p><a name="SPAinterval"></a><h2> <span class="mw-headline"> SPAinterval </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAinterval.html class="external text">SPAinterval</a></b> is an interval on the real line.  A SPAinterval may be bounded or unbounded at either end, allowing a SPAinterval to represent a finite, infinite, or semi-infinite interval.  SPAintervals are defined in interval.hxx.</p><blockquote class="templatequote"><div><p><i><b>Note:</b>  We should probably explain what it means to negate an interval.  If we start with the bounded interval (1, 2) and negate it, we get the interval (-2, -1).  This implies that not only are the lower and upper bounds negated, but they are also swapped.  The lower and upper bounds of an interval must be in a non-decreasing order.</i></p></div></blockquote><a name="SPAbox"></a><h2> <span class="mw-headline"> SPAbox </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPAbox.html class="external text">SPAbox</a></b> represents a bounding box. It is implemented as an axis-aligned rectangular box, represented by three intervals.  Each interval may be bounded or unbounded at either end, allowing a SPAbox to represent a finite, infinite, or semi-infinite bounding box.  SPAboxes are defined in box.hxx.</p><p>Bounding boxes are computed for topological ENTITIES only when needed.  That is, their computation is <i>lazy</i>, only upon demand. If an ENTITY is changed, any existing bounding box might be invalid so any such box is deleted; however, once a box is computed, it is saved for subsequent reuse. Boxes are logged for roll back purposes. After a roll back, boxes are set to their previous state.  Bounding boxes are also saved in disk files. </p><blockquote class="templatequote"><div><p><i><b>Note:</b>  Bounding boxes are generally obtained by calling one of the get_box( ) functions described in <a href="/r18/index.php/Tutorial:ACIS_Tutorial_3:_Understanding_and_traversing_ACIS_topology_%28Part_III%29" title="Tutorial:ACIS Tutorial 3: Understanding and traversing ACIS topology (Part III)">Tutorials (Model Topology) Part III</a> rather than by creating them using a constructor.</i></p></div></blockquote><blockquote class="templatequote"><div><p><i><b>Important:</b>  We cannot emphasize enough that the default behavior of ACIS is not to calculate tight bounding boxes.  The bounding box for an ENTITY may be significantly larger than the ENTITY.  The discussion in <a href="/r18/index.php/Tutorial:ACIS_Tutorial_3:_Understanding_and_traversing_ACIS_topology_%28Part_III%29" title="Tutorial:ACIS Tutorial 3: Understanding and traversing ACIS topology (Part III)"> Tutorials (Model Topology) Part III</a>  describes how to obtain tighter bounding boxes.</i></p></div></blockquote><a name="SPApar_box"></a><h2> <span class="mw-headline"> SPApar_box </span></h2><p>A <b><a href=/r18/qref/ACIS/html/classSPApar_box.html class="external text">SPApar_box</a></b> is a 2D bounding box in the parameter-space of a surface.  (This is the parameter-space analogy to a SPAbox.) It is implemented as an axis-aligned rectangular box, represented by two intervals.   SPApar_boxes are defined in param.hxx.</p><blockquote class="templatequote"><div><p><i><b>Note:</b>  Parameter-space boxes are generally obtained from a surface or a face by calling either surface::param_range( ) or sg_get_face_par_box( ) rather than by creating them using a constructor.</i></p></div></blockquote><a name="Laws"></a><h2> <span class="mw-headline"> Laws </span></h2><p>ACIS contains an extensive set of capabities to symbolically represent and solve mathematical functions (equations) using <i>laws</i>.  Laws are beyond the scope of this tutorial - and are probably inappropriate for a new ACIS user - but you should be aware of their existence.  For more information on laws please refer to <a href="/r18/index.php?title=Laws&amp;action=edit" class="new" title="Laws">Laws</a>.</p><a name="A_C.2B.2B_Example"></a><h2> <span class="mw-headline"> A C++ Example </span></h2><p>Now that we have introduced you to ACIS topology, geometry, and some math classes, let's put this all together in an example that creates a very simple model and interrogates it.  We shall start by creating a wire body that consists of four straight edges that form a closed loop.  We shall cover this wire body with a face, thereby converting the wire body into a sheet body.  The geometry underlying the face will be a bilinear b-spline surface.  We shall then split the face along an isoparametric curve.  We shall make geometric queries of the model before and after the face split operation to exercise our mathematical classes.</p><table class="wikitable collapsible" width="100%"><tr><th> Code. C++ Example</th></tr><tr><td><pre class="source-cpp"><span class="kw2">#include</span> &lt;stdio.<span class="me1">h</span>&gt;<span class="kw2">#include</span> <span class="st0">&quot;acis.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;api.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;api.err&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;kernapi.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;cstrapi.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;coverapi.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;boolapi.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;lists.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;alltop.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;get_top.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;faceutil.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;param.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;vector.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;unitvec.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;surface.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;surdef.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;box.hxx&quot;</span><span class="kw2">#include</span> <span class="st0">&quot;getbox.hxx&quot;</span>&nbsp;<span class="co1">// Declaration of the ACIS licensing function.</span><span class="kw4">void</span> unlock_spatial_products_963<span class="br0">&#40;</span><span class="br0">&#41;</span>;&nbsp;<span class="co1">// Declaration of our functions.</span><span class="kw4">int</span> do_something<span class="br0">&#40;</span><span class="br0">&#41;</span>;<span class="kw4">void</span> my_debug_face<span class="br0">&#40;</span><span class="kw7">FACE</span>*<span class="br0">&#41;</span>;<span class="kw4">int</span> my_initialization<span class="br0">&#40;</span><span class="br0">&#41;</span>;<span class="kw4">int</span> my_termination<span class="br0">&#40;</span><span class="br0">&#41;</span>;&nbsp;<span class="co1">// Define a macro to check the outcome of API functions.</span><span class="co1">// In the event of an error this macro will</span><span class="co1">// print an error message and propagate the error.</span><span class="kw2">#define</span> CHECK_RESULT                                             \	<span class="kw1">if</span> <span class="br0">&#40;</span>!result.<span class="me1">ok</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>                                      \		<span class="kw7">err_mess_type</span> err_no = result.<span class="me1">error_number</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;    \		<span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;ACIS ERROR&nbsp;%d:&nbsp;%s<span class="es0">\n</span>&quot;</span>,                    \			err_no, find_err_mess<span class="br0">&#40;</span>err_no<span class="br0">&#41;</span><span class="br0">&#41;</span>;          \		sys_error<span class="br0">&#40;</span>err_no<span class="br0">&#41;</span>;                               \	<span class="br0">&#125;</span>&nbsp;<span class="co1">// The main program...</span><span class="kw4">int</span> main <span class="br0">&#40;</span><span class="kw4">int</span> <span class="kw7">argc</span>, <span class="kw4">char</span>** <span class="kw7">argv</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>&nbsp;	<span class="kw4">int</span> ret_val = my_initialization<span class="br0">&#40;</span><span class="br0">&#41;</span>;	<span class="kw1">if</span> <span class="br0">&#40;</span>ret_val<span class="br0">&#41;</span> 		<span class="kw1">return</span> <span class="nu0">1</span>;&nbsp;	ret_val = do_something<span class="br0">&#40;</span><span class="br0">&#41;</span>;	<span class="kw1">if</span> <span class="br0">&#40;</span>ret_val<span class="br0">&#41;</span>		<span class="kw1">return</span> <span class="nu0">1</span>;&nbsp;	ret_val = my_termination<span class="br0">&#40;</span><span class="br0">&#41;</span>;	<span class="kw1">if</span> <span class="br0">&#40;</span>ret_val<span class="br0">&#41;</span>		<span class="kw1">return</span> <span class="nu0">1</span>;&nbsp;	<span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;Program completed successfully<span class="es0">\n</span><span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;	<span class="kw1">return</span> <span class="nu0">0</span>;<span class="br0">&#125;</span>&nbsp;<span class="kw4">int</span> do_something<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>&nbsp;	<span class="kw6">API_BEGIN</span>&nbsp;		<span class="co1">// Create a polygonal wire body from an array of positions.</span>		<span class="co1">// The first point is the same as the last to create a closed wire.</span>&nbsp;		<span class="kw5">SPAposition</span> * pos_array = <span class="kw6">ACIS_NEW</span> <span class="kw5">SPAposition</span><span class="br0">&#91;</span><span class="nu0">5</span><span class="br0">&#93;</span>;		pos_array<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> = <span class="kw5">SPAposition</span><span class="br0">&#40;</span><span class="nu0">-5.0</span>, <span class="nu0">-5.0</span>, <span class="nu0">-1.0</span><span class="br0">&#41;</span>;		pos_array<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> = <span class="kw5">SPAposition</span><span class="br0">&#40;</span><span class="nu0">-5.0</span>,  <span class="nu0">5.0</span>,  <span class="nu0">1.0</span><span class="br0">&#41;</span>;		pos_array<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span> = <span class="kw5">SPAposition</span><span class="br0">&#40;</span> <span class="nu0">5.0</span>,  <span class="nu0">5.0</span>, <span class="nu0">-1.0</span><span class="br0">&#41;</span>;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?