标签:term rms ota har val dir stand 创建 集合
gp是几何处理程序包(Geometric Processor package),简称gp。包gp提供以下功能:
这些实体同时在二维和三维空间中定义,且包中的类都是非持续的(non-persistent),即这些类的实例都是以值的方式处理而不是引用。当复制这种对象时,是对象本体。改变一个实例不会影响到其他的实例。
可用的几何实体如下所示:
创建几何对象之前,根据你是将几何对象用于二维还是三维来确定。若你需要一个几何对象集而不是单一的几何对象,即用来处理一类几何元素,包TColgp就是提供这种功能的。
Package TColgp提供类如:XY, XYZ, Pnt, Pnt2d, Vec, Vec2d, Lin, Lin2D, Circ, Circ2d的TCollection的实例。包中的类简单列举如下:
个人意见,若使用标准C++的容器类(The STL Template Container),就不需要创建这么多类了。
有几个库提供了曲线和曲面的基本计算功能。若要处理由包gp创建的几何对象,初等曲线曲面的有用算法库在包:ElCLib和ElSLib中。包Precision提供两个数字比较的功能。
//------------------------------------------------------------------------------ // Copyright (c) 2012 eryar All Rights Reserved. // // File : Main.cpp // Author : eryar@163.com // Date : 2012-6-23 21:30 // Version : 1.0v // // Description : Test primitive Geometric Types in OpenCASCADE. // // The Geometric Processor package, called gp. // // The pg package offers classes for both 2D and 3D objects which // are handled by value rather than by reference. When this sort of object // is copied, it is copied entirely. Changes in one instance will not be // reflected in another. // //============================================================================== // Use Toolkit TKernel. #pragma comment(lib,"TKernel.lib") // Use Toolkit TKMath. #pragma comment(lib, "TKMath.lib") #include <gp.hxx> #include <gp_Pnt.hxx> #include <gp_Trsf.hxx> #include <Precision.hxx> void DumpPoint(const gp_Pnt& p); int main(int argc, char* argv[]) { gp_Pnt aPoint(0, 0, 0); // 1. Translate a point in a direction. // The direction determined by a gp_Vec or two gp_Pnt. cout<<"Before translated:"; DumpPoint(aPoint); aPoint.Translate(gp_Pnt(2, 2, 3), gp_Pnt(10, 10, 0)); cout<<"After translated:"; DumpPoint(aPoint); // 2. Rotate a point. // Rotate a point by an axis and the rotate angle. cout<<"Before rotated:"; DumpPoint(aPoint); // Roate 45 degree about Z axis. // Positive angle value will be rotated counterclockwise. aPoint.Rotate(gp::OZ(), PI/4); cout<<"After rotated 45 degree about Z axis:"; DumpPoint(aPoint); // 2.1 Test Package Precision. if (aPoint.X() < Precision::Confusion() && aPoint.X() > -Precision::Confusion()) { cout<<"Point X value:"<<aPoint.X()<<endl; cout<<"Precision::Confusion() value:"<<Precision::Confusion()<<endl; } aPoint.Rotate(gp::OZ(), PI/4); cout<<"After rotate 45 degree about Z axis:"; DumpPoint(aPoint); // 3. Transform a point by gp_Trsf. gp_Trsf transform; transform.SetMirror(gp::OX()); cout<<"Before gp_Trsf:"; DumpPoint(aPoint); aPoint.Transform(transform); cout<<"After gp_Trsf:"; DumpPoint(aPoint); // 4. Mirror a point. // 4.1 Performs the symmetrical transformation of // a point with respect to an axis placement which // is the axis of the symmetry. cout<<"Before mirrored with a symmetric axis:"; DumpPoint(aPoint); aPoint.Mirror(gp::OY()); cout<<"After mirrored with a symmetric axis:"; DumpPoint(aPoint); // 4.2 Performs the symmetrical transformation of // a point with respect to a plane. cout<<"Before mirrored with a symmetric plane:"; DumpPoint(aPoint); aPoint.Mirror(gp::XOY()); cout<<"After mirrored with a symmetric plane"; DumpPoint(aPoint); // 5. Scale a point. aPoint.SetCoord(1, 2, 1); cout<<"Before Scaled:"; DumpPoint(aPoint); /* // Scale point source code... inline void gp_Pnt::Scale (const gp_Pnt& P, const Standard_Real S) { gp_XYZ XYZ = P.coord; XYZ.Multiply (1.0 - S); coord.Multiply (S); coord.Add (XYZ); } */ aPoint.Scale(gp_Pnt(1, 2, 2), 2); cout<<"After Scaled:"; DumpPoint(aPoint); return 0; } /** * Description: Dump point information. */ void DumpPoint( const gp_Pnt& p ) { cout<<"("<<p.X()<<","<<p.Y()<<","<<p.Z()<<")"<<endl; } /* 输出结果如下: 1: Before translated:(0,0,0) 2: After translated:(8,8,-3) 3: Before rotated:(8,8,-3) 4: After rotated 45 degree about Z axis:(8.88178e-016,11.3137,-3) 5: Point X value:8.88178e-016 6: Precision::Confusion() value:1e-007 7: After rotate 45 degree about Z axis:(-8,8,-3) 8: Before gp_Trsf:(-8,8,-3) 9: After gp_Trsf:(-8,-8,3) 10: Before mirrored with a symmetric axis:(-8,-8,3) 11: After mirrored with a symmetric axis:(8,-8,-3) 12: Before mirrored with a symmetric plane:(8,-8,-3) 13: After mirrored with a symmetric plane(8,-8,3) 14: Before Scaled:(1,2,1) 15: After Scaled:(1,2,0) 16: Press any key to continue . . . */
包gp提供了基本的几何元素表示及初等解析几何计算功能。对于几何元素的集合也有自己的类库。对于两个数值的比较采用了邻域比较技术。
标签:term rms ota har val dir stand 创建 集合
原文地址:http://www.cnblogs.com/yaoyu126/p/6900915.html