Opencascade interpolations and approximations

Source: Internet
Author: User
<span id="Label3"></p>Opencascade interpolations and approximations<p align="center"><p align="center"><span class="__cf_email__" data-cfemail="701502091102304146435e131f1d">[email protected]</span></p></p><p><p><strong>Abstract.</strong> In modeling, it's often required to approximate or interpolate points to curves and Surfaces. In interpolation, the process was complete when the curve or surface passes through all the points; In approximation, while it is as close to these points as Possible. The paper is the translation of the Opencascade Modeling Data user Guide.</p></p><p><p><strong>Key Words.</strong> interpolation, approximation, Fitting</p></p><p><p><span style="font-size: 14pt;">1.Introduction</span></p></p><p><p>In geometric modeling, it is often necessary to fit (interpolate interpolation or approximate approximation) curved surfaces according to Points. interpolation requires that the resulting curve or surface must pass through all fitting points, while approximation requires that the resulting curve or surface be fitted as close as possible to all fitting points. The features of curved surface fitting are provided in opencascade:</p></p><p><p>V to interpolate two-dimensional b-spline or Bezier curve on two-dimension points;</p></p><p><p>V The approximation of two-dimensional b-spline or Bezier curve on two-dimension points;</p></p><p><p>V for three-dimensional point of three-dimensional b-spline or Bezier curve or b-spline surface interpolation;</p></p><p><p>V three-dimensional point of three-dimensional b-spline or Bezier curve or b-spline surface approximation;</p></p><p><p>There are two ways to use the Fit function in a program:</p></p><p><p>V uses advanced Features: provides a simple method call to get Fit results;</p></p><p><p>V uses low-level features: designed for users who want to have more control over the fit;</p></p><p><p>Interpolation and approximation are also the main contents of numerical analysis or calculation methods. Using B-spline as interpolation or approximation function is a specific method in numerical Analysis. Through the study of interpolation and approximation algorithm in opencascade, this paper deepens the understanding of some algorithms, such as the least squares method, the extremum of multivariate functions and other mathematical knowledge.</p></p><p><p>In this paper, we mainly translate the interpolation and approximation parts of Opencascade document modeling Data, and give a code example using its low-level function.</p></p><p><p><span style="font-size: 14pt;">2.Analysis of a set of points</span></p></p><p><p>The class Pequation in package Gprop provides the ability to analyze point sets, point cloud data, and can be used to verify coincidence, collinear, or coplanar in a given range of accuracy, and if the test results are, then the algorithm calculates the coincident points, lines, or polygons of those points. If the detection result is not, The algorithm calculates the bounding box of the point set or point Cloud.</p></p><p><p><span style="font-size: 14pt;">3.Basic Interpolation and approximation</span></p></p><p><p>Package Geom2dapi and Geomapi provide a simple method of fitting (approximation and interpolation).</p></p><p><p>V 2D interpolation: class geom2dapi_interpolate can be used to generate a two-dimensional b-spline curve that passes through a series of points. If necessary, you can also set the corresponding tangent vector and parameters to further constrain the interpolation Curve.</p></p><p><p>V 3D interpolation: class geomapi_interpolate can be used to generate a three-dimensional b-spline curve through a series of points. If necessary, you can also set the corresponding tangent vector and parameters to further constrain the interpolation Curve. Because it is an advanced feature, you need very little code to get the interpolation curve, using the Following:</p></p><pre><pre><span style="color: #000000;"></span>= Interp.curve ();</pre></pre><p><p>V 2D approximation: class Geom2dapi_pointstobspline can be used to generate a two-dimensional b-spline curve that approximates a series of points. You need to define the curve number range, continuity, and Tolerance. The tolerance value is only used to check if there is a coincident point between the approximation points, or if the tangent vector is too small. The approximation curve will be a C2 continuous or 2-time curve, and when there is a tangent vector constraint, the C1 continuous curve will be obtained.</p></p><p><p></p></p><p><p>V 3D approximation: class Geomapi_pointstobspline can be used to generate a three-dimensional b-spline curve that approximates a series of points. You need to define the curve number range, continuity, and Tolerance. The tolerance value is only used to check if there is a coincident point between the approximation points, or if the tangent vector is too small. The approximation curve will be a C2 continuous or 2-time curve, and when there is a tangent vector constraint, the C1 continuous curve will be obtained. The usage of the class is as Follows:</p></p><pre><pre><span style="color: #000000;"></span>= Approx.curve ();</pre></pre><p><p>V Surface approximation: class Geomapi_pointstobsplinesurface can be used to fit a b-spline surface based on a point set.</p></p><p><p><span style="font-size: 14pt;">4.Advanced approximation</span></p></p><p><p>Package Appdef and appparcurves provide low-level functionality that allows for more control over Fitting. Low-level functionality provides the following function interface Apis:</p></p><p><p>V defines the rules for fitting the tangent vectors, which have origin and extremum;</p></p><p><p>V to fit a series of curves in parallel according to their respective parameters;</p></p><p><p>V Smooth fit: generates curves for fairing (faired curve).</p></p><p><p>Note: the package appdef and appparcurves through the macro definition to achieve a similar polymorphic function, but the program debugging inconvenient, resulting in some class names do not see the declaration file, the understanding of the program caused some inconvenience.</p></p><p><p><span style="font-size: 12pt;"><strong>4.1 Approximation by multiple point constraints</strong></span></p></p><p><p>The low-level tools available in package appdef are used to fit Bezier or b-spline curves with constrained point sets. Among the features Are:</p></p><p><p>V defines a set of constraint points, using class appdef_multipointconstraint;</p></p><p><p>V defines a set of constraint lines, using class appdef_multiline;</p></p><p><p>V to fit Bézier curve, using class appdef_compute;</p></p><p><p>V Fitting b-spline curve, using class appdef_bsplinecompute;</p></p><p><p>V Definition of variational criteria variational criteria;</p></p><p><p>Note: variational optimization variational optimizations can be seen in class Appdef_variational. For the people who come out of the engineering, these concepts are really some strange, or the people who study maths is bad!</p></p><p><p>The usage of the class appdef_multiline is also somewhat special, which is understood by the diagram in the Document:</p></p><p><p></p></p><p><p>Among them: Pi, Qi, Ri, ..., si can be two-dimensional point or three-dimensional point;</p></p><p><p>Defined by group, where pn, Qn, Rn, ..., sn are defined in class appdef_multipointconstraint;</p></p><p><p>P1, P2,.., PN or q, R,..., S point series are used to Fit.</p></p><p><p>The Quasi-appdef_compute is fitted with a Bezier curve to fit points;</p></p><p><p>The class Appdef_bsplinecompute is fitted with a b-spline curve;</p></p><p><p>Note: the use of Appdef_multipointconstraint and appdef_multiline needs to be carefully understood.</p></p><p><p><span style="font-size: 12pt;"><strong>4.2 example:how to approximate a curve with low-level tools</strong></span></p></p><p><p>The process of using low-level features can be divided into the following steps:</p></p><p><p>V Define fitting point;</p></p><p><p>V creates a multiline based on the fitting point;</p></p><p><p>V use Appdef_compute or appdef_bsplinecompute to fit the curve;</p></p><p><p>Here's A code example that uses low-level functionality:</p></p><pre><span style="color: #008000;"><span style="color: #008000;">/*</span></span><span style="color: #008000;"><span style="color: #008000;">* Copyright (c) Shing Liu All rights reserved.** file:main.cpp* author:shing Liu (email Protected]) * DATE:2016-03-17 21:00* version:opencascade6.9.0** description:test the low-level to OLS of Approximation.</span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">#define</span></span>Wnt<span style="color: #000000;"><span style="color: #000000;">#include</span></span><TColgp_Array1OfPnt.hxx><span style="color: #000000;"><span style="color: #000000;">#include</span></span><AppDef_MultiPointConstraint.hxx><span style="color: #000000;"><span style="color: #000000;">#include</span></span><AppDef_MultiLine.hxx><span style="color: #000000;"><span style="color: #000000;">#include</span></span><AppDef_Compute.hxx><span style="color: #000000;"><span style="color: #000000;">#include</span></span><AppDef_BSplineCompute.hxx><span style="color: #0000ff;"><span style="color: #0000ff;">#pragma</span></span>Comment (lib, "TKernel.lib")<span style="color: #0000ff;"><span style="color: #0000ff;">#pragma</span></span>Comment (lib, "TKMath.lib")<span style="color: #0000ff;"><span style="color: #0000ff;">#pragma</span></span>Comment (lib, "TKGeomBase.lib")<span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">Testbezierapprox () {tcolgp_array1ofpnt apoints (</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span>,<span style="color: #800080;"><span style="color: #800080;">3</span></span><span style="color: #000000;"><span style="color: #000000;">); Apoints.setvalue (</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Apoints.setvalue (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Apoints.setvalue (</span></span><span style="color: #800080;"><span style="color: #800080;">3</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Appdef_multiline Amultiline (apoints); Appdef_compute Abezierapprox (amultiline); Abezierapprox.value (). Dump (std::cout);}</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">Testbsplineapprox () {appdef_multiline amultiline (</span></span><span style="color: #800080;"><span style="color: #800080;">3</span></span><span style="color: #000000;"><span style="color: #000000;">); Appdef_multipointconstraint aMPC1 (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>,<span style="color: #800080;"><span style="color: #800080;">0</span></span><span style="color: #000000;"><span style="color: #000000;">); Appdef_multipointconstraint aMPC2 (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>,<span style="color: #800080;"><span style="color: #800080;">0</span></span><span style="color: #000000;"><span style="color: #000000;">); Appdef_multipointconstraint AMPC3 (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>,<span style="color: #800080;"><span style="color: #800080;">0</span></span><span style="color: #000000;"><span style="color: #000000;">); Ampc1.setpoint (</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Ampc1.setpoint (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">2.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Ampc2.setpoint (</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Ampc2.setpoint (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">2.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Ampc3.setpoint (</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">0.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Ampc3.setpoint (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>, Gp_pnt (<span style="color: #800080;"><span style="color: #800080;">1.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">3.0</span></span>,<span style="color: #800080;"><span style="color: #800080;">1.0</span></span><span style="color: #000000;"><span style="color: #000000;">)); Amultiline.setvalue (</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span><span style="color: #000000;"><span style="color: #000000;">, aMPC1); Amultiline.setvalue (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span><span style="color: #000000;"><span style="color: #000000;">, aMPC2); Amultiline.setvalue (</span></span><span style="color: #800080;"><span style="color: #800080;">3</span></span><span style="color: #000000;"><span style="color: #000000;">, aMPC3); Appdef_bsplinecompute Absplineapprox (amultiline); Absplineapprox.value (). Dump (std::cout);}</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">int</span></span>Main<span style="color: #0000ff;"><span style="color: #0000ff;">int</span></span>argc<span style="color: #0000ff;"><span style="color: #0000ff;">Char</span></span>*<span style="color: #000000;"><span style="color: #000000;">Argv[]) {testbezierapprox (); Testbsplineapprox (); </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">return</span></span> <span style="color: #800080;"><span style="color: #800080;">0</span></span><span style="color: #000000;"><span style="color: #000000;">;}</span></span></pre><p><p>The results of the program run are as Follows:</p></p><p><p></p></p><p><p><span style="font-size: 14pt;">5.Conclusion</span></p></p><p><p>The interpolation and approximation of points are the concerns in data approximation or numerical analysis or computational methods. From the document you can see some of the keywords in package appdef: Gradient, BFGS, leastsquare, etc., According to these keywords can be seen in opencascade approximation of the algorithm Used.</p></p><p><p></p></p><p><p>By using low-level interfaces such as Appdef_multipointconstraint and appdef_multiline, the output of the input and fitting results of the Quasi-composite data base is Understood. And then to learn the application of bfgs, leastsquare and other mathematical theory tools in Practice. For the concepts of multivariate functions, gradients and BFGS are acceptable, the theory of variational optimization is beyond the scope of engineering mathematics, but it should be more efficient to study these concepts in PRACTICE.</p></p><p><p>Opencascade interpolations and approximations</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.