├── .gitignore
├── AnyFeatures.png
├── AnyFeatures.sln
├── AnyFeatures.suo
├── AnyFeatures
├── AnyFeatures.csproj
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── packages.config
├── Features.Comprehensive
├── Algorithm
│ ├── FindInnerWiresFromShape.cs
│ ├── RemoveExtraEdges.cs
│ ├── SkeletonFromStep.cs
│ └── SurfaceSection.cs
├── Boolean
│ ├── ExtrudeBoolean.cs
│ └── SplitSTL.cs
├── ComprehensiveModule.cs
├── FEA
│ ├── PostProcess.cs
│ └── PostProcessHex20.cs
├── Features.Comprehensive.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Features.Core
├── Feature.cs
├── FeatureContext.cs
├── FeatureManager.cs
├── Features.Core.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Features.Modeling
├── Algorithm
│ ├── Intersections.cs
│ ├── MakeSplit.cs
│ ├── Projection.cs
│ └── SurfaceSection.cs
├── Boolean
│ ├── MakeCut.cs
│ ├── MakeGlue.cs
│ ├── MakeSection.cs
│ └── MakeSplitCurve.cs
├── Featured
│ ├── MakeEvolved.cs
│ ├── MakeFillet.cs
│ ├── MakeHoles.cs
│ ├── MakeLoft.cs
│ ├── MakePipe.cs
│ ├── MakeRevole.cs
│ └── MakeSweep.cs
├── Features.Modeling.csproj
├── Geometry
│ ├── CurveLength.cs
│ ├── QueryCurve.cs
│ ├── QuerySurface.cs
│ ├── SolidVolumn.cs
│ └── SurfaceArea.cs
├── ModelingModule.cs
├── Primitive
│ ├── Box.cs
│ ├── Primitive.cs
│ ├── RectTube.cs
│ ├── RectangleR.cs
│ ├── Sphere.cs
│ ├── Spiral.cs
│ └── Surface.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Features.Rendering
├── Animation
│ └── DancingBall.cs
├── Camera
│ ├── PerspectiveTest.cs
│ └── StdCameraTest.cs
├── Features.Rendering.csproj
├── Import
│ ├── ImportDXF.cs
│ ├── ImportIges.cs
│ ├── ImportStep.cs
│ └── ImportStl.cs
├── ManageScene
│ ├── ListNodes.cs
│ ├── QuerySelection.cs
│ └── RemoveNode.cs
├── NodeObject
│ ├── ArrowNode.cs
│ ├── AxesNode.cs
│ ├── ColoredFace.cs
│ ├── PointCloud.cs
│ ├── PointMarker.cs
│ ├── ShapeCopies.cs
│ └── Text3dObject.cs
├── Properties
│ └── AssemblyInfo.cs
├── RenderStyle
│ ├── FaceStyleTest.cs
│ └── LineStyleTest.cs
├── RenderingModule.cs
└── packages.config
├── README.md
└── bin
└── Readme.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | /.vs
4 | /packages
5 |
--------------------------------------------------------------------------------
/AnyFeatures.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/anycad.net.pro.AppFeatures/297007c87940205c449d3308b230d0e7afdff1c3/AnyFeatures.png
--------------------------------------------------------------------------------
/AnyFeatures.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyFeatures", "AnyFeatures\AnyFeatures.csproj", "{5C5FC490-B74F-4C40-9460-A355A820C6C2}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features.Modeling", "Features.Modeling\Features.Modeling.csproj", "{9B7597AF-D934-42B9-9773-8A66BFAB9C40}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features.Core", "Features.Core\Features.Core.csproj", "{C3DEEB62-2C24-41FC-823F-28B0B8AB303B}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features.Comprehensive", "Features.Comprehensive\Features.Comprehensive.csproj", "{3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Features.Rendering", "Features.Rendering\Features.Rendering.csproj", "{E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|x64 = Debug|x64
17 | Release|x64 = Release|x64
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {5C5FC490-B74F-4C40-9460-A355A820C6C2}.Debug|x64.ActiveCfg = Debug|x64
21 | {5C5FC490-B74F-4C40-9460-A355A820C6C2}.Debug|x64.Build.0 = Debug|x64
22 | {5C5FC490-B74F-4C40-9460-A355A820C6C2}.Release|x64.ActiveCfg = Release|x64
23 | {5C5FC490-B74F-4C40-9460-A355A820C6C2}.Release|x64.Build.0 = Release|x64
24 | {9B7597AF-D934-42B9-9773-8A66BFAB9C40}.Debug|x64.ActiveCfg = Debug|x64
25 | {9B7597AF-D934-42B9-9773-8A66BFAB9C40}.Debug|x64.Build.0 = Debug|x64
26 | {9B7597AF-D934-42B9-9773-8A66BFAB9C40}.Release|x64.ActiveCfg = Release|x64
27 | {9B7597AF-D934-42B9-9773-8A66BFAB9C40}.Release|x64.Build.0 = Release|x64
28 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}.Debug|x64.ActiveCfg = Debug|x64
29 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}.Debug|x64.Build.0 = Debug|x64
30 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}.Release|x64.ActiveCfg = Release|x64
31 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}.Release|x64.Build.0 = Release|x64
32 | {3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}.Debug|x64.ActiveCfg = Debug|x64
33 | {3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}.Debug|x64.Build.0 = Debug|x64
34 | {3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}.Release|x64.ActiveCfg = Release|x64
35 | {3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}.Release|x64.Build.0 = Release|x64
36 | {E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}.Debug|x64.ActiveCfg = Debug|x64
37 | {E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}.Debug|x64.Build.0 = Debug|x64
38 | {E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}.Release|x64.ActiveCfg = Release|x64
39 | {E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}.Release|x64.Build.0 = Release|x64
40 | EndGlobalSection
41 | GlobalSection(SolutionProperties) = preSolution
42 | HideSolutionNode = FALSE
43 | EndGlobalSection
44 | EndGlobal
45 |
--------------------------------------------------------------------------------
/AnyFeatures.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anycad/anycad.net.pro.AppFeatures/297007c87940205c449d3308b230d0e7afdff1c3/AnyFeatures.suo
--------------------------------------------------------------------------------
/AnyFeatures/AnyFeatures.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x64
7 | 8.0.30703
8 | 2.0
9 | {5C5FC490-B74F-4C40-9460-A355A820C6C2}
10 | WinExe
11 | Properties
12 | AnyFeatures
13 | AnyFeatures
14 | v4.0
15 | Client
16 | 512
17 |
18 |
19 |
20 |
21 | x64
22 | true
23 | full
24 | false
25 | ..\bin\x64\Debug\
26 | DEBUG;TRACE
27 | prompt
28 | 4
29 |
30 |
31 | x64
32 | pdbonly
33 | true
34 | ..\bin\x64\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 |
41 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Exchange.Net.dll
42 |
43 |
44 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Foundation.Net.dll
45 |
46 |
47 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Presentation.Net.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | Form
63 |
64 |
65 | MainForm.cs
66 |
67 |
68 |
69 |
70 | MainForm.cs
71 |
72 |
73 | ResXFileCodeGenerator
74 | Resources.Designer.cs
75 | Designer
76 |
77 |
78 | True
79 | Resources.resx
80 |
81 |
82 |
83 | SettingsSingleFileGenerator
84 | Settings.Designer.cs
85 |
86 |
87 | True
88 | Settings.settings
89 | True
90 |
91 |
92 |
93 |
94 | {3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}
95 | Features.Comprehensive
96 |
97 |
98 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}
99 | Features.Core
100 |
101 |
102 | {9B7597AF-D934-42B9-9773-8A66BFAB9C40}
103 | Features.Modeling
104 |
105 |
106 | {E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}
107 | Features.Rendering
108 |
109 |
110 |
111 |
112 |
113 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
114 |
115 |
116 |
117 |
124 |
--------------------------------------------------------------------------------
/AnyFeatures/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace AnyFeatures
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.menuStrip1 = new System.Windows.Forms.MenuStrip();
32 | this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
33 | this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
34 | this.queryMultiSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
35 | this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
36 | this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
37 | this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
38 | this.statusStrip1 = new System.Windows.Forms.StatusStrip();
39 | this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
40 | this.splitContainer1 = new System.Windows.Forms.SplitContainer();
41 | this.treeView1 = new System.Windows.Forms.TreeView();
42 | this.pickByRectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
43 | this.pickByClickToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
44 | this.menuStrip1.SuspendLayout();
45 | this.statusStrip1.SuspendLayout();
46 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
47 | this.splitContainer1.Panel1.SuspendLayout();
48 | this.splitContainer1.SuspendLayout();
49 | this.SuspendLayout();
50 | //
51 | // menuStrip1
52 | //
53 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
54 | this.fileToolStripMenuItem,
55 | this.viewToolStripMenuItem,
56 | this.editToolStripMenuItem,
57 | this.helpToolStripMenuItem});
58 | this.menuStrip1.Location = new System.Drawing.Point(0, 0);
59 | this.menuStrip1.Name = "menuStrip1";
60 | this.menuStrip1.Size = new System.Drawing.Size(849, 25);
61 | this.menuStrip1.TabIndex = 0;
62 | this.menuStrip1.Text = "menuStrip1";
63 | //
64 | // fileToolStripMenuItem
65 | //
66 | this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
67 | this.fileToolStripMenuItem.Size = new System.Drawing.Size(39, 21);
68 | this.fileToolStripMenuItem.Text = "File";
69 | //
70 | // viewToolStripMenuItem
71 | //
72 | this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
73 | this.queryMultiSelectionToolStripMenuItem});
74 | this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
75 | this.viewToolStripMenuItem.Size = new System.Drawing.Size(47, 21);
76 | this.viewToolStripMenuItem.Text = "View";
77 | //
78 | // queryMultiSelectionToolStripMenuItem
79 | //
80 | this.queryMultiSelectionToolStripMenuItem.Name = "queryMultiSelectionToolStripMenuItem";
81 | this.queryMultiSelectionToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
82 | this.queryMultiSelectionToolStripMenuItem.Text = "Query Multi-Selection";
83 | this.queryMultiSelectionToolStripMenuItem.Click += new System.EventHandler(this.queryMultiSelectionToolStripMenuItem_Click);
84 | //
85 | // editToolStripMenuItem
86 | //
87 | this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
88 | this.pickByRectToolStripMenuItem,
89 | this.pickByClickToolStripMenuItem});
90 | this.editToolStripMenuItem.Name = "editToolStripMenuItem";
91 | this.editToolStripMenuItem.Size = new System.Drawing.Size(42, 21);
92 | this.editToolStripMenuItem.Text = "Edit";
93 | //
94 | // helpToolStripMenuItem
95 | //
96 | this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
97 | this.aboutToolStripMenuItem});
98 | this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
99 | this.helpToolStripMenuItem.Size = new System.Drawing.Size(47, 21);
100 | this.helpToolStripMenuItem.Text = "Help";
101 | //
102 | // aboutToolStripMenuItem
103 | //
104 | this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
105 | this.aboutToolStripMenuItem.Size = new System.Drawing.Size(111, 22);
106 | this.aboutToolStripMenuItem.Text = "About";
107 | //
108 | // statusStrip1
109 | //
110 | this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
111 | this.toolStripStatusLabel1});
112 | this.statusStrip1.Location = new System.Drawing.Point(0, 515);
113 | this.statusStrip1.Name = "statusStrip1";
114 | this.statusStrip1.Size = new System.Drawing.Size(849, 22);
115 | this.statusStrip1.TabIndex = 1;
116 | this.statusStrip1.Text = "statusStrip1";
117 | //
118 | // toolStripStatusLabel1
119 | //
120 | this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
121 | this.toolStripStatusLabel1.Size = new System.Drawing.Size(44, 17);
122 | this.toolStripStatusLabel1.Text = "Ready";
123 | //
124 | // splitContainer1
125 | //
126 | this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
127 | this.splitContainer1.Location = new System.Drawing.Point(0, 25);
128 | this.splitContainer1.Name = "splitContainer1";
129 | //
130 | // splitContainer1.Panel1
131 | //
132 | this.splitContainer1.Panel1.Controls.Add(this.treeView1);
133 | this.splitContainer1.Size = new System.Drawing.Size(849, 490);
134 | this.splitContainer1.SplitterDistance = 197;
135 | this.splitContainer1.TabIndex = 2;
136 | //
137 | // treeView1
138 | //
139 | this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
140 | this.treeView1.Location = new System.Drawing.Point(0, 0);
141 | this.treeView1.Name = "treeView1";
142 | this.treeView1.Size = new System.Drawing.Size(197, 490);
143 | this.treeView1.TabIndex = 0;
144 | this.treeView1.DoubleClick += new System.EventHandler(this.treeView1_DoubleClick);
145 | //
146 | // pickByRectToolStripMenuItem
147 | //
148 | this.pickByRectToolStripMenuItem.Name = "pickByRectToolStripMenuItem";
149 | this.pickByRectToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
150 | this.pickByRectToolStripMenuItem.Text = "Pick by Rect";
151 | this.pickByRectToolStripMenuItem.Click += new System.EventHandler(this.pickByRectToolStripMenuItem_Click);
152 | //
153 | // pickByClickToolStripMenuItem
154 | //
155 | this.pickByClickToolStripMenuItem.Name = "pickByClickToolStripMenuItem";
156 | this.pickByClickToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
157 | this.pickByClickToolStripMenuItem.Text = "Pick by Click";
158 | this.pickByClickToolStripMenuItem.Click += new System.EventHandler(this.pickByClickToolStripMenuItem_Click);
159 | //
160 | // MainForm
161 | //
162 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
163 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
164 | this.ClientSize = new System.Drawing.Size(849, 537);
165 | this.Controls.Add(this.splitContainer1);
166 | this.Controls.Add(this.statusStrip1);
167 | this.Controls.Add(this.menuStrip1);
168 | this.MainMenuStrip = this.menuStrip1;
169 | this.Name = "MainForm";
170 | this.Text = "AnyCAD Features for .Net";
171 | this.Load += new System.EventHandler(this.MainForm_Load);
172 | this.menuStrip1.ResumeLayout(false);
173 | this.menuStrip1.PerformLayout();
174 | this.statusStrip1.ResumeLayout(false);
175 | this.statusStrip1.PerformLayout();
176 | this.splitContainer1.Panel1.ResumeLayout(false);
177 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
178 | this.splitContainer1.ResumeLayout(false);
179 | this.ResumeLayout(false);
180 | this.PerformLayout();
181 |
182 | }
183 |
184 | #endregion
185 |
186 | private System.Windows.Forms.MenuStrip menuStrip1;
187 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
188 | private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
189 | private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
190 | private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
191 | private System.Windows.Forms.StatusStrip statusStrip1;
192 | private System.Windows.Forms.SplitContainer splitContainer1;
193 | private System.Windows.Forms.TreeView treeView1;
194 | private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
195 | private System.Windows.Forms.ToolStripMenuItem queryMultiSelectionToolStripMenuItem;
196 | private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
197 | private System.Windows.Forms.ToolStripMenuItem pickByRectToolStripMenuItem;
198 | private System.Windows.Forms.ToolStripMenuItem pickByClickToolStripMenuItem;
199 | }
200 | }
201 |
202 |
--------------------------------------------------------------------------------
/AnyFeatures/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using AnyCAD.Presentation;
10 | using Features.Core;
11 | using AnyCAD.Platform;
12 |
13 |
14 | namespace AnyFeatures
15 | {
16 | public partial class MainForm : Form
17 | {
18 | private RenderWindow3d m_RenderView = null;
19 | private Feature m_CurrentFeature = null;
20 |
21 | public AnyCAD.Presentation.RenderWindow3d RenderView
22 | {
23 | get { return m_RenderView; }
24 | set { m_RenderView = value; }
25 | }
26 |
27 | public MainForm()
28 | {
29 | InitializeComponent();
30 |
31 | // Add 3D RenderView to container.
32 | var container = this.splitContainer1.Panel2;
33 |
34 | m_RenderView = new RenderWindow3d();
35 |
36 | m_RenderView.Size = container.ClientSize;
37 | m_RenderView.Dock = System.Windows.Forms.DockStyle.Fill;
38 | container.Controls.Add(m_RenderView);
39 |
40 | }
41 |
42 | private void MainForm_Load(object sender, EventArgs e)
43 | {
44 | Features.Modeling.ModelingModule.Initialize();
45 | Features.Rendering.RenderingModule.Initialize();
46 | Features.Comprehensive.ComprehensiveModule.Initialize();
47 |
48 |
49 | Dictionary groupNodes = new Dictionary();
50 | Dictionary categoryNodes = new Dictionary();
51 |
52 | foreach (Feature fe in FeatureManager.Instance().FeatrueList)
53 | {
54 | TreeNode group = null;
55 | if (!groupNodes.TryGetValue(fe.Group, out group))
56 | {
57 | group = this.treeView1.Nodes.Add(fe.Group);
58 | groupNodes.Add(fe.Group, group);
59 | }
60 |
61 | TreeNode category = null;
62 | if (!categoryNodes.TryGetValue(fe.Category, out category))
63 | {
64 | category = group.Nodes.Add(fe.Category);
65 | categoryNodes.Add(fe.Category, category);
66 | }
67 |
68 | TreeNode feNode = category.Nodes.Add(fe.Name);
69 | feNode.Tag = fe;
70 | }
71 | this.treeView1.ExpandAll();
72 | }
73 |
74 | private void treeView1_DoubleClick(object sender, EventArgs e)
75 | {
76 | TreeNode node = this.treeView1.SelectedNode;
77 | if (node == null || node.Tag == null)
78 | return;
79 |
80 | FeatureContext context = new FeatureContext(RenderView);
81 | if (m_CurrentFeature != null)
82 | m_CurrentFeature.OnExit(context);
83 | m_RenderView.ClearScene();
84 | m_CurrentFeature = node.Tag as Feature;
85 | if(m_CurrentFeature.Run(context))
86 | m_RenderView.FitAll();
87 | m_RenderView.RequestDraw();
88 |
89 | this.toolStripStatusLabel1.Text = m_CurrentFeature.Name;
90 | }
91 |
92 | private void queryMultiSelectionToolStripMenuItem_Click(object sender, EventArgs e)
93 | {
94 | TopoShapeGroup group = new TopoShapeGroup();
95 |
96 | MultiShapeQuery query = new MultiShapeQuery();
97 | m_RenderView.QuerySelection(query);
98 | int nCount = query.GetCount();
99 | for (int ii = 0; ii < nCount; ++ii)
100 | {
101 | SelectedShapeQuery shapeQuery = query.GetSubContext(ii);
102 | TopoShape subShape = shapeQuery.GetSubGeometry();
103 | if (subShape != null)
104 | {
105 | group.Add(subShape);
106 | }
107 | }
108 |
109 | // clear the scene and only keep the selected shapes
110 | if (group.Size() > 0)
111 | {
112 | m_RenderView.ClearScene();
113 | for (int ii = 0; ii < group.Size(); ++ii)
114 | {
115 | m_RenderView.ShowGeometry(group.GetAt(ii), 100+ii); ;
116 | }
117 | }
118 | }
119 |
120 | private void pickByRectToolStripMenuItem_Click(object sender, EventArgs e)
121 | {
122 | m_RenderView.ExecuteCommand("RectPick", "");
123 | }
124 |
125 | private void pickByClickToolStripMenuItem_Click(object sender, EventArgs e)
126 | {
127 | m_RenderView.ExecuteCommand("Pick", "");
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/AnyFeatures/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 | 137, 17
125 |
126 |
--------------------------------------------------------------------------------
/AnyFeatures/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace AnyFeatures
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new MainForm());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AnyFeatures/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("AnyFeatures")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AnyFeatures")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("aba70aff-b7e7-4a8a-9b10-494f3a405fb5")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AnyFeatures/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AnyFeatures.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AnyFeatures.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/AnyFeatures/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/AnyFeatures/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AnyFeatures.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AnyFeatures/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AnyFeatures/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Algorithm/FindInnerWiresFromShape.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Comprehensive.Algorithm
11 | {
12 | class FindWireContext : AnyCAD.Platform.TopoShapeReaderContext
13 | {
14 | private LineStyle _LineStyle = new LineStyle();
15 | private FaceStyle _FaceStyle = new FaceStyle();
16 |
17 | private FeatureContext _Context;
18 | public FindWireContext(FeatureContext context)
19 | {
20 | _Context = context;
21 | _LineStyle.SetLineWidth(2);
22 | _LineStyle.SetColor(255, 0, 0);
23 |
24 | _FaceStyle.SetColor(new ColorValue(0.5f, 0.5f, 0.5f, 0.5f));
25 | _FaceStyle.SetTransparent(true);
26 | }
27 |
28 | public override void OnFace(TopoShape shape)
29 | {
30 | WireClassifier wc = new WireClassifier();
31 | if (!wc.Initialize(shape))
32 | return;
33 |
34 | TopoShapeGroup innerWires = wc.GetInnerWires();
35 | int nCount = innerWires.Size();
36 | for (int ii = 0; ii < nCount; ++ii)
37 | {
38 | SceneNode node = _Context.ShowGeometry(innerWires.GetAt(ii));
39 | node.SetLineStyle(_LineStyle);
40 | }
41 |
42 | SceneNode faceNode = _Context.ShowGeometry(shape);
43 | faceNode.SetFaceStyle(_FaceStyle);
44 | }
45 |
46 | public override void OnBeginGroup(string name)
47 | {
48 |
49 | }
50 | public override void OnEndGroup()
51 | {
52 |
53 | }
54 | }
55 |
56 | class FindInnerWiresFromShape : Feature
57 | {
58 | public FindInnerWiresFromShape()
59 | {
60 | Name = "Find InnerWires";
61 | Group = ComprehensiveModule.GroupId;
62 | Category = ComprehensiveModule.AlgorithmCategoryId;
63 | }
64 |
65 | public override bool Run(FeatureContext context)
66 | {
67 | OpenFileDialog dlg = new OpenFileDialog();
68 | dlg.Filter = "Shape File (*.igs;*.iges)|*.iges;*.igs||";
69 | if (DialogResult.OK != dlg.ShowDialog())
70 | return true;
71 |
72 | FindWireContext renderContext = new FindWireContext(context);
73 | IgesReader reader = new IgesReader();
74 | reader.Read(dlg.FileName, renderContext);
75 |
76 | return true;
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Algorithm/RemoveExtraEdges.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 |
9 | namespace Features.Comprehensive.Algorithm
10 | {
11 | class RemoveExtraEdges : Feature
12 | {
13 | public RemoveExtraEdges()
14 | {
15 | Name = "Repair.RemoveExtraEdges";
16 | Group = ComprehensiveModule.GroupId;
17 | Category = ComprehensiveModule.AlgorithmCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | float y = 10;
23 | TopoShape line1 = GlobalInstance.BrepTools.MakeLine(new Vector3(0, 0, 0 + y), new Vector3(4, 0, 0 + y));
24 | TopoShape line2 = GlobalInstance.BrepTools.MakeLine(new Vector3(4, 0, 0 + y), new Vector3(4, 0, 0.5f + y));
25 | TopoShape line3 = GlobalInstance.BrepTools.MakeLine(new Vector3(4, 0, 0.5f + y), new Vector3(1, 0, 0.5f + y));
26 | TopoShape line4 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 0.5f + y), new Vector3(1, 0, 4 + y));
27 | TopoShape line5 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 4 + y), new Vector3(0.5f, 0, 4 + y));
28 | TopoShape line6 = GlobalInstance.BrepTools.MakeLine(new Vector3(0.5f, 0, 4 + y), new Vector3(0.5f, 0, 0.5f + y));
29 | TopoShape line7 = GlobalInstance.BrepTools.MakeLine(new Vector3(0.5f, 0, 0.5f + y), new Vector3(0, 0, 0.5f + y));
30 | TopoShape line8 = GlobalInstance.BrepTools.MakeLine(new Vector3(0, 0, 0.5f + y), new Vector3(0, 0, 0 + y));
31 | TopoShapeGroup shapeGroup = new TopoShapeGroup();
32 |
33 | shapeGroup.Add(line2);
34 | shapeGroup.Add(line3);
35 | shapeGroup.Add(line4);
36 | shapeGroup.Add(line5);
37 | shapeGroup.Add(line6);
38 | shapeGroup.Add(line7);
39 | shapeGroup.Add(line8);
40 | shapeGroup.Add(line1);
41 | TopoShape profile = GlobalInstance.BrepTools.MakeWire(shapeGroup);
42 |
43 | TopoShape line9 = GlobalInstance.BrepTools.MakeLine(new Vector3(0, 0, 0 + y), new Vector3(0, -20, 0 + y));
44 | TopoShapeGroup lineGroup = new TopoShapeGroup();
45 | lineGroup.Add(line9);
46 | TopoShape wire = GlobalInstance.BrepTools.MakeWire(lineGroup);
47 | TopoShape sweep = GlobalInstance.BrepTools.Sweep(profile, wire, true);
48 |
49 |
50 | TopoShape line10 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 0.5f + y), new Vector3(1, 0, 3 + y));
51 | TopoShape line11 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 3 + y), new Vector3(2, 0, 3 + y));
52 | TopoShape line12 = GlobalInstance.BrepTools.MakeLine(new Vector3(2, 0, 3 + y), new Vector3(2, 0, 0.5f + y));
53 | TopoShape line13 = GlobalInstance.BrepTools.MakeLine(new Vector3(2, 0, 0.5f + y), new Vector3(1, 0, 0.5f + y));
54 | TopoShapeGroup shapeGroup1 = new TopoShapeGroup();
55 | shapeGroup1.Add(line10);
56 | shapeGroup1.Add(line11);
57 | shapeGroup1.Add(line12);
58 | shapeGroup1.Add(line13);
59 | TopoShape profile1 = GlobalInstance.BrepTools.MakeWire(shapeGroup1);
60 | TopoShape line14 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 0.5f + y), new Vector3(1, -0.5f, 0.5f + y));
61 | TopoShapeGroup lineGroup1 = new TopoShapeGroup();
62 | lineGroup1.Add(line14);
63 | TopoShape wire1 = GlobalInstance.BrepTools.MakeWire(lineGroup1);
64 |
65 | TopoShape sweep1 = GlobalInstance.BrepTools.Sweep(profile1, wire1, true);
66 |
67 | TopoShape comp = GlobalInstance.BrepTools.BooleanAdd(sweep, sweep1);
68 |
69 | RepairTools rt = new RepairTools();
70 | comp = rt.RemoveExtraEdges(comp);
71 |
72 | context.ShowGeometry(comp);
73 |
74 | return true;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Algorithm/SkeletonFromStep.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Comprehensive.Algorithm
10 | {
11 |
12 | class VertexInfo
13 | {
14 | public int FaceIndex;
15 | public int EdgeIndex;
16 | public int Index;
17 | public Vector3 Point;
18 |
19 | public VertexInfo(Vector3 pt, int vi, int ei, int fi)
20 | {
21 | Point = pt;
22 | Index = vi;
23 | EdgeIndex = ei;
24 | FaceIndex = fi;
25 | }
26 | }
27 | class EdgeInfo
28 | {
29 | public GeomCurve Curve;
30 | public int Index;
31 | public int FaceIndex;
32 | public double Length;
33 | public Vector3 Direction;
34 |
35 | public List Vertices = new List();
36 | public TopoShape GetShape() { return Curve.GetShape(); }
37 | public EdgeInfo(TopoShape edge, int idx, int faceIdx, double length)
38 | {
39 | Curve = new GeomCurve();
40 | Curve.Initialize(edge);
41 | Index = idx;
42 | FaceIndex = faceIdx;
43 | var start = Curve.Value(Curve.FirstParameter());
44 | var end = Curve.Value(Curve.LastParameter());
45 | Direction = end - start;
46 | Direction.Normalize();
47 | Length = length;
48 |
49 | var pts = GlobalInstance.TopoExplor.ExplorVertices(edge);
50 | for(int ii=0; ii Edges = new Dictionary();
66 | public Vector3 Direction;
67 |
68 | public FaceInfo(TopoShape face, int idx, double area)
69 | {
70 | Surface = new GeomSurface();
71 | Surface.Initialize(face);
72 | Index = idx;
73 | Area = area;
74 |
75 | Direction = Surface.GetNormal(Surface.FirstUParameter(), Surface.FirstVParameter());
76 |
77 | TopoShapeProperty prop = new TopoShapeProperty();
78 | var edges = GlobalInstance.TopoExplor.ExplorEdges(face);
79 | for (int jj = 0; jj < edges.Size(); ++jj)
80 | {
81 | var edge = edges.GetAt(jj);
82 | prop.SetShape(edge);
83 | var edgeInfo = new EdgeInfo(edge, jj, idx, prop.EdgeLength());
84 | // 只加直线?
85 | Edges.Add(jj, edgeInfo);
86 | }
87 | }
88 |
89 | public TopoShape GetShape() { return Surface.GetShape(); }
90 |
91 | public EdgeInfo GetEdgeInfo(int idx) { return Edges[idx]; }
92 | }
93 |
94 | class LongFaceEdge
95 | {
96 | public int FaceIdx;
97 | public int EdgeIdx;
98 |
99 | public LongFaceEdge(int faceIdx, int edgeIdx)
100 | {
101 | FaceIdx = faceIdx;
102 | EdgeIdx = edgeIdx;
103 | }
104 | }
105 |
106 | class GroupByDirection
107 | {
108 | public Vector3 Key;
109 |
110 | Vector3 Abs(Vector3 dir)
111 | {
112 | return new Vector3(Math.Abs(dir.X), Math.Abs(dir.Y), Math.Abs(dir.Z));
113 | }
114 |
115 |
116 | public GroupByDirection(Vector3 key)
117 | {
118 | Key = Abs(key);
119 | }
120 |
121 |
122 | public bool IsEqual(double a, double b)
123 | {
124 | return Math.Abs(a - b) < 0.001;
125 | }
126 |
127 | public bool CompareWithKey(Vector3 dir)
128 | {
129 | var newDir = Abs(dir);
130 | if (IsEqual(newDir.X, Key.X) && IsEqual(newDir.Y, Key.Y) && IsEqual(newDir.Z, Key.Z))
131 | {
132 | return true;
133 | }
134 |
135 | return false;
136 | }
137 | }
138 |
139 | ///
140 | /// Group the edges by the direction of the edge.
141 | ///
142 | class EdgeGroup : GroupByDirection
143 | {
144 | public double EdgeLength;
145 |
146 | public List LongEdges = new List();
147 |
148 | public EdgeGroup(EdgeInfo edge)
149 | :base(edge.Direction)
150 | {
151 | EdgeLength = edge.Length;
152 | }
153 |
154 | public bool Add(FaceInfo face)
155 | {
156 | foreach(var item in face.Edges)
157 | {
158 | var edge = item.Value;
159 | if (Math.Abs(edge.Length - EdgeLength) > 0.001)
160 | continue;
161 |
162 | if (CompareWithKey(edge.Direction))
163 | {
164 | LongEdges.Add(new LongFaceEdge(face.Index, edge.Index));
165 | return true;
166 | }
167 | }
168 |
169 | return false;
170 | }
171 | }
172 |
173 | ///
174 | /// Group side faces by Boundingbox and direction.
175 | ///
176 | class FaceGroup : GroupByDirection
177 | {
178 | public List Faces = new List();
179 | AABox BoundingBox;
180 | double MaxDistance;
181 |
182 | public FaceGroup(FaceInfo face, double maxDistance)
183 | :base(face.Direction)
184 | {
185 | MaxDistance = maxDistance;
186 | BoundingBox = face.GetShape().GetBBox();
187 | Faces.Add(face);
188 | }
189 |
190 | public bool AddFace(FaceInfo face)
191 | {
192 | var box = face.GetShape().GetBBox();
193 | if (MaxDistance < box.GetCenter().Distance(BoundingBox.GetCenter()))
194 | return false;
195 |
196 | if (!CompareWithKey(face.Direction))
197 | return false;
198 |
199 | BoundingBox.Merge(box);
200 | Faces.Add(face);
201 | return true;
202 | }
203 |
204 | public void ComputeMiddelLines()
205 | {
206 |
207 |
208 | }
209 | }
210 |
211 | class Solid
212 | {
213 | public Dictionary Faces = new Dictionary();
214 |
215 | public List EdgeGroups = new List();
216 | public List SideFaceGroup = new List();
217 | public FaceInfo GetFaceInfo(int idx) { return Faces[idx]; }
218 | public AABox BoundingBox;
219 | public Solid(TopoShape solid)
220 | {
221 | BoundingBox = solid.GetBBox();
222 |
223 | var faces = GlobalInstance.TopoExplor.ExplorFaces(solid);
224 | TopoShapeProperty prop = new TopoShapeProperty();
225 | List dictFaceByArea = new List();
226 | for (int ii = 0; ii < faces.Size(); ++ii)
227 | {
228 | var face = faces.GetAt(ii);
229 | prop.SetShape(face);
230 | double area = prop.SurfaceArea();
231 |
232 | var faceInfo = new FaceInfo(face, ii, area);
233 | dictFaceByArea.Add(faceInfo);
234 |
235 | Faces.Add(ii, faceInfo);
236 | }
237 | dictFaceByArea.Sort((a, b) =>
238 | {
239 | return (int)((b.Area - a.Area) * 1000);
240 | });
241 |
242 | var baseFace = dictFaceByArea[0];
243 | foreach(var item in baseFace.Edges)
244 | {
245 | EdgeGroup eg = new EdgeGroup(item.Value);
246 | EdgeGroups.Add(eg);
247 | }
248 |
249 | for(int ii=2; ii rt = curve.D1(ii);
59 | LineNode ln = new LineNode();
60 | ln.SetLineStyle(ls2);
61 | ln.Set(rt[0], rt[0] + rt[1]);
62 | context.ShowSceneNode(ln);
63 | }
64 | }
65 | }
66 |
67 | return true;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Boolean/ExtrudeBoolean.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Comprehensive.Boolean
9 | {
10 | class ExtrudeBoolean : Feature
11 | {
12 | public ExtrudeBoolean()
13 | {
14 | Group = ComprehensiveModule.GroupId;
15 | Category = ComprehensiveModule.BooleanCategoryId;
16 | Name = "Extrude.Boolean";
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | // Create sketch on XZ plane
23 | float width = 20;
24 | float height = 20;
25 | float thickness = 5;
26 | float length = 100;
27 | List points = new List();
28 | points.Add(Vector3.ZERO);
29 | points.Add(new Vector3(width, 0, 0));
30 | points.Add(new Vector3(width, 0, thickness));
31 | points.Add(new Vector3(thickness, 0, thickness));
32 | points.Add(new Vector3(thickness, 0, height));
33 | points.Add(new Vector3(0, 0, height));
34 |
35 | TopoShape polygon = GlobalInstance.BrepTools.MakePolygon(points);
36 | TopoShape face = GlobalInstance.BrepTools.MakeFace(polygon);
37 |
38 | // Extrude along Y direction.
39 | TopoShape extrude = GlobalInstance.BrepTools.Extrude(face, length, Vector3.UNIT_Y);
40 |
41 | // Cylinders
42 | float radius = 2;
43 | TopoShapeGroup groups = new TopoShapeGroup();
44 | groups.Add(GlobalInstance.BrepTools.MakeCylinder(new Vector3(0, 10, 10), Vector3.UNIT_X, radius, thickness, 0));
45 | groups.Add(GlobalInstance.BrepTools.MakeCylinder(new Vector3(0, 50, 10), Vector3.UNIT_X, radius, thickness, 0));
46 | groups.Add(GlobalInstance.BrepTools.MakeCylinder(new Vector3(10, 50, 0), Vector3.UNIT_Z, radius, thickness, 0));
47 |
48 | TopoShape compound = GlobalInstance.BrepTools.MakeCompound(groups);
49 |
50 | // Cut
51 | TopoShape cut = GlobalInstance.BrepTools.BooleanCut(extrude, compound);
52 |
53 | // Dispaly
54 | context.ShowGeometry(cut);
55 | return true;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Boolean/SplitSTL.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Comprehensive.Boolean
10 | {
11 | class SplitSTL : Feature
12 | {
13 | public SplitSTL()
14 | {
15 | Group = ComprehensiveModule.GroupId;
16 | Category = ComprehensiveModule.BooleanCategoryId;
17 | Name = "Splt.STL";
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 |
23 | OpenFileDialog dlg = new OpenFileDialog();
24 | dlg.Filter = "STL (*.stl)|*.stl|IGES (*.igs;*.iges)|*.igs;*.iges|STEP (*.stp;*.step)|*.stp;*.step|BREP (*.brep)|*.brep|All Files(*.*)|*.*";
25 |
26 | if (DialogResult.OK != dlg.ShowDialog())
27 | return false;
28 |
29 | context.RenderView.RenderTimer.Enabled = false;
30 | TopoShape shape = GlobalInstance.BrepTools.LoadFile(new AnyCAD.Platform.Path(dlg.FileName));
31 | context.RenderView.RenderTimer.Enabled = true;
32 | MessageBox.Show("loaded");
33 | if (shape != null)
34 | {
35 | //context.ShowGeometry(shape, new ElementId(100));
36 | //GlobalInstance.BrepTools.SaveFile(shape, new Path(dlg.FileName + ".brep"));
37 |
38 | AABox bbox = shape.GetBBox();
39 | Vector3 size = bbox.Size();
40 | Vector3 start = new Vector3(bbox.MinPt.X - 10, bbox.MinPt.Y + size.Y * 0.5f, bbox.MinPt.Z - 10);
41 | TopoShape boxShape = GlobalInstance.BrepTools.MakeBox(start, Vector3.UNIT_Z, new Vector3(size.X + 20, size.Y * 0.25f, size.Z + 20));
42 |
43 | shape = GlobalInstance.BrepTools.BooleanCut(shape, boxShape);
44 |
45 | MessageBox.Show("cut!");
46 | var groups = GlobalInstance.TopoExplor.ExplorSubShapes(shape);
47 | for (int ii = 0, len = groups.Size(); ii < len; ++ii)
48 | {
49 | shape = groups.GetAt(ii);
50 | var node = context.ShowGeometry(shape, new ElementId(100));
51 | var fs = new FaceStyle();
52 | fs.SetColor(ii * 100, 0, ii + 200);
53 | node.SetFaceStyle(fs);
54 | }
55 | }
56 | return true;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Features.Comprehensive/ComprehensiveModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using Features.Comprehensive.Boolean;
7 | using Features.Comprehensive.Algorithm;
8 |
9 | namespace Features.Comprehensive
10 | {
11 | public class ComprehensiveModule
12 | {
13 | public static String GroupId = "5. Comprehensive";
14 | static public String BooleanCategoryId = "Boolean";
15 | static public String AlgorithmCategoryId = "Algorithm";
16 |
17 | public static void Initialize()
18 | {
19 | FeatureManager.Instance().Add(new SplitSTL());
20 | FeatureManager.Instance().Add(new ExtrudeBoolean());
21 | FeatureManager.Instance().Add(new SurfaceSection());
22 | FeatureManager.Instance().Add(new RemoveExtraEdges());
23 | FeatureManager.Instance().Add(new FindInnerWiresFromShape());
24 | FeatureManager.Instance().Add(new PostProcess());
25 | FeatureManager.Instance().Add(new PostProcessHex20());
26 | FeatureManager.Instance().Add(new SkeletonFromStep());
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Features.Comprehensive/FEA/PostProcess.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using System.IO;
9 |
10 | namespace Features.Comprehensive.Boolean
11 | {
12 | class DeformationNode
13 | {
14 | public DeformationNode()
15 | {
16 |
17 | }
18 |
19 | public int Id;
20 | public float X;
21 | public float Y;
22 | public float Z;
23 | public float Data;
24 | }
25 | class PostProcess : Feature
26 | {
27 | public PostProcess()
28 | {
29 | Group = ComprehensiveModule.GroupId;
30 | Category = ComprehensiveModule.BooleanCategoryId;
31 | Name = "FEA.Postprocess";
32 | }
33 |
34 | public override bool Run(FeatureContext context)
35 | {
36 |
37 | OpenFileDialog dlg = new OpenFileDialog();
38 | dlg.Filter = "Deformation File (*.txt)|*.txt||";
39 | if (DialogResult.OK != dlg.ShowDialog())
40 | return true;
41 |
42 |
43 | String fileName = dlg.FileName;
44 | StreamReader sr = new StreamReader(fileName, Encoding.Default);
45 | String line = sr.ReadLine();
46 |
47 | List nodes = new List();
48 | float maxValue = float.NegativeInfinity;
49 | float minValue = float.PositiveInfinity;
50 |
51 | while ((line = sr.ReadLine()) != null)
52 | {
53 | String[] items = line.Split('\t');
54 |
55 | DeformationNode node = new DeformationNode();
56 | node.Id = int.Parse(items[0]);
57 | node.X = float.Parse(items[1]);
58 | node.Y = float.Parse(items[2]);
59 | node.Z = float.Parse(items[3]);
60 | node.Data = float.Parse(items[4]);
61 |
62 | nodes.Add(node);
63 |
64 | if(node.Data > maxValue)
65 | {
66 | maxValue = node.Data;
67 | }
68 | if(node.Data < minValue)
69 | {
70 | minValue = node.Data;
71 | }
72 | }
73 |
74 | float[] pointBuffer = new float[nodes.Count * 3];
75 | float[] colorBuffer = new float[nodes.Count * 3];
76 | float range = maxValue - minValue;
77 |
78 | List colorTables = new List();
79 | colorTables.Add(new ColorValue(0, 0, 1.0f));
80 | colorTables.Add(new ColorValue(0, 108.0f/255.0f, 1.0f));
81 | colorTables.Add(new ColorValue(0, 197.0f / 255.0f, 1.0f));
82 | colorTables.Add(new ColorValue(0, 243 / 255.0f, 1.0f));
83 | colorTables.Add(new ColorValue(0, 1.0f, 219.0f / 255.0f));
84 | colorTables.Add(new ColorValue(0, 1.0f, 165.0f / 255.0f));
85 | colorTables.Add(new ColorValue(0, 1.0f, 54.0f / 255.0f));
86 | colorTables.Add(new ColorValue(54.0f / 255.0f, 1.0f, 0));
87 | colorTables.Add(new ColorValue(219.0f / 255.0f, 1.0f, 0));
88 | //colorTables.Add(new ColorValue(238.0f / 255.0f, 249.0f/255.0f, 0));
89 | colorTables.Add(new ColorValue(238.0f / 255.0f, 249.0f / 255.0f, 0));
90 | colorTables.Add(new ColorValue(255.0f / 255.0f, 197.0f / 255.0f, 0));
91 | colorTables.Add(new ColorValue(251.0f / 255.0f, 102.0f / 255.0f, 17.0f / 255.0f));
92 | colorTables.Add(new ColorValue(1.0f, 0.0f, 0.0f));
93 |
94 | float segment = range / (colorTables.Count) ;
95 |
96 | int ii=-1;
97 | foreach(DeformationNode node in nodes)
98 | {
99 | int idx = (int)(node.Data / segment);
100 |
101 | if (idx >= colorTables.Count)
102 | idx -= 1;
103 |
104 | ColorValue clr = colorTables.ElementAt(idx);
105 |
106 | pointBuffer[++ii] = node.X;
107 | colorBuffer[ii] = clr.R;
108 | pointBuffer[++ii] = node.Y;
109 | colorBuffer[ii] = clr.G;
110 | pointBuffer[++ii] = node.Z;
111 | colorBuffer[ii] = clr.B;
112 | }
113 |
114 | PointCloudNode pcn = new PointCloudNode();
115 | pcn.SetPoints(pointBuffer);
116 | pcn.SetColors(colorBuffer);
117 | pcn.ComputeBBox();
118 |
119 |
120 |
121 | context.ShowSceneNode(pcn);
122 | return true;
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/Features.Comprehensive/FEA/PostProcessHex20.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using System.IO;
9 |
10 | namespace Features.Comprehensive.Boolean
11 | {
12 | class HexNode
13 | {
14 | public HexNode()
15 | {
16 | Value = new Vector3();
17 | }
18 |
19 | public uint Id;
20 | public Vector3 Value;
21 | public float Data;
22 | }
23 |
24 | class Hex20
25 | {
26 | public Hex20()
27 | {
28 | NodeIds = new uint[20];
29 | }
30 |
31 | public uint Id;
32 | public uint[] NodeIds;
33 | }
34 |
35 | class PostProcessHex20 : Feature
36 | {
37 | public PostProcessHex20()
38 | {
39 | Group = ComprehensiveModule.GroupId;
40 | Category = ComprehensiveModule.BooleanCategoryId;
41 | Name = "FEA.Hex20";
42 | }
43 |
44 | public override bool Run(FeatureContext context)
45 | {
46 |
47 | OpenFileDialog dlg = new OpenFileDialog();
48 | dlg.Filter = "Deformation File (*.xls)|*.xls||";
49 | if (DialogResult.OK != dlg.ShowDialog())
50 | return true;
51 |
52 |
53 | String fileName = dlg.FileName;
54 | StreamReader sr = new StreamReader(fileName, Encoding.Default);
55 | String line = sr.ReadLine();
56 |
57 | Dictionary nodes = new Dictionary();
58 | float maxValue = float.NegativeInfinity;
59 | float minValue = float.PositiveInfinity;
60 |
61 | while ((line = sr.ReadLine()) != null)
62 | {
63 | String[] items = line.Split('\t');
64 |
65 | HexNode node = new HexNode();
66 | node.Id = uint.Parse(items[0]) - 1;
67 | node.Value.X = float.Parse(items[1]);
68 | node.Value.Y = float.Parse(items[2]);
69 | node.Value.Z = float.Parse(items[3]);
70 | node.Data = float.Parse(items[4]);
71 |
72 | nodes[node.Id] = node;
73 |
74 | if(node.Data > maxValue)
75 | {
76 | maxValue = node.Data;
77 | }
78 | if(node.Data < minValue)
79 | {
80 | minValue = node.Data;
81 | }
82 | }
83 |
84 | float[] pointBuffer = new float[nodes.Count * 3];
85 | float[] colorBuffer = new float[nodes.Count * 3];
86 | float range = maxValue - minValue;
87 |
88 | List colorTables = new List();
89 | colorTables.Add(new ColorValue(0, 0, 1.0f));
90 | colorTables.Add(new ColorValue(0, 108.0f/255.0f, 1.0f));
91 | colorTables.Add(new ColorValue(0, 197.0f / 255.0f, 1.0f));
92 | colorTables.Add(new ColorValue(0, 243 / 255.0f, 1.0f));
93 | colorTables.Add(new ColorValue(0, 1.0f, 219.0f / 255.0f));
94 | colorTables.Add(new ColorValue(0, 1.0f, 165.0f / 255.0f));
95 | colorTables.Add(new ColorValue(0, 1.0f, 54.0f / 255.0f));
96 | colorTables.Add(new ColorValue(54.0f / 255.0f, 1.0f, 0));
97 | colorTables.Add(new ColorValue(219.0f / 255.0f, 1.0f, 0));
98 | //colorTables.Add(new ColorValue(238.0f / 255.0f, 249.0f/255.0f, 0));
99 | colorTables.Add(new ColorValue(238.0f / 255.0f, 249.0f / 255.0f, 0));
100 | colorTables.Add(new ColorValue(255.0f / 255.0f, 197.0f / 255.0f, 0));
101 | colorTables.Add(new ColorValue(251.0f / 255.0f, 102.0f / 255.0f, 17.0f / 255.0f));
102 | colorTables.Add(new ColorValue(1.0f, 0.0f, 0.0f));
103 |
104 | float segment = range / (colorTables.Count) ;
105 |
106 | //int ii=-1;
107 | //foreach(HexNode node in nodes)
108 | //{
109 | // int idx = (int)(node.Data / segment);
110 |
111 | // if (idx >= colorTables.Count)
112 | // idx -= 1;
113 |
114 | // ColorValue clr = colorTables.ElementAt(idx);
115 |
116 | // pointBuffer[++ii] = node.X;
117 | // colorBuffer[ii] = clr.R;
118 | // pointBuffer[++ii] = node.Y;
119 | // colorBuffer[ii] = clr.G;
120 | // pointBuffer[++ii] = node.Z;
121 | // colorBuffer[ii] = clr.B;
122 | //}
123 | dlg = new OpenFileDialog();
124 | dlg.Filter = "Hex20 File (*.xls)|*.xls||";
125 | if (DialogResult.OK != dlg.ShowDialog())
126 | return true;
127 |
128 |
129 | fileName = dlg.FileName;
130 | sr = new StreamReader(fileName, Encoding.Default);
131 | line = sr.ReadLine();
132 |
133 | List hex20s = new List();
134 | while ((line = sr.ReadLine()) != null)
135 | {
136 | String[] items = line.Split('\t');
137 |
138 | Hex20 hex = new Hex20();
139 | hex.Id = uint.Parse(items[0]) - 1;
140 |
141 | for(int ii=0; ii<20; ++ii)
142 | {
143 | hex.NodeIds[ii] = uint.Parse(items[ii + 2]) - 1;
144 | }
145 |
146 | hex20s.Add(hex);
147 | }
148 |
149 | //Hex20 hexItem = hex20s[0];
150 | //for(int ii=0; ii<20; ++ii)
151 | //{
152 |
153 | // HexNode n = nodes[hexItem.NodeIds[ii]];
154 | // PointNode node = new PointNode();
155 | // node.SetName(n.Id.ToString());
156 | // node.SetShowText(true);
157 | // node.SetPoint(new Vector3(n.X, n.Y, n.Z));
158 |
159 | // context.ShowSceneNode(node);
160 | //}
161 | //GlobalInstance.TopoShapeConvert.
162 | List ib = new List();
163 | for (int ii = 0; ii < hex20s.Count; ++ii )
164 | {
165 | Hex20 hexItem = hex20s[ii];
166 |
167 |
168 | // TOP
169 | ib.Add(hexItem.NodeIds[0]);
170 | ib.Add(hexItem.NodeIds[8]);
171 | ib.Add(hexItem.NodeIds[11]);
172 |
173 | ib.Add(hexItem.NodeIds[8]);
174 | ib.Add(hexItem.NodeIds[1]);
175 | ib.Add(hexItem.NodeIds[9]);
176 |
177 | ib.Add(hexItem.NodeIds[9]);
178 | ib.Add(hexItem.NodeIds[2]);
179 | ib.Add(hexItem.NodeIds[10]);
180 |
181 | ib.Add(hexItem.NodeIds[10]);
182 | ib.Add(hexItem.NodeIds[3]);
183 | ib.Add(hexItem.NodeIds[11]);
184 |
185 | ib.Add(hexItem.NodeIds[8]);
186 | ib.Add(hexItem.NodeIds[10]);
187 | ib.Add(hexItem.NodeIds[11]);
188 |
189 | ib.Add(hexItem.NodeIds[8]);
190 | ib.Add(hexItem.NodeIds[9]);
191 | ib.Add(hexItem.NodeIds[10]);
192 |
193 |
194 | // BOTTOM
195 | ib.Add(hexItem.NodeIds[4]);
196 | ib.Add(hexItem.NodeIds[12]);
197 | ib.Add(hexItem.NodeIds[15]);
198 |
199 | ib.Add(hexItem.NodeIds[12]);
200 | ib.Add(hexItem.NodeIds[5]);
201 | ib.Add(hexItem.NodeIds[13]);
202 |
203 | ib.Add(hexItem.NodeIds[13]);
204 | ib.Add(hexItem.NodeIds[6]);
205 | ib.Add(hexItem.NodeIds[14]);
206 |
207 | ib.Add(hexItem.NodeIds[14]);
208 | ib.Add(hexItem.NodeIds[7]);
209 | ib.Add(hexItem.NodeIds[15]);
210 |
211 | ib.Add(hexItem.NodeIds[12]);
212 | ib.Add(hexItem.NodeIds[14]);
213 | ib.Add(hexItem.NodeIds[15]);
214 |
215 | ib.Add(hexItem.NodeIds[12]);
216 | ib.Add(hexItem.NodeIds[13]);
217 | ib.Add(hexItem.NodeIds[14]);
218 |
219 | // FRONT
220 | ib.Add(hexItem.NodeIds[1]);
221 | ib.Add(hexItem.NodeIds[9]);
222 | ib.Add(hexItem.NodeIds[17]);
223 |
224 | ib.Add(hexItem.NodeIds[9]);
225 | ib.Add(hexItem.NodeIds[2]);
226 | ib.Add(hexItem.NodeIds[18]);
227 |
228 | ib.Add(hexItem.NodeIds[18]);
229 | ib.Add(hexItem.NodeIds[6]);
230 | ib.Add(hexItem.NodeIds[13]);
231 |
232 | ib.Add(hexItem.NodeIds[13]);
233 | ib.Add(hexItem.NodeIds[5]);
234 | ib.Add(hexItem.NodeIds[17]);
235 |
236 | ib.Add(hexItem.NodeIds[9]);
237 | ib.Add(hexItem.NodeIds[18]);
238 | ib.Add(hexItem.NodeIds[17]);
239 |
240 | ib.Add(hexItem.NodeIds[18]);
241 | ib.Add(hexItem.NodeIds[13]);
242 | ib.Add(hexItem.NodeIds[17]);
243 |
244 | // BACK
245 | ib.Add(hexItem.NodeIds[0]);
246 | ib.Add(hexItem.NodeIds[11]);
247 | ib.Add(hexItem.NodeIds[16]);
248 |
249 | ib.Add(hexItem.NodeIds[11]);
250 | ib.Add(hexItem.NodeIds[3]);
251 | ib.Add(hexItem.NodeIds[19]);
252 |
253 | ib.Add(hexItem.NodeIds[19]);
254 | ib.Add(hexItem.NodeIds[7]);
255 | ib.Add(hexItem.NodeIds[15]);
256 |
257 | ib.Add(hexItem.NodeIds[15]);
258 | ib.Add(hexItem.NodeIds[4]);
259 | ib.Add(hexItem.NodeIds[16]);
260 |
261 | ib.Add(hexItem.NodeIds[11]);
262 | ib.Add(hexItem.NodeIds[19]);
263 | ib.Add(hexItem.NodeIds[16]);
264 |
265 | ib.Add(hexItem.NodeIds[19]);
266 | ib.Add(hexItem.NodeIds[15]);
267 | ib.Add(hexItem.NodeIds[16]);
268 |
269 | // LEFT
270 | ib.Add(hexItem.NodeIds[1]);
271 | ib.Add(hexItem.NodeIds[17]);
272 | ib.Add(hexItem.NodeIds[8]);
273 |
274 | ib.Add(hexItem.NodeIds[17]);
275 | ib.Add(hexItem.NodeIds[5]);
276 | ib.Add(hexItem.NodeIds[12]);
277 |
278 | ib.Add(hexItem.NodeIds[12]);
279 | ib.Add(hexItem.NodeIds[4]);
280 | ib.Add(hexItem.NodeIds[16]);
281 |
282 | ib.Add(hexItem.NodeIds[16]);
283 | ib.Add(hexItem.NodeIds[0]);
284 | ib.Add(hexItem.NodeIds[8]);
285 |
286 | ib.Add(hexItem.NodeIds[8]);
287 | ib.Add(hexItem.NodeIds[17]);
288 | ib.Add(hexItem.NodeIds[12]);
289 |
290 | ib.Add(hexItem.NodeIds[12]);
291 | ib.Add(hexItem.NodeIds[16]);
292 | ib.Add(hexItem.NodeIds[8]);
293 |
294 | // RIGHT
295 | ib.Add(hexItem.NodeIds[2]);
296 | ib.Add(hexItem.NodeIds[10]);
297 | ib.Add(hexItem.NodeIds[18]);
298 |
299 | ib.Add(hexItem.NodeIds[10]);
300 | ib.Add(hexItem.NodeIds[3]);
301 | ib.Add(hexItem.NodeIds[19]);
302 |
303 | ib.Add(hexItem.NodeIds[19]);
304 | ib.Add(hexItem.NodeIds[7]);
305 | ib.Add(hexItem.NodeIds[14]);
306 |
307 | ib.Add(hexItem.NodeIds[14]);
308 | ib.Add(hexItem.NodeIds[6]);
309 | ib.Add(hexItem.NodeIds[18]);
310 |
311 | ib.Add(hexItem.NodeIds[10]);
312 | ib.Add(hexItem.NodeIds[14]);
313 | ib.Add(hexItem.NodeIds[18]);
314 |
315 | ib.Add(hexItem.NodeIds[10]);
316 | ib.Add(hexItem.NodeIds[19]);
317 | ib.Add(hexItem.NodeIds[14]);
318 | }
319 |
320 | Vector3[] normals = new Vector3[nodes.Count];
321 | for(int ii=0; ii= colorTables.Count)
377 | idx = colorTables.Count - 1;
378 |
379 | ColorValue clr = colorTables.ElementAt(idx);
380 |
381 | cb[ii * 3] = clr.R;
382 | cb[ii * 3 + 1] = clr.G;
383 | cb[ii * 3 + 2] = clr.B;
384 | }
385 |
386 | var pEntity = GlobalInstance.TopoShapeConvert.CreateColoredFaceEntity(vb, ib.ToArray(), nb, cb, bbox);
387 | var nEntityNode = new EntitySceneNode();
388 | nEntityNode.SetEntity(pEntity);
389 | context.ShowSceneNode(nEntityNode);
390 |
391 | return true;
392 | }
393 | }
394 | }
395 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Features.Comprehensive.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x64
7 | 8.0.30703
8 | 2.0
9 | {3CC5CD02-4AB4-44FB-83DB-236B2C35BD72}
10 | Library
11 | Properties
12 | Features.Comprehensive
13 | Features.Comprehensive
14 | v4.0
15 | 512
16 |
17 |
18 |
19 |
20 | x64
21 | true
22 | full
23 | false
24 | ..\bin\x64\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x64
31 | pdbonly
32 | true
33 | ..\bin\x64\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Exchange.Net.dll
41 | False
42 |
43 |
44 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Foundation.Net.dll
45 | False
46 |
47 |
48 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Presentation.Net.dll
49 | False
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}
75 | Features.Core
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
85 |
86 |
87 |
88 |
95 |
--------------------------------------------------------------------------------
/Features.Comprehensive/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Features.Comprehensive")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Features.Comprehensive")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8c189ed9-8956-4539-8799-684a820cc63c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Features.Comprehensive/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Features.Core/Feature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Features.Core
7 | {
8 | public class Feature
9 | {
10 | public String Name { get; set; }
11 | public String Category { get; set; }
12 | public String Group { get; set; }
13 | public String Description { get; set; }
14 |
15 | public virtual bool Run(FeatureContext context)
16 | {
17 | return false;
18 | }
19 |
20 | public virtual void OnExit(FeatureContext context)
21 | {
22 |
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Features.Core/FeatureContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using AnyCAD.Presentation;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Core
9 | {
10 | public class FeatureContext
11 | {
12 | public RenderWindow3d RenderView { get; set; }
13 |
14 | public ElementId CurrentId { get; set; }
15 |
16 | public FeatureContext(RenderWindow3d renderView)
17 | {
18 | RenderView = renderView;
19 | CurrentId = new ElementId(100);
20 | }
21 | public SceneNode ShowGeometry(TopoShape shape)
22 | {
23 | ++CurrentId;
24 | return RenderView.ShowGeometry(shape, CurrentId);
25 | }
26 | public void ShowSceneNode(SceneNode node)
27 | {
28 | ++CurrentId;
29 | node.SetId(CurrentId);
30 | RenderView.ShowSceneNode(node);
31 | }
32 |
33 | public SceneNode ShowGeometry(TopoShape shape, ElementId id)
34 | {
35 | CurrentId = id;
36 | return RenderView.ShowGeometry(shape, id);
37 | }
38 |
39 | public void RequestDraw()
40 | {
41 | RenderView.RequestDraw();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Features.Core/FeatureManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Features.Core
7 | {
8 | public class FeatureManager
9 | {
10 | public List FeatrueList { get; set; }
11 |
12 | FeatureManager()
13 | {
14 | this.FeatrueList = new List();
15 | }
16 |
17 | static FeatureManager _Instance = null;
18 | public static FeatureManager Instance()
19 | {
20 | if (_Instance == null)
21 | {
22 | _Instance = new FeatureManager();
23 | }
24 |
25 | return _Instance;
26 | }
27 |
28 | public void Add(Feature feature)
29 | {
30 | FeatrueList.Add(feature);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Features.Core/Features.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x64
7 | 8.0.30703
8 | 2.0
9 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}
10 | Library
11 | Properties
12 | Features.Core
13 | Features.Core
14 | v4.0
15 | 512
16 |
17 |
18 |
19 |
20 | x64
21 | true
22 | full
23 | false
24 | ..\bin\x64\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x64
31 | pdbonly
32 | true
33 | ..\bin\x64\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Exchange.Net.dll
41 | False
42 |
43 |
44 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Foundation.Net.dll
45 | False
46 |
47 |
48 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Presentation.Net.dll
49 | False
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
73 |
74 |
75 |
76 |
83 |
--------------------------------------------------------------------------------
/Features.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Features.Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Features.Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c98daf1e-6cac-46c2-b4e1-b7d9fd3d280d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Features.Core/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Features.Modeling/Algorithm/Intersections.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Modeling.Algorithm
10 | {
11 | class CurveLineIntersection : Feature
12 | {
13 | public CurveLineIntersection()
14 | {
15 | Name = "Intersection.CL";
16 | Group = ModelingModule.GroupId;
17 | Category = ModelingModule.AlgorithmCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | context.RenderView.SetDisplayMode((int)(EnumDisplayStyle.DS_ShadeEdge | EnumDisplayStyle.DS_Vertex));
23 | // construct a wire;
24 | TopoShape TS = GlobalInstance.BrepTools.MakeEllipse(Vector3.ZERO, 100D, 50D, Vector3.UNIT_Z);
25 | context.ShowGeometry(TS);
26 |
27 | TopoShape line = GlobalInstance.BrepTools.MakeLine(new Vector3(0, -200, 0), new Vector3(200, 200, 0));
28 | context.ShowGeometry(line);
29 |
30 | IntersectionLineCurve intersector = new IntersectionLineCurve();
31 |
32 | TopoExplor tp = new TopoExplor();
33 | TopoShapeGroup tg = tp.ExplorEdges(TS);
34 | intersector.SetCurve(tg.GetAt(0));
35 |
36 | if (intersector.Perform(line))
37 | {
38 |
39 | int nCount = intersector.GetPointCount();
40 |
41 | List LV = new List();
42 |
43 | for (int ii = 0; ii < nCount; ++ii)
44 | {
45 |
46 | Vector3 pt = intersector.GetPoint(ii+1);
47 | LV.Add(pt);
48 |
49 | context.ShowGeometry(GlobalInstance.BrepTools.MakePoint(pt));
50 | }
51 |
52 |
53 | MessageBox.Show(String.Format("{0}", nCount));
54 | }
55 |
56 |
57 |
58 | return true;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Features.Modeling/Algorithm/MakeSplit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeSplit : Feature
11 | {
12 | public MakeSplit()
13 | {
14 | Name = "Split";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.AlgorithmCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | // Split box with two spheres.
22 | TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(150f, 150f, 150f));
23 | TopoShape sphere = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 100f);
24 | TopoShape sphere2 = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 50f);
25 |
26 | TopoShapeGroup tools = new TopoShapeGroup();
27 | tools.Add(sphere);
28 | tools.Add(sphere2);
29 | TopoShape split = GlobalInstance.BrepTools.MakeSplit(box, tools);
30 |
31 | // Display the results with customized face styles.
32 | TopoExplor expo = new TopoExplor();
33 | TopoShapeGroup bodies = expo.ExplorSolids(split);
34 |
35 |
36 | Random random = new Random();
37 | for (int ii = 0; ii < bodies.Size(); ++ii)
38 | {
39 | SceneNode node = context.ShowGeometry(bodies.GetTopoShape(ii));
40 | FaceStyle fs = new FaceStyle();
41 | fs.SetColor(new ColorValue((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), 0.5f));
42 | fs.SetTransparent(true);
43 | node.SetFaceStyle(fs);
44 | }
45 |
46 | return true;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Features.Modeling/Algorithm/Projection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class ProjectionPlane : Feature
11 | {
12 | public ProjectionPlane()
13 | {
14 | Name = "Projection.Plane";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.AlgorithmCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | // construct a wire;
22 | var points = new System.Collections.Generic.List();
23 | points.Add(new Vector3(0, 0, 0));
24 | points.Add(new Vector3(0, 100, 0));
25 | points.Add(new Vector3(100, 100, 0));
26 | TopoShape wire = GlobalInstance.BrepTools.MakePolygon(points);
27 | context.ShowGeometry(wire);
28 |
29 | // project the wire to two planes
30 | Vector3 dirPlane1 = new Vector3(0, 1, 1);
31 | dirPlane1.Normalize();
32 | TopoShape newWire1 = GlobalInstance.BrepTools.ProjectOnPlane(wire, new Vector3(0, 0, 100),
33 | dirPlane1, new Vector3(0, 0, 1));
34 |
35 | Vector3 dirPlane2 = new Vector3(0, 1, -1);
36 | dirPlane2.Normalize();
37 | TopoShape newWire2 = GlobalInstance.BrepTools.ProjectOnPlane(wire, new Vector3(0, 0, 500),
38 | dirPlane2, new Vector3(0, 0, 1));
39 |
40 | // make loft
41 | TopoShapeGroup tsg = new TopoShapeGroup();
42 | tsg.Add(newWire1);
43 | tsg.Add(newWire2);
44 | TopoShape loft = GlobalInstance.BrepTools.MakeLoft(tsg, false);
45 | context.ShowGeometry(loft);
46 |
47 | return true;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Features.Modeling/Algorithm/SurfaceSection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class SurfaceSection : Feature
11 | {
12 | public SurfaceSection()
13 | {
14 | Name = "Section.Surface";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.AlgorithmCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | // build two surfaces
22 | TopoShape arc = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, 100, 0, 135, Vector3.UNIT_Z);
23 | TopoShape cir = GlobalInstance.BrepTools.MakeCircle(new Vector3(-200, 0, 0), 50, Vector3.UNIT_X);
24 | TopoShape surf1 = GlobalInstance.BrepTools.Extrude(arc, 100, Vector3.UNIT_Z);
25 | TopoShape surf2 = GlobalInstance.BrepTools.Extrude(cir, 400, Vector3.UNIT_X);
26 |
27 | SceneNode n1 = context.ShowGeometry(surf1);
28 | {
29 | FaceStyle fs1 = new FaceStyle();
30 | fs1.SetColor(new ColorValue(0, 0, 0.5f, 0.5f));
31 | fs1.SetTransparent(true);
32 | n1.SetFaceStyle(fs1);
33 | }
34 | SceneNode n2 = context.ShowGeometry(surf2);
35 | {
36 | FaceStyle fs2 = new FaceStyle();
37 | fs2.SetColor(new ColorValue(0, 0.5f, 0.5f, 0.5f));
38 | fs2.SetTransparent(true);
39 | n2.SetFaceStyle(fs2);
40 | }
41 |
42 | // compute section wire
43 | TopoShape wire = GlobalInstance.BrepTools.SurfaceSection(surf1, surf2);
44 |
45 | SceneNode sectionNode = context.ShowGeometry(wire);
46 | LineStyle lineStyle = new LineStyle();
47 | lineStyle.SetLineWidth(4);
48 | lineStyle.SetColor(ColorValue.RED);
49 | sectionNode.SetLineStyle(lineStyle);
50 |
51 | return true;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Features.Modeling/Boolean/MakeCut.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeCut : Feature
11 | {
12 | public MakeCut()
13 | {
14 | Name = "Cut";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.BooleanCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | TopoShape tube = GlobalInstance.BrepTools.MakeTube(Vector3.ZERO, Vector3.UNIT_Z, 8, 2, 100);
22 |
23 | TopoShape cyl = GlobalInstance.BrepTools.MakeCylinder(new Vector3(0, 0, 50), Vector3.UNIT_X, 5, 10, 0);
24 | {
25 | SceneNode node = context.ShowGeometry(cyl);
26 | FaceStyle fs = new FaceStyle();
27 | fs.SetColor(new ColorValue(0.5f, 0.5f, 0, 0.5f));
28 | fs.SetTransparent(true);
29 | node.SetFaceStyle(fs);
30 | }
31 |
32 | TopoShape cut = GlobalInstance.BrepTools.BooleanCut(tube, cyl);
33 | context.ShowGeometry(cut);
34 |
35 | return true;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Features.Modeling/Boolean/MakeGlue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeGlue : Feature
11 | {
12 | public MakeGlue()
13 | {
14 | Name = "Glue";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.BooleanCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | TopoShape box1 = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 100, 100));
22 | TopoShape box2 = GlobalInstance.BrepTools.MakeBox(new Vector3(0, 0, -100), Vector3.UNIT_Z, new Vector3(100, 100, 100));
23 |
24 | TopoShapeGroup group = new TopoShapeGroup();
25 | group.Add(box1);
26 | group.Add(box2);
27 |
28 | TopoShape compound = GlobalInstance.BrepTools.MakeCompound(group);
29 |
30 | RepairTools repairTool = new RepairTools();
31 | TopoShape glue = repairTool.GlueFaces(compound, 0.00001f, true);
32 | //TopoShape newBody = repairTool.RemoveExtraEdges(glue);
33 | context.ShowGeometry(glue);
34 |
35 | return true;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Features.Modeling/Boolean/MakeSection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeSection : Feature
11 | {
12 | public MakeSection()
13 | {
14 | Name = "Section";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.BooleanCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | TopoShape cylinder = GlobalInstance.BrepTools.MakeCylinder(Vector3.ZERO, Vector3.UNIT_Z, 100, 200, 270);
22 | TopoShape section = GlobalInstance.BrepTools.BodySection(cylinder, new Vector3(0, 0, 50), Vector3.UNIT_Z);
23 |
24 | context.ShowGeometry(cylinder);
25 |
26 | SceneNode node = context.ShowGeometry(section);
27 | LineStyle ls = new LineStyle();
28 | ls.SetLineWidth(3.0f);
29 | ls.SetColor(255, 0, 0);
30 | node.SetLineStyle(ls);
31 |
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Features.Modeling/Boolean/MakeSplitCurve.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeSplitCurve : Feature
11 | {
12 | public MakeSplitCurve()
13 | {
14 | Name = "Split Curve";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.BooleanCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | TopoShape arc = GlobalInstance.BrepTools.MakeArc(new Vector3(-100, 0, 0), new Vector3(100, 0, 0), Vector3.ZERO, Vector3.UNIT_Z);
22 | TopoShape line = GlobalInstance.BrepTools.MakeLine(new Vector3(100, 0, 0), new Vector3(100, 200, 0));
23 |
24 | TopoShapeGroup group = new TopoShapeGroup();
25 | group.Add(arc);
26 | group.Add(line);
27 |
28 | TopoShape wire = GlobalInstance.BrepTools.MakeSpline(group);
29 |
30 | TopoShape splitter1 = GlobalInstance.BrepTools.MakePoint(new Vector3(0, -100, 0));
31 | TopoShape splitter2 = GlobalInstance.BrepTools.MakePoint(new Vector3(100, 100, 0));
32 |
33 | TopoShapeGroup spliterGroup = new TopoShapeGroup();
34 | spliterGroup.Add(splitter1);
35 | spliterGroup.Add(splitter2);
36 | TopoShape result = GlobalInstance.BrepTools.MakeSplit(wire, spliterGroup);
37 |
38 | TopoExplor exp = new TopoExplor();
39 | TopoShapeGroup itmes = exp.ExplorSubShapes(result);
40 | for (int ii = 0; ii < itmes.Size(); ++ii)
41 | {
42 | SceneNode node = context.ShowGeometry(itmes.GetAt(ii));
43 | LineStyle ls = new LineStyle();
44 | ls.SetLineWidth(3.0f);
45 | ls.SetColor((ii + 1) * 50, ii * 20, ii * 10);
46 | node.SetLineStyle(ls);
47 |
48 | }
49 |
50 |
51 | return true;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakeEvolved.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeEvolved : Feature
11 | {
12 | public MakeEvolved()
13 | {
14 | Name = "Evolved";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | //1. Create the path
23 | float radius = 100;
24 | TopoShape arc = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, new Vector3(-radius, -radius, 0), new Vector3(0, -radius, 0), Vector3.UNIT_Z);
25 | TopoShape line = GlobalInstance.BrepTools.MakeLine(new Vector3(-radius, -radius, 0), new Vector3(-radius, -radius * 2, 0));
26 |
27 | TopoShapeGroup edges = new TopoShapeGroup();
28 | edges.Add(arc);
29 | edges.Add(line);
30 | TopoShape wire = GlobalInstance.BrepTools.MakeWire(edges);
31 |
32 |
33 | Vector3 dirZ = new Vector3(1, -1, 0);
34 | dirZ.Normalize();
35 | Vector3 dirX = dirZ.CrossProduct(Vector3.UNIT_Z);
36 | Coordinate3 coord = new Coordinate3(Vector3.ZERO, dirX, Vector3.UNIT_Z, dirZ);
37 |
38 |
39 | TopoShape path = GlobalInstance.BrepTools.Transform(wire, coord);
40 | context.ShowGeometry(path);
41 |
42 | //2. Create the profile
43 | List points = new List();
44 | points.Add(new Vector3());
45 | points.Add(new Vector3(200, 0, 0));
46 | points.Add(new Vector3(200, 200, 0));
47 | points.Add(new Vector3(0, 200, 0));
48 |
49 | TopoShape polygon = GlobalInstance.BrepTools.MakePolygon(points);
50 |
51 | // 3. Make body
52 | AdvFeatureTools advFT = new AdvFeatureTools();
53 | TopoShape shape = advFT.MakeEvolved(polygon, path, 0, true);
54 |
55 | context.ShowGeometry(shape);
56 |
57 | return true;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakeFillet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeFillet : Feature
11 | {
12 | public MakeFillet()
13 | {
14 | Name = "Fillet";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | // 1. Create Solid by extrude the section
22 | Vector3 start = new Vector3(100, 0, 0);
23 | Vector3 end = new Vector3(0, 100, 0);
24 |
25 | TopoShapeGroup group = new TopoShapeGroup();
26 | group.Add(GlobalInstance.BrepTools.MakeArc(start, end, Vector3.ZERO, Vector3.UNIT_Z));
27 | group.Add(GlobalInstance.BrepTools.MakeLine(Vector3.ZERO, start));
28 | group.Add(GlobalInstance.BrepTools.MakeLine(Vector3.ZERO, end));
29 |
30 | TopoShape section = GlobalInstance.BrepTools.MakeWire(group);
31 | TopoShape face = GlobalInstance.BrepTools.MakeFace(section);
32 | TopoShape solid = GlobalInstance.BrepTools.Extrude(face, 50, Vector3.UNIT_Z);
33 |
34 | // 2. Fillet the specified edges with different radius.
35 | int[] edges = {4, 6, 8};
36 | float[] radius = {5, 5, 10};
37 |
38 | TopoShape chamfer = GlobalInstance.BrepTools.MakeFillet(solid, edges, radius);
39 |
40 | context.ShowGeometry(chamfer);
41 | return true;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakeHoles.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeHoles : Feature
11 | {
12 | public MakeHoles()
13 | {
14 | Name = "Holes.Loops";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | var ptlist = new System.Collections.Generic.List();
22 | ptlist.Add(Vector3.ZERO);
23 | ptlist.Add(new Vector3(100, 0, 0));
24 | ptlist.Add(new Vector3(100, 100, 0));
25 | ptlist.Add(new Vector3(0, 100, 0));
26 | TopoShape polygon = GlobalInstance.BrepTools.MakePolygon(ptlist);
27 |
28 | TopoShape cir1 = GlobalInstance.BrepTools.MakeCircle(new Vector3(20, 20, 0), 15, Vector3.UNIT_Z);
29 | TopoShape cir2 = GlobalInstance.BrepTools.MakeCircle(new Vector3(80, 20, 0), 15, Vector3.UNIT_Z);
30 | TopoShape cir3 = GlobalInstance.BrepTools.MakeCircle(new Vector3(80, 80, 0), 15, Vector3.UNIT_Z);
31 | TopoShape cir4 = GlobalInstance.BrepTools.MakeCircle(new Vector3(20, 80, 0), 15, Vector3.UNIT_Z);
32 |
33 | TopoShapeGroup group = new TopoShapeGroup();
34 | group.Add(polygon);
35 | group.Add(cir1);
36 | group.Add(cir2);
37 | group.Add(cir3);
38 | group.Add(cir4);
39 |
40 | // build faces with holes
41 | LoopsBuilder lb = new LoopsBuilder();
42 | lb.Initialize(group);
43 | TopoShapeGroup faces = lb.BuildFacesWithHoles();
44 | for (int ii = 0; ii < faces.Size(); ++ii)
45 | {
46 | context.ShowGeometry(faces.GetTopoShape(ii));
47 | }
48 |
49 | return true;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakeLoft.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeLoft : Feature
11 | {
12 | public MakeLoft()
13 | {
14 | Name = "Loft";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | TopoShape circle = GlobalInstance.BrepTools.MakeCircle(new Vector3(0, 0, 50), 10, Vector3.UNIT_Z);
22 | TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(40, 40, 5, new Coordinate3(new Vector3(-20, -20, 0), Vector3.UNIT_X, Vector3.UNIT_Y, Vector3.UNIT_Z));
23 |
24 | TopoShape loft = GlobalInstance.BrepTools.MakeLoft(rect, circle, true);
25 |
26 | context.ShowGeometry(loft);
27 |
28 | return true;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakePipe.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakePipe : Feature
11 | {
12 | public MakePipe()
13 | {
14 | Name = "Sweep.Pipe";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | for (int ii = 0; ii < 3; ++ii)
22 | {
23 | // Path
24 | Vector3 startPt = new Vector3(ii * 100, 0, 0);
25 | var points = new System.Collections.Generic.List();
26 | points.Add(startPt);
27 | points.Add(startPt + new Vector3(0, 0, 100));
28 | points.Add(startPt + new Vector3(50, 50, 150));
29 | TopoShape path = GlobalInstance.BrepTools.MakePolyline(points);
30 |
31 | // Profile
32 | TopoShape section = GlobalInstance.BrepTools.MakeCircle(startPt, 10, Vector3.UNIT_Z);
33 |
34 | // ii is used to define the joint style.
35 | TopoShape pipe = GlobalInstance.BrepTools.MakePipe(section, path, ii);
36 |
37 | context.ShowGeometry(pipe);
38 | }
39 |
40 | return true;
41 | }
42 | }
43 |
44 | class MakePipe2 : Feature
45 | {
46 | public MakePipe2()
47 | {
48 | Name = "Sweep.Solid";
49 | Group = ModelingModule.GroupId;
50 | Category = ModelingModule.FeaturedCategoryId;
51 | }
52 |
53 | public override bool Run(FeatureContext context)
54 | {
55 | List pts = new List();
56 | pts.Add(new Vector3(0, 0, 0));
57 | pts.Add(new Vector3(10, 0, 0));
58 | pts.Add(new Vector3(10, 100, 0));
59 | pts.Add(new Vector3(0, 100, 0));
60 | TopoShape rect = GlobalInstance.BrepTools.MakePolygon(pts);
61 |
62 | TopoShape arc = GlobalInstance.BrepTools.MakeArc(new Vector3(-100, 0, 100),new Vector3(0, 0, 0), new Vector3(-100, 0, 0), Vector3.UNIT_Y);
63 | //TopoShape arc = GlobalInstance.BrepTools.MakeArc(new Vector3(0, 0, 0), new Vector3(100, 100, 0), new Vector3(100, 0, 0), new Vector3(0, 0, -1));
64 | //context.ShowGeometry(arc);
65 | //GeomCurve curve = new GeomCurve();
66 | //curve.Initialize(arc);
67 | //var d1 = curve.D1(curve.FirstParameter());
68 | ////Vector3 dir = d1[1];
69 | ////dir = dir.CrossProduct(Vector3.UNIT_Z);
70 | ////float x = dir.AngleBetween(Vector3.UNIT_Y);
71 | //Matrix4 mm = GlobalInstance.MatrixBuilder.MakeRotation(90, Vector3.UNIT_X);
72 | //Matrix4 trans = GlobalInstance.MatrixBuilder.MakeTranslate(d1[0]);
73 | //Matrix4 trf = GlobalInstance.MatrixBuilder.Multiply(trans, mm);
74 | //rect = GlobalInstance.BrepTools.Transform(rect, trf);
75 |
76 | rect = GlobalInstance.BrepTools.MakePipe(rect, arc, 0);
77 |
78 | SceneNode sn = context.ShowGeometry(rect);
79 |
80 | return true;
81 | }
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakeRevole.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeRevole : Feature
11 | {
12 | public MakeRevole()
13 | {
14 | Name = "Revole";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | int size = 10;
22 | // Create the outline edge
23 | TopoShape arc = GlobalInstance.BrepTools.MakeArc3Pts(new Vector3(-size, 0, 0), new Vector3(size, 0, 0), new Vector3(0, size, 0));
24 | TopoShape line1 = GlobalInstance.BrepTools.MakeLine(new Vector3(-size, -size, 0), new Vector3(-size, 0, 0));
25 | TopoShape line2 = GlobalInstance.BrepTools.MakeLine(new Vector3(size, -size, 0), new Vector3(size, 0, 0));
26 | TopoShape line3 = GlobalInstance.BrepTools.MakeLine(new Vector3(-size, -size, 0), new Vector3(size, -size, 0));
27 |
28 | TopoShapeGroup shapeGroup = new TopoShapeGroup();
29 | shapeGroup.Add(line1);
30 | shapeGroup.Add(arc);
31 | shapeGroup.Add(line2);
32 | shapeGroup.Add(line3);
33 |
34 | TopoShape wire = GlobalInstance.BrepTools.MakeWire(shapeGroup);
35 |
36 | TopoShape revole = GlobalInstance.BrepTools.Revol(wire, new Vector3(size * 3, 0, 0), new Vector3(0, 1, 0), 145);
37 |
38 | context.ShowGeometry(revole);
39 |
40 | return true;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Features.Modeling/Featured/MakeSweep.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Algorithm
9 | {
10 | class MakeSweep : Feature
11 | {
12 | public MakeSweep()
13 | {
14 | Name = "Sweep.Evolution";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.FeaturedCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | AdvFeatureTools advTool = new AdvFeatureTools();
22 |
23 | // Create the evolution spline
24 | Primitive2dTools tool2d = new Primitive2dTools();
25 | float radius = 50;
26 | TopoShapeGroup group = new TopoShapeGroup();
27 | group.Add(tool2d.MakeArc(new Vector2(0, radius), radius, 0, 45));
28 | group.Add(tool2d.MakeLine(new Vector2(radius, radius), new Vector2(radius * 2, radius)));
29 | TopoShape spline = tool2d.ToBSplineCurve(group);
30 |
31 | // Create the profile section
32 | TopoShape profile = GlobalInstance.BrepTools.MakeCircle(new Vector3(100, 100, 0), 1, Vector3.UNIT_Z);
33 |
34 | // Create the path
35 | List pts = new List();
36 | pts.Add(new Vector3(100, 100, 0));
37 | pts.Add(new Vector3(100, 100, 100));
38 | pts.Add(new Vector3(100, 200, 400));
39 | TopoShape path = GlobalInstance.BrepTools.MakeSpline(pts);
40 |
41 | // Make sweep
42 | TopoShape sweepBody = advTool.MakeSweep(profile, path, spline, true);
43 |
44 | context.ShowGeometry(sweepBody);
45 |
46 | return true;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Features.Modeling/Features.Modeling.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x64
7 | 8.0.30703
8 | 2.0
9 | {9B7597AF-D934-42B9-9773-8A66BFAB9C40}
10 | Library
11 | Properties
12 | Features.Modeling
13 | Features.Modeling
14 | v4.0
15 | 512
16 |
17 |
18 |
19 |
20 | x64
21 | true
22 | full
23 | false
24 | ..\bin\x64\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x64
31 | pdbonly
32 | true
33 | ..\bin\x64\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Exchange.Net.dll
41 | False
42 |
43 |
44 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Foundation.Net.dll
45 | False
46 |
47 |
48 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Presentation.Net.dll
49 | False
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}
94 | Features.Core
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
104 |
105 |
106 |
107 |
114 |
--------------------------------------------------------------------------------
/Features.Modeling/Geometry/CurveLength.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Modeling.Geometry
10 | {
11 | class CurveLength : Feature
12 | {
13 | public CurveLength()
14 | {
15 | Name = "Curve.Length";
16 | Group = ModelingModule.GroupId;
17 | Category = ModelingModule.GeometryCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z);
23 | context.ShowGeometry(arc);
24 |
25 |
26 | TopoShapeProperty property = new TopoShapeProperty();
27 | property.SetShape(arc);
28 |
29 | double length = property.EdgeLength();
30 |
31 | MessageBox.Show(String.Format("Length: {0}",length));
32 |
33 | return true;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Features.Modeling/Geometry/QueryCurve.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Geometry
9 | {
10 | class QuertyCurve : Feature
11 | {
12 | public QuertyCurve()
13 | {
14 | Name = "Curve";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.GeometryCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | LineStyle lineStyle = new LineStyle();
22 | lineStyle.SetLineWidth(0.5f);
23 | lineStyle.SetColor(ColorValue.BLUE);
24 | lineStyle.SetLineWidth(1.5f);
25 | LineStyle lineStyle2 = new LineStyle();
26 | lineStyle2.SetLineWidth(0.5f);
27 | lineStyle2.SetColor(ColorValue.GREEN);
28 | lineStyle2.SetLineWidth(2);
29 | TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z);
30 | context.ShowGeometry(arc);
31 |
32 | {
33 | GeomCurve curve = new GeomCurve();
34 | curve.Initialize(arc);
35 |
36 | double paramStart = curve.FirstParameter();
37 | double paramEnd = curve.LastParameter();
38 |
39 | double step = (paramEnd - paramStart) * 0.1;
40 |
41 | for (double uu = paramStart; uu <= paramEnd; uu += step)
42 | {
43 | Vector3 dir = curve.DN(uu, 1);
44 | Vector3 pos = curve.Value(uu);
45 |
46 | // 切线
47 | {
48 | TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir);
49 | SceneNode node = context.ShowGeometry(line);
50 | node.SetLineStyle(lineStyle);
51 | }
52 | // 法线
53 | {
54 | Vector3 dirN = dir.CrossProduct(Vector3.UNIT_Z);
55 | TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dirN);
56 | SceneNode node = context.ShowGeometry(line);
57 | node.SetLineStyle(lineStyle2);
58 | }
59 |
60 | }
61 |
62 | }
63 |
64 | return true;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Features.Modeling/Geometry/QuerySurface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Modeling.Geometry
10 | {
11 | class SurfaceArea : Feature
12 | {
13 | public SurfaceArea()
14 | {
15 | Name = "Surface.Area";
16 | Group = ModelingModule.GroupId;
17 | Category = ModelingModule.GeometryCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 |
23 | var points = new List();
24 | points.Add(new Vector3(0, 0, 0));
25 | points.Add(new Vector3(50, 0, 0));
26 | points.Add(new Vector3(100, 0, 0));
27 |
28 | points.Add(new Vector3(0, 50, 0));
29 | points.Add(new Vector3(50, 50, 5));
30 | points.Add(new Vector3(100, 50, -5));
31 |
32 | points.Add(new Vector3(0, 150, 5));
33 | points.Add(new Vector3(50, 150, -5));
34 | points.Add(new Vector3(100, 150, 0));
35 |
36 | TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3);
37 |
38 | context.ShowGeometry(face);
39 |
40 | TopoShapeProperty property = new TopoShapeProperty();
41 | property.SetShape(face);
42 |
43 | MessageBox.Show(String.Format("Area: {0}", property.SurfaceArea()));
44 |
45 | return true;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Features.Modeling/Geometry/SolidVolumn.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Modeling.Geometry
10 | {
11 | class SolidVolumn : Feature
12 | {
13 | public SolidVolumn()
14 | {
15 | Name = "Solid.Volumn";
16 | Group = ModelingModule.GroupId;
17 | Category = ModelingModule.GeometryCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 100, 100));
23 | context.ShowGeometry(box);
24 |
25 |
26 | TopoShapeProperty property = new TopoShapeProperty();
27 | property.SetShape(box);
28 |
29 | MessageBox.Show(String.Format("Area: {0}", property.SolidVolume()));
30 |
31 | return true;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Features.Modeling/Geometry/SurfaceArea.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Geometry
9 | {
10 | class QuertySurface : Feature
11 | {
12 | public QuertySurface()
13 | {
14 | Name = "Surface";
15 | Group = ModelingModule.GroupId;
16 | Category = ModelingModule.GeometryCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 | LineStyle lineStyle = new LineStyle();
22 | lineStyle.SetLineWidth(0.5f);
23 | lineStyle.SetColor(ColorValue.RED);
24 |
25 | var points = new List();
26 | points.Add(new Vector3(0, 0, 0));
27 | points.Add(new Vector3(50, 0, 0));
28 | points.Add(new Vector3(100, 0, 0));
29 |
30 | points.Add(new Vector3(0, 50, 0));
31 | points.Add(new Vector3(50, 50, 5));
32 | points.Add(new Vector3(100, 50, -5));
33 |
34 | points.Add(new Vector3(0, 150, 5));
35 | points.Add(new Vector3(50, 150, -5));
36 | points.Add(new Vector3(100, 150, 0));
37 |
38 | TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3);
39 |
40 | context.ShowGeometry(face);
41 |
42 | GeomSurface surface = new GeomSurface();
43 | surface.Initialize(face);
44 | double ufirst = surface.FirstUParameter();
45 | double uLarst = surface.LastUParameter();
46 | double vfirst = surface.FirstVParameter();
47 | double vLast = surface.LastVParameter();
48 |
49 | double ustep = (uLarst - ufirst) * 0.1;
50 | double vstep = (vLast - vfirst) * 0.1;
51 | for (double ii = ufirst; ii <= uLarst; ii += ustep)
52 | for (double jj = vfirst; jj <= vLast; jj += vstep)
53 | {
54 | var data = surface.D1(ii, jj);
55 |
56 | Vector3 pos = data[0];
57 | Vector3 dirU = data[1];
58 | Vector3 dirV = data[2];
59 | Vector3 dir = dirV.CrossProduct(dirU);
60 | //dir.Normalize();
61 | {
62 | TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir * 0.01f);
63 | SceneNode node = context.ShowGeometry(line);
64 |
65 | node.SetLineStyle(lineStyle);
66 | }
67 | }
68 |
69 | return true;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Features.Modeling/ModelingModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using Features.Modeling.Primitive;
7 | using Features.Modeling.Algorithm;
8 | using Features.Modeling.Geometry;
9 |
10 | namespace Features.Modeling
11 | {
12 | public class ModelingModule
13 | {
14 | public static String GroupId = "1. Modeling";
15 | static public String PrimitiveCategoryId = "1.1 Primitive";
16 | static public String BooleanCategoryId = "1.2 Boolean";
17 | static public String FeaturedCategoryId = "1.3 Feature";
18 | static public String AlgorithmCategoryId = "1.4 Algorithm";
19 | static public String GeometryCategoryId = "1.6 Geometry";
20 |
21 | public static void Initialize()
22 | {
23 | FeatureManager.Instance().Add(new Spiral());
24 | FeatureManager.Instance().Add(new RectangleR());
25 | FeatureManager.Instance().Add(new Sphere());
26 | FeatureManager.Instance().Add(new Box());
27 | FeatureManager.Instance().Add(new SurfaceFromPoints());
28 | FeatureManager.Instance().Add(new RectTube());
29 |
30 | FeatureManager.Instance().Add(new MakeCut());
31 | //FeatureManager.Instance().Add(new MakeGlue());
32 | FeatureManager.Instance().Add(new MakeSection());
33 | FeatureManager.Instance().Add(new MakeSplitCurve());
34 |
35 | FeatureManager.Instance().Add(new MakeHoles());
36 | FeatureManager.Instance().Add(new MakeFillet());
37 | FeatureManager.Instance().Add(new MakeRevole());
38 | FeatureManager.Instance().Add(new MakeSweep());
39 | FeatureManager.Instance().Add(new MakePipe());
40 | FeatureManager.Instance().Add(new MakePipe2());
41 | FeatureManager.Instance().Add(new MakeLoft());
42 | FeatureManager.Instance().Add(new MakeEvolved());
43 |
44 | FeatureManager.Instance().Add(new MakeSplit());
45 | FeatureManager.Instance().Add(new SurfaceSection());
46 | FeatureManager.Instance().Add(new ProjectionPlane());
47 | FeatureManager.Instance().Add(new CurveLineIntersection());
48 |
49 | FeatureManager.Instance().Add(new QuertyCurve());
50 | FeatureManager.Instance().Add(new QuertySurface());
51 | FeatureManager.Instance().Add(new CurveLength());
52 | FeatureManager.Instance().Add(new SurfaceArea());
53 | FeatureManager.Instance().Add(new SolidVolumn());
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/Box.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | namespace Features.Modeling.Primitive
8 | {
9 | class Box : PrimitiveFeature
10 | {
11 | public Box()
12 | {
13 | Name = "Box";
14 | }
15 |
16 | public override bool Run(FeatureContext context)
17 | {
18 | TopoShape body = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(10,20,30));
19 |
20 | context.ShowGeometry(body);
21 | return true;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/Primitive.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 |
7 | namespace Features.Modeling.Primitive
8 | {
9 | class PrimitiveFeature : Feature
10 | {
11 | public PrimitiveFeature()
12 | {
13 | Group = ModelingModule.GroupId;
14 | Category = ModelingModule.PrimitiveCategoryId;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/RectTube.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Platform;
2 | using Features.Core;
3 |
4 |
5 | namespace Features.Modeling.Primitive
6 | {
7 | class RectTube : PrimitiveFeature
8 | {
9 | public RectTube()
10 | {
11 | Name = "Rectangel Tube";
12 | }
13 | public override bool Run(FeatureContext context)
14 | {
15 | TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(100, 50, 10, Coordinate3.UNIT_XYZ);
16 | rect = GlobalInstance.BrepTools.MakeFace(rect);
17 |
18 | TopoShape rect2 = GlobalInstance.BrepTools.MakeRectangle(90, 40, 9, Coordinate3.UNIT_XYZ);
19 | rect2 = GlobalInstance.BrepTools.MakeFace(rect2);
20 |
21 | rect2 = GlobalInstance.BrepTools.Translate(rect2, new Vector3(5, 5, 0));
22 |
23 | var cut = GlobalInstance.BrepTools.BooleanCut(rect, rect2);
24 |
25 | var body = GlobalInstance.BrepTools.Extrude(cut, 100, Vector3.UNIT_Z);
26 |
27 | context.ShowGeometry(body);
28 | return true;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/RectangleR.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | namespace Features.Modeling.Primitive
8 | {
9 | class RectangleR : PrimitiveFeature
10 | {
11 | public RectangleR()
12 | {
13 | Name = "Rectangle";
14 | }
15 |
16 | public override bool Run(FeatureContext context)
17 | {
18 | TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(100, 50, 10, Coordinate3.UNIT_XYZ);
19 | rect = GlobalInstance.BrepTools.MakeFace(rect);
20 |
21 | context.ShowGeometry(rect);
22 | return true;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/Sphere.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Modeling.Primitive
9 | {
10 | class Sphere : PrimitiveFeature
11 | {
12 | public Sphere()
13 | {
14 | Name = "Sphere";
15 | }
16 |
17 | public override bool Run(FeatureContext context)
18 | {
19 | TopoShape body = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 10);
20 |
21 | context.ShowGeometry(body);
22 | return true;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/Spiral.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | namespace Features.Modeling.Primitive
8 | {
9 | class Spiral : PrimitiveFeature
10 | {
11 | public Spiral()
12 | {
13 | Name = "Spiral";
14 | }
15 |
16 | public override bool Run(FeatureContext context)
17 | {
18 | TopoShape spiralCurve = GlobalInstance.BrepTools.MakeSpiralCurve(100, 10, 10, Coordinate3.UNIT_XYZ);
19 |
20 | context.ShowGeometry(spiralCurve);
21 | return true;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Features.Modeling/Primitive/Surface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | namespace Features.Modeling.Primitive
8 | {
9 | class SurfaceFromPoints : PrimitiveFeature
10 | {
11 | public SurfaceFromPoints()
12 | {
13 | Name = "Surface.Points";
14 | }
15 |
16 | public override bool Run(FeatureContext context)
17 | {
18 | var points = new List();
19 | points.Add(new Vector3(0, 0, 0));
20 | points.Add(new Vector3(50, 0, 0));
21 | points.Add(new Vector3(100, 0, 0));
22 |
23 | points.Add(new Vector3(0, 50, 0));
24 | points.Add(new Vector3(50, 50, 5));
25 | points.Add(new Vector3(100, 50, -5));
26 |
27 | points.Add(new Vector3(0, 150, 5));
28 | points.Add(new Vector3(50, 150, -5));
29 | points.Add(new Vector3(100, 150, 0));
30 |
31 | TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3);
32 |
33 | context.ShowGeometry(face);
34 | return true;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Features.Modeling/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Features.Modeling")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Features.Modeling")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1dd384ae-97bf-41e7-aed0-000205eae619")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Features.Modeling/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Features.Rendering/Animation/DancingBall.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Rendering.Animation
9 | {
10 | class DancingBall : Feature
11 | {
12 | public DancingBall()
13 | {
14 | Name = "Dancing Ball";
15 | Group = RenderingModule.GroupId;
16 | Category = RenderingModule.AnimationCategoryId;
17 | }
18 |
19 | private float heightOfObject = 0; //记录小球的高度
20 | private float timerOfObject = 0; //记录运动时间
21 | private float speedOfObject = 60; //起始速度
22 | private float xspeed = 10; //X方向的速度
23 | private float distanceX = -125; //X方向的位移
24 | private SceneNode m_Object; //小球的节点
25 | private FaceStyle fs = null;
26 | private AnyCAD.Presentation.RenderWindow3d m_RenderView;
27 | private Random random = new Random();
28 |
29 | private void DancingBall_RenderTick()
30 | {
31 | timerOfObject += 0.5f;
32 |
33 | //z方向的位移
34 | heightOfObject = speedOfObject * timerOfObject - (9.8f * timerOfObject * timerOfObject) * 0.5f;
35 | //x方向的位移
36 | distanceX += xspeed;
37 | if (heightOfObject <= 0.0f)
38 | {
39 | distanceX -= xspeed;
40 | timerOfObject = 0;
41 | xspeed = -xspeed;
42 | heightOfObject = 10;
43 | }
44 |
45 | //设置位移矩阵
46 | Matrix4 trf = GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(distanceX, 0, heightOfObject));
47 | float scaleValue = heightOfObject*0.01f + 1;
48 | Matrix4 scale = GlobalInstance.MatrixBuilder.MakeScale(new Vector3(scaleValue, scaleValue, scaleValue));
49 | m_Object.SetTransform(trf*scale);
50 |
51 |
52 | // Change color
53 | fs.SetColor((int)(random.NextDouble()*100), (int)(random.NextDouble()*100), (int)(random.NextDouble()*100));
54 |
55 | m_RenderView.RequestDraw();
56 | }
57 |
58 |
59 | public override bool Run(FeatureContext context)
60 | {
61 | if (m_Object == null)
62 | {
63 | TopoShape sphere = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 10);
64 | fs = new FaceStyle();
65 | m_Object = context.ShowGeometry(sphere);
66 | m_Object.SetFaceStyle(fs);
67 | }
68 | else
69 | {
70 | context.ShowSceneNode(m_Object);
71 | }
72 |
73 | m_RenderView = context.RenderView;
74 | m_RenderView.RenderTick += new AnyCAD.Presentation.RenderEventHandler(DancingBall_RenderTick);
75 | return false;
76 | }
77 |
78 | public override void OnExit(FeatureContext context)
79 | {
80 | m_RenderView.RenderTick -= new AnyCAD.Presentation.RenderEventHandler(DancingBall_RenderTick);
81 | m_RenderView = null;
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Features.Rendering/Camera/PerspectiveTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 |
13 | class PerspectiveTest : Feature
14 | {
15 | public PerspectiveTest()
16 | {
17 | Name = "Perspective";
18 | Group = RenderingModule.GroupId;
19 | Category = RenderingModule.CameraCategoryId;
20 | }
21 |
22 | public override bool Run(FeatureContext context)
23 | {
24 |
25 | context.RenderView.ExecuteCommand("ProjectionMode");
26 |
27 | return true;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Features.Rendering/Camera/StdCameraTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class StdTopCameraTest : Feature
13 | {
14 | public StdTopCameraTest()
15 | {
16 | Name = "Top";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.CameraCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | context.RenderView.SetStandardView(EnumStandardView.SV_Top);
24 | return true;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Features.Rendering/Features.Rendering.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x64
7 | 8.0.30703
8 | 2.0
9 | {E2A25EAF-30D9-4A07-BC33-B89BB2F874ED}
10 | Library
11 | Properties
12 | Features.Rendering
13 | Features.Rendering
14 | v4.0
15 | 512
16 |
17 |
18 |
19 |
20 | x64
21 | true
22 | full
23 | false
24 | ..\bin\x64\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | x64
31 | pdbonly
32 | true
33 | ..\bin\x64\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Exchange.Net.dll
41 | False
42 |
43 |
44 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Foundation.Net.dll
45 | False
46 |
47 |
48 | ..\packages\AnyCAD.Net.Pro.2020.0.1\lib\x64\AnyCAD.Presentation.Net.dll
49 | False
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | {C3DEEB62-2C24-41FC-823F-28B0B8AB303B}
86 | Features.Core
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
96 |
97 |
98 |
99 |
106 |
--------------------------------------------------------------------------------
/Features.Rendering/Import/ImportDXF.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class ImportDxf : Feature
13 | {
14 | public ImportDxf()
15 | {
16 | Name = "DXF";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.ImportCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | OpenFileDialog dlg = new OpenFileDialog();
24 | dlg.Filter = "DXF File (*.dxf)|*.dxf||";
25 | if(DialogResult.OK != dlg.ShowDialog())
26 | return true;
27 |
28 | ShowShapeReaderContext renderContext = new ShowShapeReaderContext(context.RenderView.SceneManager);
29 | DxfReader reader = new DxfReader();
30 | reader.Read(dlg.FileName, renderContext, false);
31 |
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Features.Rendering/Import/ImportIges.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class ImportIges : Feature
13 | {
14 | public ImportIges()
15 | {
16 | Name = "IGES";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.ImportCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | OpenFileDialog dlg = new OpenFileDialog();
24 | dlg.Filter = "IGES File (*.igs;*.iges)|*.igs;*.iges||";
25 | if(DialogResult.OK != dlg.ShowDialog())
26 | return true;
27 |
28 | ShowShapeReaderContext renderContext = new ShowShapeReaderContext(context.RenderView.SceneManager);
29 | IgesReader reader = new IgesReader();
30 | reader.Read(dlg.FileName, renderContext);
31 |
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Features.Rendering/Import/ImportStep.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class ImportStep : Feature
13 | {
14 | public ImportStep()
15 | {
16 | Name = "STEP";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.ImportCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | OpenFileDialog dlg = new OpenFileDialog();
24 | dlg.Filter = "Step File (*.stp;*.step)|*.stp;*.step||";
25 | if(DialogResult.OK != dlg.ShowDialog())
26 | return true;
27 |
28 | ShowShapeReaderContext renderContext = new ShowShapeReaderContext(context.RenderView.SceneManager);
29 | StepReader reader = new StepReader();
30 | reader.Read(dlg.FileName, renderContext);
31 |
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Features.Rendering/Import/ImportStl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class ImportStl : Feature
13 | {
14 | public ImportStl()
15 | {
16 | Name = "STL";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.ImportCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | OpenFileDialog dlg = new OpenFileDialog();
24 | dlg.Filter = "STL File (*.stl)|*.stl||";
25 | if(DialogResult.OK != dlg.ShowDialog())
26 | return true;
27 |
28 | ModelReader reader = new ModelReader();
29 | GroupSceneNode node = reader.LoadFile(new Path(dlg.FileName));
30 | context.ShowSceneNode(node);
31 |
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Features.Rendering/ManageScene/ListNodes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Rendering.NodeObject
10 | {
11 | class ListNodes : Feature
12 | {
13 | public ListNodes()
14 | {
15 | Name = "List Nodes";
16 | Group = RenderingModule.GroupId;
17 | Category = RenderingModule.SceneCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(10, 10, 10));
23 | RenderableEntity entity = GlobalInstance.TopoShapeConvert.ToEntity(box, 0);
24 | for (int ii = 0; ii < 10; ++ii)
25 | {
26 | EntitySceneNode node = new EntitySceneNode();
27 | node.SetEntity(entity);
28 | Matrix4 trf = GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(11 * ii, 0, 0));
29 | node.SetTransform(trf);
30 |
31 | context.ShowSceneNode(node);
32 | }
33 | context.RequestDraw();
34 |
35 | SceneNodeIterator itr = context.RenderView.SceneManager.NewSceneNodeIterator();
36 | String msg = "Node Ids: ";
37 | while (itr.More())
38 | {
39 | SceneNode node = itr.Next();
40 | msg += String.Format(" {0}", node.GetId().AsInt());
41 | }
42 |
43 | MessageBox.Show(msg);
44 |
45 | return true;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Features.Rendering/ManageScene/QuerySelection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Rendering.NodeObject
10 | {
11 | class QuerySelectionTest : Feature
12 | {
13 | public QuerySelectionTest()
14 | {
15 | Name = "Query Selection";
16 | Group = RenderingModule.GroupId;
17 | Category = RenderingModule.SceneCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | {
23 | TopoShape cone = GlobalInstance.BrepTools.MakeDish(100, 30, Vector3.ZERO);
24 | SceneNode node = context.ShowGeometry(cone);
25 | node.SetName("My Cone");
26 | context.RenderView.SceneManager.SelectNode(node);
27 |
28 | context.RequestDraw();
29 | }
30 |
31 | SelectedEntityQuery query = new SelectedEntityQuery();
32 | context.RenderView.QuerySelection(query);
33 | SceneNode node2 = query.GetRootNode();
34 | if (node2 != null)
35 | {
36 | MessageBox.Show(String.Format("Selected Node: {0}", node2.GetName()));
37 | }
38 |
39 |
40 | return true;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Features.Rendering/ManageScene/RemoveNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Rendering.NodeObject
10 | {
11 | class RemoveNode : Feature
12 | {
13 | public RemoveNode()
14 | {
15 | Name = "Remove Node";
16 | Group = RenderingModule.GroupId;
17 | Category = RenderingModule.SceneCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | {
23 | ArrowWidget arrow = new ArrowWidget();
24 | context.ShowSceneNode(arrow);
25 | context.RenderView.FitAll();
26 | context.RequestDraw();
27 | }
28 |
29 |
30 | ElementId id = context.CurrentId;
31 | MessageBox.Show("Remove Node");
32 |
33 | SceneManager sceneMgr = context.RenderView.SceneManager;
34 | SceneNode node = sceneMgr.FindNode(id);
35 | if (node != null)
36 | {
37 | sceneMgr.RemoveNode(node);
38 | }
39 |
40 | return true;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/ArrowNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Rendering.NodeObject
10 | {
11 |
12 |
13 | class ArrowNode : Feature
14 | {
15 | public ArrowNode()
16 | {
17 | Name = "Arrow.FixedSize";
18 | Group = RenderingModule.GroupId;
19 | Category = RenderingModule.NodeCategoryId;
20 | }
21 |
22 | public override bool Run(FeatureContext context)
23 | {
24 |
25 | ArrowWidget arrow = new ArrowWidget();
26 | arrow.SetFixedSize(true);
27 |
28 | context.ShowSceneNode(arrow);
29 |
30 |
31 | return true;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/AxesNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Rendering.NodeObject
9 | {
10 | class AxesNodeObject : Feature
11 | {
12 | public AxesNodeObject()
13 | {
14 | Name = "Axes";
15 | Group = RenderingModule.GroupId;
16 | Category = RenderingModule.NodeCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | AxesWidget node = new AxesWidget();
23 | node.SetArrowText((int)EnumAxesDirection.Axes_X, "");
24 | node.SetArrowText((int)EnumAxesDirection.Axes_Y, "");
25 | node.SetArrowText((int)EnumAxesDirection.Axes_Z, "");
26 |
27 | context.ShowSceneNode(node);
28 |
29 |
30 | return true;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/ColoredFace.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Rendering.NodeObject
9 | {
10 | class ColoredFaceObject : Feature
11 | {
12 | public ColoredFaceObject()
13 | {
14 | Name = "Colorful Face";
15 | Group = RenderingModule.GroupId;
16 | Category = RenderingModule.NodeCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | TopoShape circle = GlobalInstance.BrepTools.MakeCircle(Vector3.ZERO, 100, Vector3.UNIT_Z);
23 | TopoShape face = GlobalInstance.BrepTools.MakeFace(circle);
24 |
25 | FaceTriangulation ft = new FaceTriangulation();
26 | ft.SetTolerance(5);
27 | ft.Perform(face);
28 | float[] points = ft.GetVertexBuffer();
29 | int pointCount = points.Length / 3;
30 | uint[] indexBuffer = ft.GetIndexBuffer();
31 | int faceCount = indexBuffer.Length / 3;
32 | float[] normals = ft.GetNormalBuffer();
33 |
34 |
35 | float[] colorBuffer = new float[pointCount * 4];
36 |
37 | Random num = new Random();
38 | for (int ii = 0; ii < pointCount; ++ii)
39 | {
40 | int idx = ii * 4;
41 | colorBuffer[idx] = num.Next(0, 256) / 256.0f;
42 | colorBuffer[idx + 1] = num.Next(0, 256) / 256.0f;
43 | colorBuffer[idx + 2] = num.Next(0, 256) / 256.0f;
44 | colorBuffer[idx + 3] = 1;
45 | }
46 |
47 | RenderableEntity entity = GlobalInstance.TopoShapeConvert.CreateColoredFaceEntity(points, indexBuffer, normals, colorBuffer, face.GetBBox());
48 |
49 | EntitySceneNode node = new EntitySceneNode();
50 | node.SetEntity(entity);
51 |
52 | context.ShowSceneNode(node);
53 |
54 | //////////////////////////////////////////////////////////////////////////
55 | // Code to get the mesh
56 | /*
57 | for (int ii = 0; ii < faceCount; ++ii)
58 | {
59 | int p0 = (int)indexBuffer[ii * 3];
60 | int p1 = (int)indexBuffer[ii * 3 + 1];
61 | int p2 = (int)indexBuffer[ii * 3 + 2];
62 |
63 | Vector3 pt0 = new Vector3(points[p0 * 3], points[p0 * 3 + 1], points[p0 * 3 + 2]);
64 | Vector3 pt1 = new Vector3(points[p1 * 3], points[p1 * 3 + 1], points[p1 * 3 + 2]);
65 | Vector3 pt2 = new Vector3(points[p2 * 3], points[p2 * 3 + 1], points[p2 * 3 + 2]);
66 |
67 | // ....
68 | // use the same way to get the normal data for each point.
69 | }
70 | * */
71 |
72 |
73 | return true;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/PointCloud.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Rendering.NodeObject
9 | {
10 | class PointCloudObject : Feature
11 | {
12 | public PointCloudObject()
13 | {
14 | Name = "Point Cloud";
15 | Group = RenderingModule.GroupId;
16 | Category = RenderingModule.NodeCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | const float len = 100.0f;
23 | const int nDim = 50;
24 | float[] pointBuffer = new float[nDim * nDim * nDim * 3];
25 | float[] colorBuffer = new float[nDim * nDim * nDim * 3];
26 | int idx = -1;
27 | for (int ii = 0; ii < nDim; ++ii)
28 | for (int jj = 0; jj < nDim; ++jj)
29 | for (int kk = 0; kk < nDim; ++kk)
30 | {
31 | ++idx;
32 | pointBuffer[idx * 3] = ii * len;
33 | pointBuffer[idx * 3 + 1] = jj * len;
34 | pointBuffer[idx * 3 + 2] = kk * len;
35 |
36 | colorBuffer[idx * 3] = ((float)ii) / ((float)nDim);
37 | colorBuffer[idx * 3 + 1] = ((float)jj) / ((float)nDim);
38 | colorBuffer[idx * 3 + 2] = ((float)kk) / ((float)nDim);
39 | }
40 |
41 | PointStyle pointStyle = new PointStyle();
42 | pointStyle.SetPointSize(4.0f);
43 |
44 | PointCloudNode pcn = new PointCloudNode();
45 | pcn.SetPointStyle(pointStyle);
46 | pcn.SetPoints(pointBuffer);
47 | pcn.SetColors(colorBuffer);
48 | pcn.ComputeBBox();
49 | AABox bbox = pcn.GetBBox();
50 | Vector3 pt = bbox.MinPt;
51 |
52 | context.ShowSceneNode(pcn);
53 |
54 |
55 | return true;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/PointMarker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Rendering.NodeObject
9 | {
10 | class PointMarker : Feature
11 | {
12 | public PointMarker()
13 | {
14 | Name = "Point Marker";
15 | Group = RenderingModule.GroupId;
16 | Category = RenderingModule.NodeCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | const float len = 100.0f;
23 | const int nDim = 50;
24 | float[] pointBuffer = new float[nDim * nDim * nDim * 3];
25 | float[] colorBuffer = new float[nDim * nDim * nDim * 3];
26 | int idx = -1;
27 | for (int ii = 0; ii < nDim; ++ii)
28 | for (int jj = 0; jj < nDim; ++jj)
29 | for (int kk = 0; kk < nDim; ++kk)
30 | {
31 | ++idx;
32 | pointBuffer[idx * 3] = ii * len;
33 | pointBuffer[idx * 3 + 1] = jj * len;
34 | pointBuffer[idx * 3 + 2] = kk * len;
35 |
36 | colorBuffer[idx * 3] = ((float)ii) / ((float)nDim);
37 | colorBuffer[idx * 3 + 1] = ((float)jj) / ((float)nDim);
38 | colorBuffer[idx * 3 + 2] = ((float)kk) / ((float)nDim);
39 | }
40 |
41 | PointStyle pointStyle = new PointStyle();
42 | //pointStyle.SetPointSize(4.0f);
43 | pointStyle.SetMarker("cross");
44 |
45 | PointCloudNode pcn = new PointCloudNode();
46 | pcn.SetPointStyle(pointStyle);
47 | pcn.SetPoints(pointBuffer);
48 | pcn.SetColors(colorBuffer);
49 | pcn.ComputeBBox();
50 | AABox bbox = pcn.GetBBox();
51 | Vector3 pt = bbox.MinPt;
52 |
53 | context.ShowSceneNode(pcn);
54 |
55 |
56 | return true;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/ShapeCopies.cs:
--------------------------------------------------------------------------------
1 | using AnyCAD.Platform;
2 | using Features.Core;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace Features.Rendering.NodeObject
10 | {
11 | class ShapeCopies : Feature
12 | {
13 | public ShapeCopies()
14 | {
15 | Name = "Copy.Shapes";
16 | Group = RenderingModule.GroupId;
17 | Category = RenderingModule.NodeCategoryId;
18 | }
19 |
20 | public override bool Run(FeatureContext context)
21 | {
22 | OpenFileDialog dlg = new OpenFileDialog();
23 | dlg.Filter = "IGES File (*.igs;*.iges)|*.igs;*.iges||";
24 | if (DialogResult.OK != dlg.ShowDialog())
25 | return true;
26 |
27 | var shape = GlobalInstance.BrepTools.LoadFile(new Path(dlg.FileName));
28 |
29 | var size = shape.GetBBox().Size();
30 |
31 | var entity = GlobalInstance.TopoShapeConvert.ToEntity(shape, 1);
32 |
33 | for(int ii=0; ii<7; ++ii)
34 | {
35 | for(int jj=0; jj<7; ++jj)
36 | {
37 | var node = new EntitySceneNode();
38 | node.SetEntity(entity);
39 |
40 | var trf = GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(size.X* ii, size.Y * jj, 0));
41 | node.SetTransform(trf);
42 |
43 | context.ShowSceneNode(node);
44 | }
45 |
46 | }
47 |
48 | return true;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Features.Rendering/NodeObject/Text3dObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 |
8 | namespace Features.Rendering.NodeObject
9 | {
10 | class Text3dObject : Feature
11 | {
12 | public Text3dObject()
13 | {
14 | Name = "Text.3D";
15 | Group = RenderingModule.GroupId;
16 | Category = RenderingModule.NodeCategoryId;
17 | }
18 |
19 | public override bool Run(FeatureContext context)
20 | {
21 |
22 | Text3dNode textNode = new Text3dNode();
23 | textNode.SetFontName("FangSong (TrueType)");
24 | textNode.SetText("1234565\nabcdefg\n我爱CAD");
25 | textNode.SetLineSpace(10);
26 |
27 | Coordinate3 coord = new Coordinate3();
28 | coord.Origion = new Vector3(100, 100, 0);
29 | coord.X = new Vector3(1, 1, 0);
30 | coord.X.Normalize();
31 | coord.Y = coord.Z.CrossProduct(coord.X);
32 |
33 | Matrix4 trf = GlobalInstance.MatrixBuilder.ToWorldMatrix(coord);
34 | textNode.SetTransform(trf);
35 | textNode.Update();
36 |
37 | context.ShowSceneNode(textNode);
38 |
39 |
40 | return true;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Features.Rendering/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Features.Rendering")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Features.Rendering")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("81aab699-eeb4-49f6-bcb7-f72e2085d66c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Features.Rendering/RenderStyle/FaceStyleTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class FaceStyleTest : Feature
13 | {
14 | public FaceStyleTest()
15 | {
16 | Name = "FaceStyle";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.StyleCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 2, 200));
24 | {
25 | SceneNode node = context.ShowGeometry(box);
26 | FaceStyle fs = new FaceStyle();
27 | fs.SetColor(new ColorValue(0.5f, 0.5f, 1.0f, 0.5f));
28 | fs.SetTransparent(true);
29 | node.SetFaceStyle(fs);
30 | }
31 | context.RequestDraw();
32 |
33 |
34 | OpenFileDialog dlg = new OpenFileDialog();
35 | dlg.Filter = "Texture File (*.jpg;*.png)|*.jpg;*png||";
36 | if (DialogResult.OK == dlg.ShowDialog())
37 | {
38 | SceneNode node2 = context.ShowGeometry(box);
39 | node2.SetTransform(GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(0, 50, 0)));
40 | FaceStyle fs2 = new FaceStyle();
41 | Texture tex = new Texture();
42 | tex.SetName(dlg.SafeFileName);
43 | tex.SetFilePath(new Path(dlg.FileName));
44 |
45 | fs2.SetTexture(0, tex);
46 |
47 | node2.SetFaceStyle(fs2);
48 | }
49 |
50 | return true;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Features.Rendering/RenderStyle/LineStyleTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using AnyCAD.Platform;
7 | using System.Windows.Forms;
8 | using AnyCAD.Exchange;
9 |
10 | namespace Features.Rendering.Exchange
11 | {
12 | class LineStyleTest : Feature
13 | {
14 | public LineStyleTest()
15 | {
16 | Name = "LineStyle";
17 | Group = RenderingModule.GroupId;
18 | Category = RenderingModule.StyleCategoryId;
19 | }
20 |
21 | public override bool Run(FeatureContext context)
22 | {
23 | TopoShape shape = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, 100, 10, 180, Vector3.UNIT_Z);
24 | SceneNode node = context.ShowGeometry(shape);
25 | LineStyle ls = new LineStyle();
26 | ls.SetLineWidth(2);
27 | ls.SetColor(0, 255, 0);
28 | ls.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
29 | node.SetLineStyle(ls);
30 |
31 | return true;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Features.Rendering/RenderingModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Features.Core;
6 | using Features.Rendering.NodeObject;
7 | using Features.Rendering.Animation;
8 | using Features.Rendering.Exchange;
9 |
10 | namespace Features.Rendering
11 | {
12 | public class RenderingModule
13 | {
14 | public static String GroupId = "2. Rendering";
15 | static public String NodeCategoryId = "2.1 Node";
16 | static public String SceneCategoryId = "2.2 Scene";
17 | static public String AnimationCategoryId = "2.3 Animation";
18 | static public String StyleCategoryId = "2.4 Style";
19 | static public String CameraCategoryId = "2.5 Camera";
20 | static public String ImportCategoryId = "2.6 Import";
21 |
22 | public static void Initialize()
23 | {
24 | FeatureManager.Instance().Add(new ArrowNode());
25 | FeatureManager.Instance().Add(new AxesNodeObject());
26 | FeatureManager.Instance().Add(new ColoredFaceObject());
27 | FeatureManager.Instance().Add(new Text3dObject());
28 | FeatureManager.Instance().Add(new PointCloudObject());
29 | FeatureManager.Instance().Add(new PointMarker());
30 | FeatureManager.Instance().Add(new ShapeCopies());
31 |
32 | FeatureManager.Instance().Add(new RemoveNode());
33 | FeatureManager.Instance().Add(new ListNodes());
34 | FeatureManager.Instance().Add(new QuerySelectionTest());
35 |
36 | FeatureManager.Instance().Add(new DancingBall());
37 |
38 | FeatureManager.Instance().Add(new FaceStyleTest());
39 | FeatureManager.Instance().Add(new LineStyleTest());
40 |
41 | FeatureManager.Instance().Add(new StdTopCameraTest());
42 | FeatureManager.Instance().Add(new PerspectiveTest());
43 |
44 | FeatureManager.Instance().Add(new ImportStep());
45 | FeatureManager.Instance().Add(new ImportDxf());
46 | FeatureManager.Instance().Add(new ImportIges());
47 | FeatureManager.Instance().Add(new ImportStl());
48 |
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Features.Rendering/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The Featrued App for AnyCAD .Net Graphics SDK
2 |
3 | ### Code for:
4 | - Modeling features
5 | - Rendering features
6 | - Comprehensive usage
7 |
8 | 
9 |
10 | ### Download
11 |
12 | http://www.anycad.net/docs/download.html
--------------------------------------------------------------------------------
/bin/Readme.txt:
--------------------------------------------------------------------------------
1 | Copy anycad sdk here
2 |
3 | ---- bin
4 | |--------x64
5 | |--------x86
--------------------------------------------------------------------------------