当前位置: 首页 > wzjs >正文

做网站时随便弄上去的文章怎么删掉seo网站优化培训找哪些

做网站时随便弄上去的文章怎么删掉,seo网站优化培训找哪些,淘宝客做的好的几个网站,自贡建设能源开发有限公司网站Open CASCADE (OCC) 是一个开源的 CAD/CAM/CAE 几何建模内核,它提供了多种容器类来存储和管理数据。下面我将详细介绍 Open CASCADE 中的主要容器类及其使用方法。 1. NCollection 容器 Open CASCADE 提供了一套名为 NCollection 的高效容器模板库,类似…

Open CASCADE (OCC) 是一个开源的 CAD/CAM/CAE 几何建模内核,它提供了多种容器类来存储和管理数据。下面我将详细介绍 Open CASCADE 中的主要容器类及其使用方法。

1. NCollection 容器

Open CASCADE 提供了一套名为 NCollection 的高效容器模板库,类似于 STL 但针对 CAD 应用进行了优化。

1.1 NCollection_Array1 - 一维数组

#include <NCollection_Array1.hxx>
#include <iostream>int main() {// 创建一个包含5个整数的数组,索引从1到5NCollection_Array1<int> arr(1, 5);// 填充数组for (int i = arr.Lower(); i <= arr.Upper(); i++) {arr(i) = i * 10;}// 访问和打印数组元素std::cout << "Array elements:" << std::endl;for (int i = arr.Lower(); i <= arr.Upper(); i++) {std::cout << "arr(" << i << ") = " << arr(i) << std::endl;}// 检查边界try {std::cout << "Attempting to access arr(0): ";std::cout << arr(0) << std::endl; // 这将抛出异常} catch (Standard_OutOfRange&) {std::cout << "Out of range exception caught!" << std::endl;}return 0;
}

1.2 NCollection_List - 双向链表

#include <NCollection_List.hxx>
#include <iostream>int main() {// 创建一个整数链表NCollection_List<int> list;// 添加元素list.Append(10);list.Append(20);list.Append(30);list.Prepend(5); // 在开头添加// 遍历链表std::cout << "List contents:" << std::endl;for (NCollection_List<int>::Iterator it(list); it.More(); it.Next()) {std::cout << it.Value() << std::endl;}// 检查是否包含某个值bool contains20 = list.Contains(20);std::cout << "List contains 20: " << (contains20 ? "true" : "false") << std::endl;// 删除元素list.Remove(20);// 再次遍历std::cout << "List after removing 20:" << std::endl;for (NCollection_List<int>::Iterator it(list); it.More(); it.Next()) {std::cout << it.Value() << std::endl;}return 0;
}

1.3 NCollection_Map - 哈希映射

#include <NCollection_Map.hxx>
#include <NCollection_DefaultHasher.hxx>
#include <iostream>int main() {// 创建一个整数到字符串的映射NCollection_Map<int, NCollection_DefaultHasher<int>> intMap;// 添加元素intMap.Add(1);intMap.Add(2);intMap.Add(3);// 检查元素是否存在std::cout << "Map contains 2: " << (intMap.Contains(2) ? "true" : "false") << std::endl;std::cout << "Map contains 5: " << (intMap.Contains(5) ? "true" : "false") << std::endl;// 遍历映射std::cout << "Map contents:" << std::endl;for (NCollection_Map<int, NCollection_DefaultHasher<int>>::Iterator it(intMap); it.More(); it.Next()) {std::cout << it.Key() << std::endl;}// 删除元素intMap.Remove(2);// 再次检查std::cout << "After removal, map contains 2: " << (intMap.Contains(2) ? "true" : "false") << std::endl;return 0;
}

1.4 NCollection_DataMap - 键值对映射

#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
#include <iostream>int main() {// 创建一个字符串到整数的映射NCollection_DataMap<TCollection_AsciiString, int> strToIntMap;// 添加元素strToIntMap.Bind("one", 1);strToIntMap.Bind("two", 2);strToIntMap.Bind("three", 3);// 访问元素if (strToIntMap.IsBound("two")) {std::cout << "Value for 'two': " << strToIntMap.Find("two") << std::endl;}// 遍历映射std::cout << "DataMap contents:" << std::endl;NCollection_DataMap<TCollection_AsciiString, int>::Iterator it(strToIntMap);for (; it.More(); it.Next()) {std::cout << it.Key() << " => " << it.Value() << std::endl;}// 更新值strToIntMap("two") = 22;// 检查更新std::cout << "Updated value for 'two': " << strToIntMap.Find("two") << std::endl;// 删除元素strToIntMap.UnBind("two");// 检查删除std::cout << "After removal, 'two' exists: " << (strToIntMap.IsBound("two") ? "true" : "false") << std::endl;return 0;
}

