7.3.2.2模板的存储结构


                                

       模板由若干个组件构成,每一个组件都必须是一个闭合环。通过组件的 parent 属性来指定两个组件的包含关系,从而提供对空洞的定义。

闭合环一般由线、弧和圆来定义,可以分为以下几种情况,

                   

         椭圆组件只包含一个椭圆对象。

         线组件由首尾相连的线段定义。

        线弧组件由首尾相连的线和弧共同定义。

        可见,目前构成组件的基本几何分为,

              

         组件的 parent 属性则表示实体由子过渡到父的区域应该被填充。

         我们通过下面的代码可以创建一个圆环,

           

1.	auto uor = ISessionMgr::GetActiveDgnModelP()->GetModelInfo().GetUorPerMeter();  
2.	  
3.	auto library = CIM::CIMTemplate::ITemplateLibrary::Create();  
4.	auto category = library->AddCategory(L"UseCase");  
5.	auto t = category->AddTemplate(L"swimring");  
6.	  
7.	auto center = t->AddPoint(0, 0);  
8.	double radius0 = 20 * uor;  
9.	double radius1 = 10 * uor;  
10.	  
11.	auto outer = t->AddComponent();  
12.	outer->AddEllipse(center->GetName().GetWCharCP(), radius0, radius0);            
13.	  
14.	auto inner = t->AddComponent();  
15.	inner->AddEllipse(center->GetName().GetWCharCP(), radius1, radius1);            
16.	  
17.	inner->SetParent(outer->GetName().GetWCharCP());  
18.	  
19.	auto curve = t->ToCurveVector();  

          如图: