├── .gitignore
├── ChronoSolidworks.sln
├── ChronoSolidworksAddIn
├── .gitignore
├── ChModelExporter.cs
├── ChModelExporterCSharp.cs
├── ChModelExporterCpp.cs
├── ChModelExporterJson.cs
├── ChModelExporterPython.cs
├── ChModelExporterText.cs
├── ChScale.cs
├── ChronoEngine_SwAddin.cs
├── ChronoEngine_SwAddin.cs.rej
├── ChronoSolidworksAddIn.csproj
├── ChronoSolidworksAddIn.csproj.user
├── ConvertToCollisionShapes.cs
├── ConvexDecomp2.Designer.cs
├── ConvexDecomp2.cs
├── ConvexDecomp2.resx
├── ConvexDecompForm.Designer.cs
├── ConvexDecompForm.cs
├── ConvexDecompForm.resx
├── EditChMotor.Designer.cs
├── EditChMotor.cs
├── EditChMotor.resx
├── EditChSDA.Designer.cs
├── EditChSDA.cs
├── EditChSDA.resx
├── EditCollisionParameters.Designer.cs
├── EditCollisionParameters.cs
├── EditCollisionParameters.resx
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── SidePanel.Designer.cs
├── SidePanel.cs
├── SidePanel.resx
├── TesselateToObj.cs
├── app.config
├── packages.config
└── signature.snk
├── LICENSE
├── README.md
├── decomposition_hacd_CLI
├── AssemblyInfo.cpp
├── Backup
│ └── hacd_CLI.sln
├── ReadMe.txt
├── app.ico
├── app.rc
├── hacd.snk
├── hacd
│ ├── inc
│ │ ├── hacdCircularList.h
│ │ ├── hacdCircularList.inl
│ │ ├── hacdGraph.h
│ │ ├── hacdHACD.h
│ │ ├── hacdICHull.h
│ │ ├── hacdManifoldMesh.h
│ │ ├── hacdMeshDecimator.h
│ │ ├── hacdMicroAllocator.h
│ │ ├── hacdRaycastMesh.h
│ │ ├── hacdSArray.h
│ │ ├── hacdVector.h
│ │ ├── hacdVector.inl
│ │ └── hacdVersion.h
│ └── src
│ │ ├── hacdGraph.cpp
│ │ ├── hacdHACD.cpp
│ │ ├── hacdICHull.cpp
│ │ ├── hacdManifoldMesh.cpp
│ │ ├── hacdMeshDecimator.cpp
│ │ ├── hacdMicroAllocator.cpp
│ │ └── hacdRaycastMesh.cpp
├── hacd_CLI.cpp
├── hacd_CLI.h
├── hacd_CLI.vcproj
├── hacd_CLI.vcxproj
├── hacd_CLI.vcxproj.filters
├── resource.h
├── vhacd
│ ├── inc
│ │ ├── btAlignedAllocator.h
│ │ ├── btAlignedObjectArray.h
│ │ ├── btConvexHullComputer.h
│ │ ├── btMinMax.h
│ │ ├── btScalar.h
│ │ ├── btVector3.h
│ │ ├── kdtree.h
│ │ ├── triangle.h
│ │ ├── vhacdGraph.h
│ │ ├── vhacdHACD.h
│ │ ├── vhacdMaterial.h
│ │ ├── vhacdMesh.h
│ │ ├── vhacdMeshDecimator.h
│ │ ├── vhacdSArray.h
│ │ ├── vhacdVector.h
│ │ ├── vhacdVector.inl
│ │ └── vhacdVersion.h
│ └── src
│ │ ├── btAlignedAllocator.cpp
│ │ ├── btConvexHullComputer.cpp
│ │ ├── kdtree.c
│ │ ├── triangle.c
│ │ ├── vhacdGraph.cpp
│ │ ├── vhacdHACD.cpp
│ │ ├── vhacdMesh.cpp
│ │ └── vhacdMeshDecimator.cpp
├── vhacd_CLI.cpp
└── vhacd_CLI.h
├── installer
├── SetupModern20.bmp
└── installer_addin.iss
├── packages
└── Newtonsoft.Json.13.0.3
│ ├── .signature.p7s
│ ├── LICENSE.md
│ ├── Newtonsoft.Json.13.0.3.nupkg
│ ├── README.md
│ ├── lib
│ ├── net20
│ │ └── Newtonsoft.Json.xml
│ ├── net35
│ │ └── Newtonsoft.Json.xml
│ ├── net40
│ │ └── Newtonsoft.Json.xml
│ ├── net45
│ │ └── Newtonsoft.Json.xml
│ ├── net6.0
│ │ └── Newtonsoft.Json.xml
│ ├── netstandard1.0
│ │ └── Newtonsoft.Json.xml
│ ├── netstandard1.3
│ │ └── Newtonsoft.Json.xml
│ └── netstandard2.0
│ │ └── Newtonsoft.Json.xml
│ └── packageIcon.png
└── to_put_in_app_dir
├── ChronoSolidworksImportTemplate
├── CMakeLists.txt
├── solid_import_cpp.cpp
├── solid_import_json.cpp
├── solid_import_pychrono.py.in
└── solid_import_pyparser.cpp
├── _template_POV.pov
├── data
├── fonts
│ ├── arial8.xml
│ └── arial80.bmp
├── logo_pychrono_alpha.png
└── skybox
│ ├── sky_dn.jpg
│ ├── sky_lf.jpg
│ └── sky_up.jpg
├── examples
├── addin_tester
│ ├── addin_tester_simulation.py
│ └── cad
│ │ ├── FlexibleSubAssem.SLDASM
│ │ ├── MainAssembly.SLDASM
│ │ ├── Part1.SLDPRT
│ │ ├── Part10.SLDPRT
│ │ ├── Part11.SLDPRT
│ │ ├── Part12.SLDPRT
│ │ ├── Part2.SLDPRT
│ │ ├── Part3.SLDPRT
│ │ ├── Part4.SLDPRT
│ │ ├── Part5.SLDPRT
│ │ ├── Part6.SLDPRT
│ │ ├── Part7.SLDPRT
│ │ ├── Part8.SLDPRT
│ │ ├── Part9.SLDPRT
│ │ └── RigidSubAssem.SLDASM
├── collisions
│ ├── capital.sldprt
│ ├── column.sldprt
│ ├── demo_SW_collisions.py
│ └── portal.SLDASM
├── conveyor
│ ├── assembly_conveyor.SLDASM
│ ├── concrete.jpeg
│ └── demo_SW_conveyor.py
├── engine
│ ├── ConRod-Study 2.LOG
│ ├── ConRod.DSP
│ ├── ConRod.GEN
│ ├── ConRod.MAS
│ ├── ConRod.TTP
│ ├── ConRod.sldprt
│ ├── Crankshaft.SLDPRT
│ ├── Engine.sldasm
│ ├── Engine4c.sldasm
│ ├── Piston.sldprt
│ ├── X.BAT
│ ├── demo_SW_engine.py
│ └── piston_rod.sldasm
└── spider_robot
│ ├── ArmBase.sldprt
│ ├── M-410iB-300 .SLDASM
│ ├── M-410iB-300-02.SLDPRT
│ ├── M-410iB-300-03.SLDPRT
│ ├── M-410iB-300-04.SLDPRT
│ ├── M-410iB-300-05.SLDPRT
│ ├── M-410iB-300-06.SLDPRT
│ ├── M-410iB-300-07.SLDPRT
│ ├── M-410iB-300-08.SLDPRT
│ ├── M-410iB-300-09.SLDPRT
│ ├── M-410iB-300-10.SLDPRT
│ ├── M-410iB-300-11.SLDPRT
│ ├── M-410iB-300-12.SLDPRT
│ ├── M-410iB-300-13.SLDPRT
│ ├── SPIDER_ROBOT.SLDASM
│ └── demo_SW_spider_robot.py
├── icons
├── ChronoEngineAddIn_128.png
├── ChronoEngineAddIn_20.png
├── ChronoEngineAddIn_32.png
├── ChronoEngineAddIn_40.png
├── ChronoEngineAddIn_64.png
└── ChronoEngineAddIn_96.png
└── run_test.py
/.gitignore:
--------------------------------------------------------------------------------
1 | ##---------------------------------------------------
2 | ## Directories
3 | ##---------------------------------------------------
4 |
5 | # Where you build the src
6 | /bin
7 | /obj
8 | /.vs
9 |
10 | ##---------------------------------------------------
11 | ## Visual Studio
12 | ##---------------------------------------------------
13 |
14 | # User settings of solution
15 | *.suo
16 | decomposition_hacd_CLI/x64/
17 | decomposition_hacd_CLI/.vs/
18 | chrono-solidworks_install/
19 | x64/
20 | csharp_source/
21 |
--------------------------------------------------------------------------------
/ChronoSolidworks.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.5.33516.290
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChronoSolidworksAddIn", "ChronoSolidworksAddIn\ChronoSolidworksAddIn.csproj", "{E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {C457BA60-8F07-4664-90E1-A4E2040AD640} = {C457BA60-8F07-4664-90E1-A4E2040AD640}
9 | EndProjectSection
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hacd_CLI", "decomposition_hacd_CLI\hacd_CLI.vcxproj", "{C457BA60-8F07-4664-90E1-A4E2040AD640}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Debug|x64 = Debug|x64
17 | Debug|x86 = Debug|x86
18 | Release|Any CPU = Release|Any CPU
19 | Release|x64 = Release|x64
20 | Release|x86 = Release|x86
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Debug|x64.ActiveCfg = Debug|x64
26 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Debug|x64.Build.0 = Debug|x64
27 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Debug|x86.ActiveCfg = Debug|Any CPU
28 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Debug|x86.Build.0 = Debug|Any CPU
29 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Release|x64.ActiveCfg = Release|x64
32 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Release|x64.Build.0 = Release|x64
33 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Release|x86.ActiveCfg = Release|Any CPU
34 | {E615EBB3-8A0B-4A1D-A8DA-585BAFA8A8C8}.Release|x86.Build.0 = Release|Any CPU
35 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|Any CPU.ActiveCfg = Debug|x64
36 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|Any CPU.Build.0 = Debug|x64
37 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|x64.ActiveCfg = Debug|x64
38 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|x64.Build.0 = Debug|x64
39 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|x86.ActiveCfg = Debug|Win32
40 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|x86.Build.0 = Debug|Win32
41 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|Any CPU.ActiveCfg = Release|x64
42 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|Any CPU.Build.0 = Release|x64
43 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|x64.ActiveCfg = Release|x64
44 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|x64.Build.0 = Release|x64
45 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|x86.ActiveCfg = Release|Win32
46 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|x86.Build.0 = Release|Win32
47 | EndGlobalSection
48 | GlobalSection(SolutionProperties) = preSolution
49 | HideSolutionNode = FALSE
50 | EndGlobalSection
51 | GlobalSection(ExtensibilityGlobals) = postSolution
52 | SolutionGuid = {55B07C67-A57D-4DF0-8802-441E0B499CA0}
53 | EndGlobalSection
54 | EndGlobal
55 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/.gitignore:
--------------------------------------------------------------------------------
1 | ##---------------------------------------------------
2 | ## Directories
3 | ##---------------------------------------------------
4 |
5 | # Where you build the src
6 | /bin
7 | /obj
8 |
9 | ##---------------------------------------------------
10 | ## Visual Studio
11 | ##---------------------------------------------------
12 |
13 | # User settings of solution
14 | *.suo
15 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ChModelExporterText.cs:
--------------------------------------------------------------------------------
1 | using ChronoEngine_SwAddin;
2 | using SolidWorks.Interop.sldworks;
3 | using SolidWorks.Interop.swconst;
4 | using System;
5 | using System.Collections;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using static ChronoEngineAddin.ChModelExporter;
12 |
13 | namespace ChronoEngineAddin
14 | {
15 | internal class ChModelExporterText
16 | {
17 |
18 | string asciitext = "";
19 |
20 |
21 | protected ChronoEngine_SwAddin.SWIntegration m_swIntegration;
22 | protected string m_saveDirShapes = "";
23 | protected string m_saveFilename = "";
24 |
25 | public ChModelExporterText(ChronoEngine_SwAddin.SWIntegration swIntegration, string save_dir_shapes, string save_filename)
26 | {
27 | m_saveDirShapes = save_dir_shapes;
28 | m_saveFilename = save_filename;
29 | m_swIntegration = swIntegration;
30 | }
31 |
32 | public void Export()
33 | {
34 | ModelDoc2 swModel;
35 | ConfigurationManager swConfMgr;
36 | Configuration swConf;
37 | Component2 swRootComp;
38 |
39 | swModel = (ModelDoc2)m_swIntegration.m_swApplication.ActiveDoc;
40 | swConfMgr = (ConfigurationManager)swModel.ConfigurationManager;
41 | swConf = (Configuration)swConfMgr.ActiveConfiguration;
42 | swRootComp = (Component2)swConf.GetRootComponent3(true);
43 |
44 | asciitext = "# Dump hierarchy from SolidWorks \n" +
45 | "# Assembly: " + swModel.GetPathName() + "\n\n\n";
46 |
47 | // The root component (root assembly) cannot work in DumpTraverseComponent()
48 | // cause SW api limit, so call feature traversal using this custom step:
49 | Feature swFeat = (Feature)swModel.FirstFeature();
50 | DumpTraverseFeatures(swFeat, 1, ref asciitext);
51 |
52 | // Traverse all sub components
53 | if (swModel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY)
54 | {
55 | DumpTraverseComponent(swRootComp, 1, ref asciitext);
56 | }
57 |
58 | string asciitext_filename = System.IO.Path.GetDirectoryName(m_saveFilename) + "\\" + System.IO.Path.GetFileNameWithoutExtension(m_saveFilename) + "_shapes/"
59 | + System.IO.Path.GetFileNameWithoutExtension(m_saveFilename) + ".txt";
60 |
61 | FileStream dumpstream = new FileStream(asciitext_filename, FileMode.Create, FileAccess.ReadWrite);
62 | StreamWriter dumpwriter = new StreamWriter(dumpstream);
63 | dumpwriter.Write(asciitext);
64 | dumpwriter.Flush();
65 | dumpstream.Close();
66 | }
67 |
68 | public void DumpTraverseFeatures(Feature swFeat, long nLevel, ref string asciitext)
69 | {
70 | Feature swSubFeat;
71 | string sPadStr = " ";
72 | long i = 0;
73 |
74 | for (i = 0; i <= nLevel; i++)
75 | {
76 | sPadStr = sPadStr + " ";
77 | }
78 |
79 | while ((swFeat != null))
80 | {
81 | asciitext += sPadStr + " -" + swFeat.Name + " [" + swFeat.GetTypeName2() + "]" + "\n";
82 | swSubFeat = (Feature)swFeat.GetFirstSubFeature();
83 | if ((swSubFeat != null))
84 | {
85 | DumpTraverseFeatures(swSubFeat, nLevel + 1, ref asciitext);
86 | }
87 | if (nLevel == 1)
88 | {
89 | swFeat = (Feature)swFeat.GetNextFeature();
90 | }
91 | else
92 | {
93 | swFeat = (Feature)swFeat.GetNextSubFeature();
94 | }
95 | }
96 | }
97 |
98 | public void DumpTraverseComponent(Component2 swComp, long nLevel, ref string asciitext)
99 | {
100 | // *** SCAN THE COMPONENT FEATURES
101 |
102 | if (!swComp.IsRoot())
103 | {
104 | Feature swFeat;
105 | swFeat = (Feature)swComp.FirstFeature();
106 | DumpTraverseFeatures(swFeat, nLevel, ref asciitext);
107 | }
108 |
109 | // *** RECURSIVE SCAN CHILDREN COMPONENTS
110 |
111 | object[] vChildComp;
112 | Component2 swChildComp;
113 | string sPadStr = " ";
114 | long i = 0;
115 |
116 | for (i = 0; i <= nLevel - 1; i++)
117 | {
118 | sPadStr = sPadStr + " ";
119 | }
120 |
121 | vChildComp = (object[])swComp.GetChildren();
122 |
123 | for (i = 0; i < vChildComp.Length; i++)
124 | {
125 | swChildComp = (Component2)vChildComp[i];
126 |
127 | asciitext += sPadStr + "+" + swChildComp.Name2 + " <" + swChildComp.ReferencedConfiguration + ">" + "\n";
128 |
129 | // DumpTraverseComponentFeatures(swChildComp, nLevel, ref asciitext);
130 |
131 | DumpTraverseComponent(swChildComp, nLevel + 1, ref asciitext);
132 | }
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ChScale.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace ChronoEngineAddin
7 | {
8 | // Class for scaling output (lengths, masses, time)
9 | // when converting to a .py file
10 |
11 | public static class ChScale
12 | {
13 | public static double L = 1.0; // length scale factor
14 | public static double M = 1.0; // mass scale factor
15 | public static double T = 1.0; // time scale factor
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ChronoEngine_SwAddin.cs.rej:
--------------------------------------------------------------------------------
1 | diff a/ChronoSolidworksAddIn/ChronoEngine_SwAddin.cs b/ChronoSolidworksAddIn/ChronoEngine_SwAddin.cs (rejected hunks)
2 | @@ -18,7 +18,7 @@
3 | using SWPublished;
4 | */
5 |
6 | -namespace ChronoEngine_SwAddin
7 | +namespace ChronoEngineAddIn
8 | {
9 |
10 | [ComVisible(true)]
11 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ChronoSolidworksAddIn.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\
5 |
6 |
7 | Program
8 | C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\SLDWORKS.exe
9 |
10 |
11 | Program
12 | C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\SLDWORKS.exe
13 |
14 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ConvexDecomp2.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 |
10 | namespace ChronoEngineAddin
11 | {
12 | public partial class ConvexDecomp2 : Form
13 | {
14 | public ConvexDecomp2()
15 | {
16 | InitializeComponent();
17 | }
18 |
19 | public void SetMeshInfo(int numfaces, int numvertexes)
20 | {
21 | this.label_meshinfo.Text = "Original mesh: " + numfaces + " faces and " + numvertexes + " vertexes.";
22 | }
23 |
24 | private void button_ok_Click(object sender, EventArgs e)
25 | {
26 | m_alpha = (double)this.numeric_alpha.Value;
27 | m_concavity = (double)this.numeric_concavity.Value;
28 | m_depht = (int)this.numeric_depht.Value;
29 | m_posrefine = (int)this.numeric_posrefine.Value;
30 | m_anglerefine = (int)this.numeric_anglerefine.Value;
31 | m_positionsampling = (int)this.numeric_possampling.Value;
32 | m_anglesampling = (int)this.numeric_anglesampling.Value;
33 | m_decimate = (int)this.numeric_decimate.Value;
34 | }
35 |
36 | public double m_alpha;
37 | public double m_concavity;
38 | public int m_depht;
39 | public int m_posrefine;
40 | public int m_anglerefine;
41 | public int m_positionsampling;
42 | public int m_anglesampling;
43 | public int m_decimate;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ConvexDecomp2.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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ConvexDecompForm.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 |
10 | namespace ChronoEngineAddin
11 | {
12 | public partial class ConvexDecompForm : Form
13 | {
14 | public ConvexDecompForm()
15 | {
16 | InitializeComponent();
17 | }
18 |
19 | public void SetMeshInfo(int numfaces, int numvertexes)
20 | {
21 | this.label_meshinfo.Text = "Original mesh: " + numfaces + " faces and " + numvertexes + " vertexes.";
22 | }
23 |
24 | // press OK
25 | private void button1_Click(object sender, EventArgs e)
26 | {
27 | concavity = (double)this.numeric_concavity.Value;
28 | smallclusterthreshold = (double)this.numeric_smallclusterthreshold.Value;
29 | compacity = (double)this.numeric_compacity.Value;
30 | volumeweight = (double)this.numeric_volumeweight.Value;
31 | connectdistance = (double)this.numeric_connectdistance.Value;
32 | maxvertexespermesh = (int) this.numeric_maxvertexpermesh.Value;
33 | minclusters = (int)this.numeric_minclusters.Value;
34 | maxvertexespercluster = (int)this.numeric_maxnvertexespercluster.Value;
35 | addextradistancepoints = this.checkBox_addextradistpoints.Checked;
36 | addextrafacepoints = this.checkBox_addextrafacepoints.Checked;
37 | }
38 |
39 | public double concavity;
40 | public double smallclusterthreshold;
41 | public double compacity;
42 | public double volumeweight;
43 | public double connectdistance;
44 | public int maxvertexespermesh;
45 | public int minclusters;
46 | public int maxvertexespercluster;
47 | public bool addextradistancepoints;
48 | public bool addextrafacepoints;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/ConvexDecompForm.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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/EditChMotor.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 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/EditChSDA.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 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/EditCollisionParameters.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 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/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("SolidWorks ChronoEngine export")]
9 | [assembly: AssemblyDescription("Add-in for SolidWorks")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SolidWorks ChronoEngine export")]
13 | [assembly: AssemblyCopyright("Alessandro Tasora © 2019")]
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(true)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("e2ae1d33-42df-4c35-9230-06850f197bde")]
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("2.0.8.0")]
36 | [assembly: AssemblyFileVersion("2.0.8.0")]
37 |
38 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/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 ChronoEngineAddin.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ChronoSolidworksAddIn/signature.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/ChronoSolidworksAddIn/signature.snk
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013, Chrono Development Team
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 | - Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9 |
10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERChANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CHRONO::SOLIDWORKS
2 | ==================
3 |  
4 | 
5 |
6 | Chrono::SolidWorks is an add-in for [SolidWorks](https://www.solidworks.com) that allows to simulate the CAD models by leveraging the capabilities of the [Chrono](https://www.projectchrono.org) multibody library.
7 | The models created can be also exported for further processing directly in Chrono, either in C++, Python, C# or through JSON files.
8 |
9 | Chrono::SolidWorks is part of [Project Chrono](https://www.projectchrono.org).
10 |
11 |
12 | Main features
13 | -------------
14 |
15 | * add-in for [SolidWorks](https://www.solidworks.com)
16 | * export mechanical systems including:
17 | + Parts, as rigid bodies; including mass and inertia properties
18 | + Assemblies, as rigid bodies for rigid Assemblies, or articulated for flexible Assemblies;
19 | + Mates, either Standard or Mechanical;
20 | + custom motors
21 | * export visualization shapes Wavefront OBJ meshes, to be later edited/optimized
22 | * export coordinate systems as chrono::ChMarker
23 | * adding advanced collision features
24 |
25 | For more informations: [Chrono::Solidworks User Manual](https://api.projectchrono.org/development/manual_chrono_solidworks.html)
26 |
27 | How to install the add-in
28 | ------------------------------------
29 | Visit the ProjectChrono website for the [pre-compiled binary webpage](https://www.projectchrono.org/download/) and look for the Chrono::Solidworks section.
30 | The installer will prompt the user to locate the Solidworks directory. Dependencies will be installed together with the add-in.
31 |
32 |
33 | How to build the add-in from source (advanced users)
34 | ------------------------------------
35 | There is no need to build the add-in from source unless you are interested in expanding/fixing the add-in.
36 |
37 | * the project is written in C#, so you must use Microsoft Visual Studio with the C# development module enabled
38 | * double check the availability of the proper .NET Framework version on your computer
39 | * you must have a [SolidWorks](https://www.solidworks.com) license installed on your computer
40 | * clone this repository to any given folder (always suggested to avoid spaces and special characters in the path)
41 | * run Visual Studio as Administrator
42 | * load the **ChronoSolidworks.sln** solution located in the main directory
43 | * set build configuration to *Release*
44 | * right-click on the *ChronoSolidworksAddIn* target, click on *Manage NuGet Packages* and install the *Newtonsoft.JSON* package
45 | * you may need to modify some settings of this solution, in order to reference the .COM assemblies of your SolidWorks
46 | In the Solution Explorer panel, expand *ChronoSolidworksAddIn*>*References* and make sure that the four references called "SolidWorks...." are properly set. If not:
47 | + right click on *References*>*Add Reference...*
48 | + go to the *Browse* tab and navigate to the SolidWorks installation folder
49 | (typically *C:\Program Files\SolidWorks 20XX\SolidWorks*) and add the following files (names might change depending on Solidworks version):
50 | - *solidworkstools.dll*
51 | - *SolidWorks.Interop.sldworks.dll*
52 | - *SolidWorks.Interop.swcommands.dll*
53 | - *SolidWorks.Interop.swconst.dll*
54 | - *SolidWorks.Interop.swpublished.dll*
55 | * right-click on *ChronoSolidworksAddIn* project, click on *Properties*, *Reference Paths* and add the Solidworks installation folder (e.g. "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\")
56 | * in the *Build* panel close by an additional flag `HAS_CHRONO_CSHARP` is currently set by default: in case you didn't compile Chrono with CSHARP module enabled please remove this flag. This will disable the "Export to JSON" and "Run Simulation" options.
57 | + in case you decided to use Chrono CSharp, right click on the *ChronoSolidworksAddIn*, then *Add*>*Existing Item*, go to the Chrono build folder, navigate into _bin/Release_ and select *ChronoEngine.dll* and *ChronoEngine_csharp_core.dll*; in the selection dialog it is better to select *Add as Link* instead of a simple *Add*; please mind that the selection dialog has some selection filter that, in this case, should be set to show also *.dll* files; you should now see the picked libraries into the Visual Studio solution;
58 | + select both *ChronoEngine.dll* and *ChronoEngine_csharp_core.dll*, right-click and then *Properties*; set the *Copy to Output Directory* to *Copy always*;
59 | + go to the Chrono build folder, copy all the source code from _chrono_csharp/core_ and _chrono_csharp/irrlicht_ into a single folder e.g. _csharp_source_ (unfortunately Chrono CSharp modules re-export some classes, thus creating duplicated items);
60 | + in Visual Studio, right click on the *ChronoSolidworksAddIn* target, then *Add*>*New Folder* and call it _Chrono_; this is for convenience;
61 | + right click on it, click on *Add*>*Existing Item*, go to the temporary _csharp_source_ folder and add all the files contained there by selecting _Add as Link_;
62 | * build the solution. It will generate the **ChronoEngineAddIn.dll** into the *chrono-solidworks_install* together with all its dependencies; the DLLs are automatically registered by the post-build events
63 | * start SolidWorks, you should find the Chrono::Engine panel in the Task Pane to the right. Note that add-ins can be enabled/disabled with the *Tools>Adds-In* menu in the toolbar
64 |
65 | If you find problems to build the add-in, look at [this tutorial](https://www.angelsix.com/cms/products/tutorials/64-solidworks/67-creating-a-solidworks-add-in-from-scratch) for instructions about how to build add-ins for SolidWorks.
66 |
67 |
68 | How to use the Chrono::SolidWorks add-in
69 | ----------------------------------------
70 |
71 | In the _ChronoSolidworksImportTemplate_ a CMake solution offers a set of projects to test all the export options: CPP, JSON, Python parsing and PyChrono. CMake will setup a solution according to your IDE including to test the first three types of export, plus it will create a dedicate PyChrono source file that can be run indipendently (it will be created in the _${PROJECT_BINARY_DIR}/pychrono_).
72 | The _ChronoSolidworksImportTemplate_ is available in the install folder or inside the *to_put_in_app_ir* folder in the sources.
73 |
74 | See the [tutorials](https://api.projectchrono.org/development/tutorial_table_of_content_chrono_solidworks.html) for examples of C++ code and Python code that load systems exported with this add-in.
75 |
76 | A place for discussions can be the [projectchrono group](https://groups.google.com/forum/#!forum/projectchrono).
77 |
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/AssemblyInfo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/decomposition_hacd_CLI/AssemblyInfo.cpp
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/Backup/hacd_CLI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hacd_CLI", "hacd_CLI.vcproj", "{C457BA60-8F07-4664-90E1-A4E2040AD640}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Debug|x64 = Debug|x64
10 | Release|Win32 = Release|Win32
11 | Release|x64 = Release|x64
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|Win32.Build.0 = Debug|Win32
16 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|x64.ActiveCfg = Debug|x64
17 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Debug|x64.Build.0 = Debug|x64
18 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|Win32.ActiveCfg = Release|Win32
19 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|Win32.Build.0 = Release|Win32
20 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|x64.ActiveCfg = Release|x64
21 | {C457BA60-8F07-4664-90E1-A4E2040AD640}.Release|x64.Build.0 = Release|x64
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | DYNAMIC LINK LIBRARY : hacd_CLI Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this hacd_CLI DLL for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your hacd_CLI application.
9 |
10 | hacd_CLI.vcproj
11 | This is the main project file for VC++ projects generated using an Application Wizard.
12 | It contains information about the version of Visual C++ that generated the file, and
13 | information about the platforms, configurations, and project features selected with the
14 | Application Wizard.
15 |
16 | hacd_CLI.cpp
17 | This is the main DLL source file.
18 |
19 | hacd_CLI.h
20 | This file contains a class declaration.
21 |
22 | AssemblyInfo.cpp
23 | Contains custom attributes for modifying assembly metadata.
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | Other notes:
27 |
28 | AppWizard uses "TODO:" to indicate parts of the source code you
29 | should add to or customize.
30 |
31 | /////////////////////////////////////////////////////////////////////////////
32 |
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/decomposition_hacd_CLI/app.ico
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/app.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 |
7 | /////////////////////////////////////////////////////////////////////////////
8 | #undef APSTUDIO_READONLY_SYMBOLS
9 |
10 | /////////////////////////////////////////////////////////////////////////////
11 | // English (U.S.) resources
12 |
13 |
14 | /////////////////////////////////////////////////////////////////////////////
15 | //
16 | // Icon
17 | //
18 |
19 | // Icon placed first or with lowest ID value becomes application icon
20 |
21 | LANGUAGE 16, 1
22 | #pragma code_page(1252)
23 | 1 ICON "app.ico"
24 |
25 | #ifdef APSTUDIO_INVOKED
26 | /////////////////////////////////////////////////////////////////////////////
27 | //
28 | // TEXTINCLUDE
29 | //
30 |
31 | 1 TEXTINCLUDE
32 | BEGIN
33 | "resource.h\0"
34 | "\0"
35 | END
36 |
37 | 2 TEXTINCLUDE
38 | BEGIN
39 | "#include ""afxres.h""\r\n"
40 | "\0"
41 | END
42 |
43 | 3 TEXTINCLUDE
44 | BEGIN
45 | "\0"
46 | END
47 |
48 | #endif // APSTUDIO_INVOKED
49 |
50 | /////////////////////////////////////////////////////////////////////////////
51 |
52 |
53 |
54 | #ifndef APSTUDIO_INVOKED
55 | /////////////////////////////////////////////////////////////////////////////
56 | //
57 | // Generated from the TEXTINCLUDE 3 resource.
58 | //
59 |
60 |
61 | /////////////////////////////////////////////////////////////////////////////
62 | #endif // not APSTUDIO_INVOKED
63 |
64 |
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/hacd.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/decomposition_hacd_CLI/hacd.snk
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/hacd/inc/hacdCircularList.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
2 | All rights reserved.
3 |
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 | */
15 | #pragma once
16 | #ifndef HACD_CIRCULAR_LIST_H
17 | #define HACD_CIRCULAR_LIST_H
18 | #include
19 | #include
20 | #include
21 | namespace HACD
22 | {
23 | //! CircularListElement class.
24 | template < typename T > class CircularListElement
25 | {
26 | public:
27 | T & GetData() { return m_data; }
28 | const T & GetData() const { return m_data; }
29 | CircularListElement * & GetNext() { return m_next; }
30 | CircularListElement * & GetPrev() { return m_prev; }
31 | const CircularListElement * & GetNext() const { return m_next; }
32 | const CircularListElement * & GetPrev() const { return m_prev; }
33 | //! Constructor
34 | CircularListElement(const T & data) {m_data = data;}
35 | CircularListElement(void){}
36 | //! Destructor
37 | ~CircularListElement(void){}
38 | private:
39 | T m_data;
40 | CircularListElement * m_next;
41 | CircularListElement * m_prev;
42 |
43 | CircularListElement(const CircularListElement & rhs);
44 | };
45 |
46 |
47 | //! CircularList class.
48 | template < typename T > class CircularList
49 | {
50 | public:
51 | HeapManager * const GetHeapManager() const { return m_heapManager;}
52 | void SetHeapManager(HeapManager * const heapManager) { m_heapManager = heapManager;}
53 | CircularListElement * & GetHead() { return m_head;}
54 | const CircularListElement * GetHead() const { return m_head;}
55 | bool IsEmpty() const { return (m_size == 0);}
56 | size_t GetSize() const { return m_size; }
57 | const T & GetData() const { return m_head->GetData(); }
58 | T & GetData() { return m_head->GetData();}
59 | bool Delete() ;
60 | bool Delete(CircularListElement * element);
61 | CircularListElement * Add(const T * data = 0);
62 | CircularListElement * Add(const T & data);
63 | bool Next();
64 | bool Prev();
65 | void Clear() { while(Delete());};
66 | const CircularList& operator=(const CircularList& rhs);
67 | //! Constructor
68 | CircularList(HeapManager * heapManager)
69 | {
70 | m_head = 0;
71 | m_size = 0;
72 | m_heapManager = heapManager;
73 | }
74 | CircularList(const CircularList& rhs);
75 | //! Destructor
76 | virtual ~CircularList(void) {Clear();};
77 | private:
78 | CircularListElement * m_head; //!< a pointer to the head of the circular list
79 | size_t m_size; //!< number of element in the circular list
80 | HeapManager * m_heapManager;
81 |
82 | };
83 | }
84 | #include
85 | #endif
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/hacd/inc/hacdCircularList.inl:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef HACD_CIRCULAR_LIST_INL
3 | #define HACD_CIRCULAR_LIST_INL
4 | #include
5 | #include
6 | namespace HACD
7 | {
8 | template < typename T >
9 | inline bool CircularList::Delete(CircularListElement * element)
10 | {
11 | if (!element)
12 | {
13 | return false;
14 | }
15 | if (m_size > 1)
16 | {
17 | CircularListElement * next = element->GetNext();
18 | CircularListElement * prev = element->GetPrev();
19 | if (m_heapManager)
20 | {
21 | element->~CircularListElement();
22 | heap_free(m_heapManager, element);
23 | }
24 | else
25 | {
26 | delete element;
27 | }
28 | m_size--;
29 | if (element == m_head)
30 | {
31 | m_head = next;
32 | }
33 | next->GetPrev() = prev;
34 | prev->GetNext() = next;
35 | return true;
36 | }
37 | else if (m_size == 1)
38 | {
39 | if (m_heapManager)
40 | {
41 | element->~CircularListElement();
42 | heap_free(m_heapManager, m_head);
43 | }
44 | else
45 | {
46 | delete m_head;
47 | }
48 | m_size--;
49 | m_head = 0;
50 | return true;
51 | }
52 | else
53 | {
54 | return false;
55 | }
56 | }
57 |
58 | template < typename T >
59 | inline bool CircularList::Delete()
60 | {
61 | if (m_size > 1)
62 | {
63 | CircularListElement * next = m_head->GetNext();
64 | CircularListElement * prev = m_head->GetPrev();
65 | if (m_heapManager)
66 | {
67 | m_head->~CircularListElement();
68 | heap_free(m_heapManager, m_head);
69 | }
70 | else
71 | {
72 | delete m_head;
73 | }
74 | m_size--;
75 | m_head = next;
76 | next->GetPrev() = prev;
77 | prev->GetNext() = next;
78 | return true;
79 | }
80 | else if (m_size == 1)
81 | {
82 | if (m_heapManager)
83 | {
84 | m_head->~CircularListElement();
85 | heap_free(m_heapManager, m_head);
86 | }
87 | else
88 | {
89 | delete m_head;
90 | }
91 | m_size--;
92 | m_head = 0;
93 | return true;
94 | }
95 | else
96 | {
97 | return false;
98 | }
99 | }
100 | template < typename T >
101 | inline CircularListElement * CircularList::Add(const T * data)
102 | {
103 | if (m_size == 0)
104 | {
105 | if (data)
106 | {
107 | if (m_heapManager)
108 | {
109 | m_head = static_cast< CircularListElement * > (heap_malloc(m_heapManager, sizeof(CircularListElement)));
110 | m_head->GetData().Initialize();
111 | m_head->GetData() = (*data);
112 | }
113 | else
114 | {
115 | m_head = new CircularListElement(*data);
116 | }
117 | }
118 | else
119 | {
120 | if (m_heapManager)
121 | {
122 | m_head = static_cast< CircularListElement * > (heap_malloc(m_heapManager, sizeof(CircularListElement)));
123 | m_head->GetData().Initialize();
124 | }
125 | else
126 | {
127 | m_head = new CircularListElement();
128 | }
129 | }
130 | m_head->GetNext() = m_head->GetPrev() = m_head;
131 | }
132 | else
133 | {
134 | CircularListElement * next = m_head->GetNext();
135 | CircularListElement * element = m_head;
136 | if (data)
137 | {
138 | if (m_heapManager)
139 | {
140 | m_head = static_cast< CircularListElement * > (heap_malloc(m_heapManager, sizeof(CircularListElement)));
141 | m_head->GetData().Initialize();
142 | m_head->GetData() = (*data);
143 | }
144 | else
145 | {
146 | m_head = new CircularListElement(*data);
147 | }
148 | }
149 | else
150 | {
151 | if (m_heapManager)
152 | {
153 | m_head = static_cast< CircularListElement * > (heap_malloc(m_heapManager, sizeof(CircularListElement)));
154 | m_head->GetData().Initialize();
155 | }
156 | else
157 | {
158 | m_head = new CircularListElement();
159 | }
160 | }
161 | m_head->GetNext() = next;
162 | m_head->GetPrev() = element;
163 | element->GetNext() = m_head;
164 | next->GetPrev() = m_head;
165 | }
166 | m_size++;
167 | return m_head;
168 | }
169 | template < typename T >
170 | inline CircularListElement * CircularList::Add(const T & data)
171 | {
172 | const T * pData = &data;
173 | return Add(pData);
174 | }
175 | template < typename T >
176 | inline bool CircularList::Next()
177 | {
178 | if (m_size == 0)
179 | {
180 | return false;
181 | }
182 | m_head = m_head->GetNext();
183 | return true;
184 | }
185 | template < typename T >
186 | inline bool CircularList::Prev()
187 | {
188 | if (m_size == 0)
189 | {
190 | return false;
191 | }
192 | m_head = m_head->GetPrev();
193 | return true;
194 | }
195 | template < typename T >
196 | inline CircularList::CircularList(const CircularList& rhs)
197 | {
198 | if (rhs.m_size > 0)
199 | {
200 | CircularListElement * current = rhs.m_head;
201 | do
202 | {
203 | current = current->GetNext();
204 | Add(current->GetData());
205 | }
206 | while ( current != rhs.m_head );
207 | }
208 | }
209 | template < typename T >
210 | inline const CircularList& CircularList::operator=(const CircularList& rhs)
211 | {
212 | if (&rhs != this)
213 | {
214 | Clear();
215 | m_heapManager = rhs.m_heapManager;
216 | if (rhs.m_size > 0)
217 | {
218 | CircularListElement * current = rhs.m_head;
219 | do
220 | {
221 | current = current->GetNext();
222 | Add(current->GetData());
223 | }
224 | while ( current != rhs.m_head );
225 | }
226 | }
227 | return (*this);
228 | }
229 | }
230 | #endif
--------------------------------------------------------------------------------
/decomposition_hacd_CLI/hacd/inc/hacdGraph.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
2 | All rights reserved.
3 |
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 | */
15 | #pragma once
16 | #ifndef HACD_GRAPH_H
17 | #define HACD_GRAPH_H
18 | #include
19 | #include
20 | #include
21 | #include