2. TCollection 容器

TCollection 是 Open CASCADE 提供的另一组容器类,主要用于字符串处理。

2.1 TColStd_Array1OfReal - 实数数组

#include <TColStd_Array1OfReal.hxx>
#include <iostream>int main() {// 创建一个实数数组,索引从0到4TColStd_Array1OfReal realArray(0, 4);// 填充数组for (int i = realArray.Lower(); i <= realArray.Upper(); i++) {realArray(i) = i * 1.5;}// 访问和打印数组元素std::cout << "Real array elements:" << std::endl;for (int i = realArray.Lower(); i <= realArray.Upper(); i++) {std::cout << "realArray(" << i << ") = " << realArray(i) << std::endl;}// 修改元素realArray(2) = 99.9;// 显示修改后的值std::cout << "Modified realArray(2) = " << realArray(2) << std::endl;return 0;
}

2.2 TColStd_SequenceOfReal - 实数序列

#include <TColStd_SequenceOfReal.hxx>
#include <iostream>int main() {// 创建一个实数序列TColStd_SequenceOfReal realSeq;// 添加元素realSeq.Append(1.1);realSeq.Append(2.2);realSeq.Append(3.3);// 在开头插入realSeq.Prepend(0.0);// 遍历序列std::cout << "Sequence contents:" << std::endl;for (int i = 1; i <= realSeq.Length(); i++) {std::cout << "realSeq(" << i << ") = " << realSeq.Value(i) << std::endl;}// 删除元素realSeq.Remove(2); // 删除第二个元素// 再次遍历std::cout << "Sequence after removal:" << std::endl;for (int i = 1; i <= realSeq.Length(); i++) {std::cout << "realSeq(" << i << ") = " << realSeq.Value(i) << std::endl;}return 0;
}

2.3 TColStd_ListOfInteger - 整数列表

#include <TColStd_ListOfInteger.hxx>
#include <iostream>int main() {// 创建一个整数列表TColStd_ListOfInteger intList;// 添加元素intList.Append(10);intList.Append(20);intList.Append(30);// 在开头插入intList.Prepend(5);// 遍历列表std::cout << "List contents:" << std::endl;TColStd_ListIteratorOfListOfInteger it(intList);for (; it.More(); it.Next()) {std::cout << it.Value() << std::endl;}// 查找元素Standard_Integer toFind = 20;if (intList.Contains(toFind)) {std::cout << "List contains " << toFind << std::endl;} else {std::cout << "List does not contain " << toFind << std::endl;}// 删除元素intList.Remove(toFind);// 再次检查std::cout << "After removal, list contains " << toFind << ": " << (intList.Contains(toFind) ? "true" : "false") << std::endl;return 0;
}

3. 几何容器

Open CASCADE 还提供了一些专门用于几何数据的容器。

3.1 TColgp_Array1OfPnt - 点数组

#include <TColgp_Array1OfPnt.hxx>
#include <gp_Pnt.hxx>
#include <iostream>int main() {// 创建一个包含3个点的数组TColgp_Array1OfPnt points(1, 3);// 填充点points.SetValue(1, gp_Pnt(0, 0, 0));points.SetValue(2, gp_Pnt(1, 0, 0));points.SetValue(3, gp_Pnt(1, 1, 0));// 访问和打印点std::cout << "Point array contents:" << std::endl;for (int i = points.Lower(); i <= points.Upper(); i++) {gp_Pnt p = points.Value(i);std::cout << "Point " << i << ": (" << p.X() << ", " << p.Y() << ", " << p.Z() << ")" << std::endl;}// 修改点points(2).SetY(2.0);// 显示修改后的点gp_Pnt modified = points.Value(2);std::cout << "Modified point 2: (" << modified.X() << ", " << modified.Y() << ", " << modified.Z() << ")" << std::endl;return 0;
}

3.2 TColGeom_Array1OfBSplineCurve - B样条曲线数组

#include <TColGeom_Array1OfBSplineCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>int main() {// 创建控制点TColgp_Array1OfPnt poles(1, 4);poles.SetValue(1, gp_Pnt(0, 0, 0));poles.SetValue(2, gp_Pnt(1, 1, 0));poles.SetValue(3, gp_Pnt(2, 1, 0));poles.SetValue(4, gp_Pnt(3, 0, 0));// 创建节点和重数TColStd_Array1OfReal knots(1, 2);knots.SetValue(1, 0.0);knots.SetValue(2, 1.0);TColStd_Array1OfInteger mults(1, 2);mults.SetValue(1, 4);mults.SetValue(2, 4);// 创建B样条曲线Handle(Geom_BSplineCurve) curve1 = new Geom_BSplineCurve(poles, knots, mults, 3);// 创建另一个曲线poles.SetValue(2, gp_Pnt(1, 2, 0));Handle(Geom_BSplineCurve) curve2 = new Geom_BSplineCurve(poles, knots, mults, 3);// 创建B样条曲线数组TColGeom_Array1OfBSplineCurve curves(1, 2);curves.SetValue(1, curve1);curves.SetValue(2, curve2);// 访问曲线Handle(Geom_BSplineCurve) firstCurve = curves.Value(1);gp_Pnt startPoint = firstCurve->Value(firstCurve->FirstParameter());gp_Pnt endPoint = firstCurve->Value(firstCurve->LastParameter());// 打印曲线信息std::cout << "First curve:" << std::endl;std::cout << "  Start point: (" << startPoint.X() << ", " << startPoint.Y() << ", " << startPoint.Z() << ")" << std::endl;std::cout << "  End point: (" << endPoint.X() << ", " << endPoint.Y() << ", " << endPoint.Z() << ")" << std::endl;return 0;
}

4. 高级容器操作

4.1 容器间的转换

#include <TColStd_ListOfInteger.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <NCollection_List.hxx>
#include <iostream>int main() {// 创建一个NCollection列表NCollection_List<int> nList;nList.Append(1);nList.Append(2);nList.Append(3);// 转换为TColStd列表TColStd_ListOfInteger tList;for (NCollection_List<int>::Iterator it(nList); it.More(); it.Next()) {tList.Append(it.Value());}// 转换为序列TColStd_SequenceOfInteger seq;TColStd_ListIteratorOfListOfInteger it(tList);for (; it.More(); it.Next()) {seq.Append(it.Value());}// 打印序列内容std::cout << "Sequence converted from NCollection list:" << std::endl;for (int i = 1; i <= seq.Length(); i++) {std::cout << seq.Value(i) << " ";}std::cout << std::endl;return 0;
}

5. 性能考虑

Open CASCADE 容器与 STL 容器的选择:

  1. NCollection vs STL:

    • NCollection 针对 CAD 数据进行了优化
    • 内存管理更符合 Open CASCADE 的整体架构
    • 与 Open CASCADE 其他类集成更好
  2. 何时使用 STL:

    • 需要与标准 C++ 代码交互时
    • 需要 STL 特定算法时
    • 性能测试显示 STL 在特定场景下更优时

总结

Open CASCADE 提供了丰富的容器类,包括:

  1. NCollection 容器:通用模板容器,类似 STL 但针对 CAD 优化
  2. TCollection 容器:主要用于字符串和基本数据类型
  3. 几何专用容器:如 TColgp_Array1OfPnt 等,用于几何数据

选择容器时应考虑:

  • 数据类型和大小
  • 需要的操作(随机访问、插入、删除等)
  • 性能要求
  • 与其他 Open CASCADE 类的互操作性

以上代码示例展示了各种容器的创建、填充、访问、修改和遍历操作,涵盖了 Open CASCADE 容器的主要功能。

http://www.dtcms.com/wzjs/180680.html

相关文章:

  • 鹰潭市网站建设人民日报今天新闻
  • 超值的郑州网站建设网站建设工作总结
  • 公司做网站的费用怎么账务处理网络营销个人感悟小结
  • 有域名了 怎么做网站b站引流推广
  • 服饰网站建设我赢网提供的高水平网页设计师
  • 做网站的做app的优化网站关键词的技巧
  • 怎么做网站的搜索功能百度搜图匹配相似图片
  • 怎么给网站做后台广告信息发布平台
  • 网站排名怎么做的最新军事动态
  • 中职电子商务网站建设与维护考试题最佳搜索引擎磁力王
  • 如何添加网站关键词郑州网络营销策划
  • 沈阳网站关键词优化做的好吗seo页面内容优化
  • 做模特的网站百度爱采购推广平台
  • 旅游网站系统建设种子资源地址
  • 360网站卖东西怎么做的百度网站名称及网址
  • 有自己网站做淘宝客赚钱吗百度收录检测
  • 重庆建设教育培训管理系统网站广告优化师培训
  • 武汉做网站冰洁找到冰洁工作室我想做地推怎么找渠道
  • 和狗做的网站网络推广运营是做什么
  • 如何做自己的视频网站查找关键词的工具叫什么
  • 阿里巴巴网站建设的背景网络营销的基本内容有哪些
  • 做简历网站 39网站建设的好公司
  • 阿里云wordpress进不去简述seo和sem的区别与联系
  • 建设一个网站需要那些技术优化师和运营区别
  • 做cpa的网站源码seo优化排名工具
  • 建设网站后怎么发布全网营销系统是干什么的
  • 怎么用ps做网站首页背景图片搜索引擎推广有哪些
  • 用哪个网站做相册视频文件软文推广营销
  • 做网站 郑州公司哪家好网络营销好学吗
  • 网站开发怎么报价北京网站排名seo