├── .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 | ![chrono_solidworks_github_1](http://projectchrono.org/assets/manual/chrono_solidworks_github_1.png) ![chrono_solidworks_github_2](http://projectchrono.org/assets/manual/chrono_solidworks_github_2.png) 4 | ![chrono_solidworks_github_3](http://projectchrono.org/assets/manual/chrono_solidworks_github_3.png) 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 22 | #include 23 | #include 24 | //#define HACD_PRECOMPUTE_CHULLS 25 | 26 | namespace HACD 27 | { 28 | class GraphVertex; 29 | class GraphEdge; 30 | class Graph; 31 | class HACD; 32 | 33 | class GraphVertex 34 | { 35 | public: 36 | bool AddEdge(long name) 37 | { 38 | m_edges.Insert(name); 39 | return true; 40 | } 41 | bool DeleteEdge(long name); 42 | GraphVertex(); 43 | ~GraphVertex(){ delete m_convexHull;}; 44 | private: 45 | long m_name; 46 | long m_cc; 47 | SArray m_edges; 48 | bool m_deleted; 49 | std::vector m_ancestors; 50 | SArray m_distPoints; 51 | 52 | Real m_concavity; 53 | double m_surf; 54 | ICHull * m_convexHull; 55 | SArray m_boudaryEdges; 56 | 57 | 58 | friend class GraphEdge; 59 | friend class Graph; 60 | friend class HACD; 61 | }; 62 | 63 | class GraphEdge 64 | { 65 | public: 66 | GraphEdge(); 67 | ~GraphEdge() 68 | { 69 | #ifdef HACD_PRECOMPUTE_CHULLS 70 | delete m_convexHull; 71 | #endif 72 | }; 73 | private: 74 | long m_name; 75 | long m_v1; 76 | long m_v2; 77 | double m_concavity; 78 | Real m_error; 79 | #ifdef HACD_PRECOMPUTE_CHULLS 80 | ICHull * m_convexHull; 81 | #endif 82 | bool m_deleted; 83 | 84 | friend class GraphVertex; 85 | friend class Graph; 86 | friend class HACD; 87 | }; 88 | 89 | class Graph 90 | { 91 | public: 92 | size_t GetNEdges() const { return m_nE;} 93 | size_t GetNVertices() const { return m_nV;} 94 | bool EdgeCollapse(long v1, long v2); 95 | long AddVertex(); 96 | long AddEdge(long v1, long v2); 97 | bool DeleteEdge(long name); 98 | bool DeleteVertex(long name); 99 | long GetEdgeID(long v1, long v2) const; 100 | void Clear(); 101 | void Print() const; 102 | long ExtractCCs(); 103 | 104 | Graph(); 105 | virtual ~Graph(); 106 | void Allocate(size_t nV, size_t nE); 107 | 108 | private: 109 | size_t m_nCCs; 110 | size_t m_nV; 111 | size_t m_nE; 112 | std::vector m_edges; 113 | std::vector m_vertices; 114 | 115 | friend class HACD; 116 | }; 117 | } 118 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd/inc/hacdMeshDecimator.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_MESH_DECEMATOR_H 17 | #define HACD_MESH_DECEMATOR_H 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace HACD 27 | { 28 | typedef double Float; 29 | struct MDVertex 30 | { 31 | SArray m_edges; 32 | SArray m_triangles; 33 | Float m_Q[10]; 34 | // 0 1 2 3 35 | // 4 5 6 36 | // 7 8 37 | // 9 38 | bool m_tag; 39 | bool m_onBoundary; 40 | }; 41 | 42 | struct MDEdge 43 | { 44 | long m_v1; 45 | long m_v2; 46 | double m_qem; 47 | Vec3 m_pos; 48 | bool m_onBoundary; 49 | bool m_tag; 50 | }; 51 | struct MDEdgePriorityQueue 52 | { 53 | long m_name; 54 | double m_qem; 55 | inline friend bool operator<(const MDEdgePriorityQueue & lhs, const MDEdgePriorityQueue & rhs) { return (lhs.m_qem > rhs.m_qem);} 56 | inline friend bool operator>(const MDEdgePriorityQueue & lhs, const MDEdgePriorityQueue & rhs) { return (lhs.m_qem < rhs.m_qem);} 57 | }; 58 | typedef void (*CallBackFunction)(const char *, double, double, size_t); 59 | class MeshDecimator 60 | { 61 | public: 62 | //! Sets the call-back function 63 | //! @param callBack pointer to the call-back function 64 | void SetCallBack(CallBackFunction callBack) { m_callBack = callBack;} 65 | //! Gives the call-back function 66 | //! @return pointer to the call-back function 67 | const CallBackFunction GetCallBack() const { return m_callBack;} 68 | 69 | inline void SetEColManifoldConstraint(bool ecolManifoldConstraint) { m_ecolManifoldConstraint = ecolManifoldConstraint; } 70 | inline size_t GetNVertices()const {return m_nVertices;}; 71 | inline size_t GetNTriangles() const {return m_nTriangles;}; 72 | inline size_t GetNEdges() const {return m_nEdges;}; 73 | void GetMeshData(Vec3 * points, Vec3 * triangles) const; 74 | void ReleaseMemory(); 75 | void Initialize(size_t nVertices, size_t nTriangles, 76 | Vec3 * points, 77 | Vec3 * triangles); 78 | bool Decimate(size_t targetNVertices = 100, 79 | size_t targetNTriangles = 0, 80 | double targetError = std::numeric_limits::max()); 81 | 82 | MeshDecimator(void); 83 | ~MeshDecimator(void); 84 | private : 85 | void EdgeCollapse(long v1, long v2); 86 | long GetTriangle(long v1, long v2, long v3) const; 87 | long GetEdge(long v1, long v2) const; 88 | long IsBoundaryEdge(long v1, long v2) const; 89 | bool IsBoundaryVertex(long v) const; 90 | void InitializePriorityQueue(); 91 | void InitializeQEM(); 92 | bool ManifoldConstraint(long v1, long v2) const; 93 | double ComputeEdgeCost(long v1, long v2, Vec3 & pos) const; 94 | bool EdgeCollapse(double & error); 95 | private: 96 | Vec3 * m_triangles; 97 | Vec3 * m_points; 98 | size_t m_nPoints; 99 | size_t m_nInitialTriangles; 100 | size_t m_nVertices; 101 | size_t m_nTriangles; 102 | size_t m_nEdges; 103 | double m_diagBB; 104 | std::vector m_vertices; 105 | std::vector m_edges; 106 | std::priority_queue< 107 | MDEdgePriorityQueue, 108 | std::vector, 109 | std::less > m_pqueue; 110 | CallBackFunction m_callBack; //>! call-back function 111 | bool * m_trianglesTags; 112 | bool m_ecolManifoldConstraint; 113 | }; 114 | } 115 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd/inc/hacdMicroAllocator.h: -------------------------------------------------------------------------------- 1 | #ifndef MICRO_ALLOCATOR_H 2 | 3 | #define MICRO_ALLOCATOR_H 4 | 5 | /*! 6 | ** 7 | ** Copyright (c) 2009 by John W. Ratcliff mailto:jratcliffscarab@gmail.com 8 | ** 9 | ** If you find this code useful or you are feeling particularily generous I would 10 | ** ask that you please go to http://www.amillionpixels.us and make a donation 11 | ** to Troy DeMolay. 12 | ** 13 | ** If you wish to contact me you can use the following methods: 14 | ** 15 | ** Skype ID: jratcliff63367 16 | ** email: jratcliffscarab@gmail.com 17 | ** 18 | ** 19 | ** The MIT license: 20 | ** 21 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 22 | ** of this software and associated documentation files (the "Software"), to deal 23 | ** in the Software without restriction, including without limitation the rights 24 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | ** copies of the Software, and to permit persons to whom the Software is furnished 26 | ** to do so, subject to the following conditions: 27 | ** 28 | ** The above copyright notice and this permission notice shall be included in all 29 | ** copies or substantial portions of the Software. 30 | 31 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 35 | ** WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 36 | ** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | 38 | */ 39 | 40 | 41 | // This code snippet provides a high speed micro-allocator. 42 | // 43 | // The concept is that you reserve an initial bank of memory for small allocations. Ideally a megabyte or two. 44 | // The amount of memory reserved is equal to chunkSize*6 45 | // 46 | // All micro-allocations are split into 6 seperate pools. 47 | // They are: 0-8 bytes 48 | // 9-32 bytes 49 | // 33-64 bytes 50 | // 65-128 bytes 51 | // 129-256 bytes 52 | // 53 | // On creation of the micro-allocation system you preserve a certiain amount of memory for each of these banks. 54 | // 55 | // The user provides a heap interface to callback for additional memory as needed. 56 | // 57 | // In most cases allocations are order-N and frees are order-N as well. 58 | // 59 | // The larger a buffer you provide, the closer to 'order-N' the allocator behaves. 60 | // 61 | // This kind of a micro-allocator is ideal for use with STL as it does many tiny allocations. 62 | // All allocations are 16 byte aligned (with the exception of the 8 byte allocations, which are 8 byte aligned every other one). 63 | // 64 | #include 65 | 66 | #ifdef WIN32 67 | typedef __int64 NxI64; 68 | typedef signed int NxI32; 69 | typedef signed short NxI16; 70 | typedef signed char NxI8; 71 | 72 | typedef unsigned __int64 NxU64; 73 | typedef unsigned int NxU32; 74 | typedef unsigned short NxU16; 75 | typedef unsigned char NxU8; 76 | 77 | typedef float NxF32; 78 | typedef double NxF64; 79 | 80 | #elif __gnu_linux__ 81 | typedef long long NxI64; 82 | typedef signed int NxI32; 83 | typedef signed short NxI16; 84 | typedef signed char NxI8; 85 | 86 | typedef unsigned long long NxU64; 87 | typedef unsigned int NxU32; 88 | typedef unsigned short NxU16; 89 | typedef unsigned char NxU8; 90 | 91 | typedef float NxF32; 92 | typedef double NxF64; 93 | 94 | #elif __APPLE__ 95 | typedef long long NxI64; 96 | typedef signed int NxI32; 97 | typedef signed short NxI16; 98 | typedef signed char NxI8; 99 | 100 | typedef unsigned long long NxU64; 101 | typedef unsigned int NxU32; 102 | typedef unsigned short NxU16; 103 | typedef unsigned char NxU8; 104 | 105 | typedef float NxF32; 106 | typedef double NxF64; 107 | 108 | #elif __CELLOS_LV2__ 109 | typedef long long NxI64; 110 | typedef signed int NxI32; 111 | typedef signed short NxI16; 112 | typedef signed char NxI8; 113 | 114 | typedef unsigned long long NxU64; 115 | typedef unsigned int NxU32; 116 | typedef unsigned short NxU16; 117 | typedef unsigned char NxU8; 118 | 119 | typedef float NxF32; 120 | typedef double NxF64; 121 | 122 | #elif _XBOX 123 | typedef __int64 NxI64; 124 | typedef signed int NxI32; 125 | typedef signed short NxI16; 126 | typedef signed char NxI8; 127 | 128 | typedef unsigned __int64 NxU64; 129 | typedef unsigned int NxU32; 130 | typedef unsigned short NxU16; 131 | typedef unsigned char NxU8; 132 | 133 | typedef float NxF32; 134 | typedef double NxF64; 135 | 136 | #elif defined(__PPCGEKKO__) 137 | typedef long long NxI64; 138 | typedef signed int NxI32; 139 | typedef signed short NxI16; 140 | typedef signed char NxI8; 141 | 142 | typedef unsigned long long NxU64; 143 | typedef unsigned int NxU32; 144 | typedef unsigned short NxU16; 145 | 146 | typedef float NxF32; 147 | typedef double NxF64; 148 | 149 | #else 150 | #error Unknown platform! 151 | #endif 152 | 153 | 154 | namespace HACD 155 | { 156 | 157 | // user provided heap allocator 158 | class MicroHeap 159 | { 160 | public: 161 | virtual void * micro_malloc(size_t size) = 0; 162 | virtual void micro_free(void *p) = 0; 163 | virtual void * micro_realloc(void *oldMen,size_t newSize) = 0; 164 | }; 165 | 166 | class MemoryChunk; 167 | 168 | class MicroAllocator 169 | { 170 | public: 171 | virtual void * malloc(size_t size) = 0; 172 | virtual void free(void *p,MemoryChunk *chunk) = 0; // free relative to previously located MemoryChunk 173 | virtual MemoryChunk * isMicroAlloc(const void *p) = 0; // returns pointer to the chunk this memory belongs to, or null if not a micro-allocated block. 174 | virtual NxU32 getChunkSize(MemoryChunk *chunk) = 0; 175 | }; 176 | 177 | MicroAllocator *createMicroAllocator(MicroHeap *heap,NxU32 chunkSize=32768); // initial chunk size 32k per block. 178 | void releaseMicroAllocator(MicroAllocator *m); 179 | 180 | class HeapManager 181 | { 182 | public: 183 | virtual void * heap_malloc(size_t size) = 0; 184 | virtual void heap_free(void *p) = 0; 185 | virtual void * heap_realloc(void *oldMem,size_t newSize) = 0; 186 | }; 187 | 188 | 189 | // creates a heap manager that uses micro-allocations for all allocations < 256 bytes and standard malloc/free for anything larger. 190 | HeapManager * createHeapManager(NxU32 defaultChunkSize=32768); 191 | void releaseHeapManager(HeapManager *heap); 192 | 193 | // about 10% faster than using the virtual interface, inlines the functions as much as possible. 194 | void * heap_malloc(HeapManager *hm,size_t size); 195 | void heap_free(HeapManager *hm,void *p); 196 | void * heap_realloc(HeapManager *hm,void *oldMem,size_t newSize); 197 | 198 | void performUnitTests(void); 199 | 200 | // 201 | 202 | }; // end of namespace 203 | 204 | #endif 205 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd/inc/hacdRaycastMesh.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com) 4 | All rights reserved. 5 | 6 | 7 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 10 | 11 | 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. 12 | 13 | 3. The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 14 | 15 | 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. 16 | */ 17 | #ifndef RAYCAST_MESH_H 18 | #define RAYCAST_MESH_H 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace HACD 26 | { 27 | typedef double Float; 28 | class RaycastMesh; 29 | class RMNode; 30 | class BBox 31 | { 32 | public: 33 | bool Raycast(const Vec3 & origin, const Vec3 & dir, Float & distance) const; 34 | BBox(void){} 35 | ~BBox(void){} 36 | private: 37 | Vec3 m_min; 38 | Vec3 m_max; 39 | friend class RMNode; 40 | friend class RaycastMesh; 41 | }; 42 | 43 | enum RMSplitAxis 44 | { 45 | RMSplitAxis_X, 46 | RMSplitAxis_Y, 47 | RMSplitAxis_Z 48 | }; 49 | class RMNode 50 | { 51 | public: 52 | void ComputeBB(); 53 | bool Raycast(const Vec3 & from, const Vec3 & dir, long & triID, Float & distance, Vec3 & hitPoint, Vec3 & hitNormal) const; 54 | void Create(size_t depth, size_t maxDepth, size_t minLeafSize, Float minAxisSize); 55 | ~RMNode(void){} 56 | RMNode(void) 57 | { 58 | m_idRight = m_idLeft = m_id = -1; 59 | m_rm = 0; 60 | m_leaf = false; 61 | } 62 | long m_id; 63 | long m_idLeft; 64 | long m_idRight; 65 | BBox m_bBox; 66 | SArray m_triIDs; 67 | RaycastMesh * m_rm; 68 | bool m_leaf; 69 | }; 70 | 71 | class RaycastMesh 72 | { 73 | public: 74 | size_t GetNNodes() const { return m_nNodes;} 75 | size_t AddNode() { m_nNodes++; return m_nNodes-1; } 76 | void ComputeBB(); 77 | bool Raycast(const Vec3 & from, const Vec3 & dir, long & triID, Float & distance, Vec3 & hitPoint, Vec3 & hitNormal) const; 78 | void Initialize(size_t nVertices, size_t nTriangles, 79 | Vec3 * vertices, Vec3 * triangles, 80 | size_t maxDepth=15, size_t minLeafSize = 4, Float minAxisSize = 2.0); 81 | RaycastMesh(void); 82 | ~RaycastMesh(void); 83 | private : 84 | 85 | private: 86 | Vec3 * m_triangles; 87 | Vec3 * m_vertices; 88 | size_t m_nVertices; 89 | size_t m_nTriangles; 90 | RMNode * m_nodes; 91 | BBox m_bBox; 92 | size_t m_nNodes; 93 | size_t m_nMaxNodes; 94 | friend class RMNode; 95 | }; 96 | } 97 | #endif 98 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd/inc/hacdVector.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_VECTOR_H 17 | #define HACD_VECTOR_H 18 | #include 19 | #include 20 | #include 21 | 22 | namespace HACD 23 | { 24 | typedef double Real; 25 | //! Vector dim 3. 26 | template < typename T > class Vec3 27 | { 28 | public: 29 | T & operator[](size_t i) { return m_data[i];} 30 | const T & operator[](size_t i) const { return m_data[i];} 31 | T & X(); 32 | T & Y(); 33 | T & Z(); 34 | const T & X() const; 35 | const T & Y() const; 36 | const T & Z() const; 37 | void Normalize(); 38 | T GetNorm() const; 39 | void operator= (const Vec3 & rhs); 40 | void operator+=(const Vec3 & rhs); 41 | void operator-=(const Vec3 & rhs); 42 | void operator-=(T a); 43 | void operator+=(T a); 44 | void operator/=(T a); 45 | void operator*=(T a); 46 | Vec3 operator^ (const Vec3 & rhs) const; 47 | T operator* (const Vec3 & rhs) const; 48 | Vec3 operator+ (const Vec3 & rhs) const; 49 | Vec3 operator- (const Vec3 & rhs) const; 50 | Vec3 operator- () const; 51 | Vec3 operator* (T rhs) const; 52 | Vec3 operator/ (T rhs) const; 53 | Vec3(); 54 | Vec3(T a); 55 | Vec3(T x, T y, T z); 56 | Vec3(const Vec3 & rhs); 57 | /*virtual*/ ~Vec3(void); 58 | 59 | private: 60 | T m_data[3]; 61 | }; 62 | template 63 | const bool Colinear(const Vec3 & a, const Vec3 & b, const Vec3 & c); 64 | template 65 | const T Volume(const Vec3 & a, const Vec3 & b, const Vec3 & c, const Vec3 & d); 66 | 67 | } 68 | #include "hacdVector.inl" // template implementation 69 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd/inc/hacdVector.inl: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef HACD_VECTOR_INL 3 | #define HACD_VECTOR_INL 4 | namespace HACD 5 | { 6 | template 7 | inline Vec3 operator*(T lhs, const Vec3 & rhs) 8 | { 9 | return Vec3(lhs * rhs.X(), lhs * rhs.Y(), lhs * rhs.Z()); 10 | } 11 | template 12 | inline T & Vec3::X() 13 | { 14 | return m_data[0]; 15 | } 16 | template 17 | inline T & Vec3::Y() 18 | { 19 | return m_data[1]; 20 | } 21 | template 22 | inline T & Vec3::Z() 23 | { 24 | return m_data[2]; 25 | } 26 | template 27 | inline const T & Vec3::X() const 28 | { 29 | return m_data[0]; 30 | } 31 | template 32 | inline const T & Vec3::Y() const 33 | { 34 | return m_data[1]; 35 | } 36 | template 37 | inline const T & Vec3::Z() const 38 | { 39 | return m_data[2]; 40 | } 41 | template 42 | inline void Vec3::Normalize() 43 | { 44 | T n = sqrt(m_data[0]*m_data[0]+m_data[1]*m_data[1]+m_data[2]*m_data[2]); 45 | if (n != 0.0) (*this) /= n; 46 | } 47 | template 48 | inline T Vec3::GetNorm() const 49 | { 50 | return sqrt(m_data[0]*m_data[0]+m_data[1]*m_data[1]+m_data[2]*m_data[2]); 51 | } 52 | template 53 | inline void Vec3::operator= (const Vec3 & rhs) 54 | { 55 | this->m_data[0] = rhs.m_data[0]; 56 | this->m_data[1] = rhs.m_data[1]; 57 | this->m_data[2] = rhs.m_data[2]; 58 | } 59 | template 60 | inline void Vec3::operator+=(const Vec3 & rhs) 61 | { 62 | this->m_data[0] += rhs.m_data[0]; 63 | this->m_data[1] += rhs.m_data[1]; 64 | this->m_data[2] += rhs.m_data[2]; 65 | } 66 | template 67 | inline void Vec3::operator-=(const Vec3 & rhs) 68 | { 69 | this->m_data[0] -= rhs.m_data[0]; 70 | this->m_data[1] -= rhs.m_data[1]; 71 | this->m_data[2] -= rhs.m_data[2]; 72 | } 73 | template 74 | inline void Vec3::operator-=(T a) 75 | { 76 | this->m_data[0] -= a; 77 | this->m_data[1] -= a; 78 | this->m_data[2] -= a; 79 | } 80 | template 81 | inline void Vec3::operator+=(T a) 82 | { 83 | this->m_data[0] += a; 84 | this->m_data[1] += a; 85 | this->m_data[2] += a; 86 | } 87 | template 88 | inline void Vec3::operator/=(T a) 89 | { 90 | this->m_data[0] /= a; 91 | this->m_data[1] /= a; 92 | this->m_data[2] /= a; 93 | } 94 | template 95 | inline void Vec3::operator*=(T a) 96 | { 97 | this->m_data[0] *= a; 98 | this->m_data[1] *= a; 99 | this->m_data[2] *= a; 100 | } 101 | template 102 | inline Vec3 Vec3::operator^ (const Vec3 & rhs) const 103 | { 104 | return Vec3(m_data[1] * rhs.m_data[2] - m_data[2] * rhs.m_data[1], 105 | m_data[2] * rhs.m_data[0] - m_data[0] * rhs.m_data[2], 106 | m_data[0] * rhs.m_data[1] - m_data[1] * rhs.m_data[0]); 107 | } 108 | template 109 | inline T Vec3::operator*(const Vec3 & rhs) const 110 | { 111 | return (m_data[0] * rhs.m_data[0] + m_data[1] * rhs.m_data[1] + m_data[2] * rhs.m_data[2]); 112 | } 113 | template 114 | inline Vec3 Vec3::operator+(const Vec3 & rhs) const 115 | { 116 | return Vec3(m_data[0] + rhs.m_data[0],m_data[1] + rhs.m_data[1],m_data[2] + rhs.m_data[2]); 117 | } 118 | template 119 | inline Vec3 Vec3::operator-(const Vec3 & rhs) const 120 | { 121 | return Vec3(m_data[0] - rhs.m_data[0],m_data[1] - rhs.m_data[1],m_data[2] - rhs.m_data[2]) ; 122 | } 123 | template 124 | inline Vec3 Vec3::operator-() const 125 | { 126 | return Vec3(-m_data[0],-m_data[1],-m_data[2]) ; 127 | } 128 | 129 | template 130 | inline Vec3 Vec3::operator*(T rhs) const 131 | { 132 | return Vec3(rhs * this->m_data[0], rhs * this->m_data[1], rhs * this->m_data[2]); 133 | } 134 | template 135 | inline Vec3 Vec3::operator/ (T rhs) const 136 | { 137 | return Vec3(m_data[0] / rhs, m_data[1] / rhs, m_data[2] / rhs); 138 | } 139 | template 140 | inline Vec3::Vec3(T a) 141 | { 142 | m_data[0] = m_data[1] = m_data[2] = a; 143 | } 144 | template 145 | inline Vec3::Vec3(T x, T y, T z) 146 | { 147 | m_data[0] = x; 148 | m_data[1] = y; 149 | m_data[2] = z; 150 | } 151 | template 152 | inline Vec3::Vec3(const Vec3 & rhs) 153 | { 154 | m_data[0] = rhs.m_data[0]; 155 | m_data[1] = rhs.m_data[1]; 156 | m_data[2] = rhs.m_data[2]; 157 | } 158 | template 159 | inline Vec3::~Vec3(void){}; 160 | 161 | template 162 | inline Vec3::Vec3() {} 163 | 164 | template 165 | inline const bool Colinear(const Vec3 & a, const Vec3 & b, const Vec3 & c) 166 | { 167 | return ((c.Z() - a.Z()) * (b.Y() - a.Y()) - (b.Z() - a.Z()) * (c.Y() - a.Y()) == 0.0 /*EPS*/) && 168 | ((b.Z() - a.Z()) * (c.X() - a.X()) - (b.X() - a.X()) * (c.Z() - a.Z()) == 0.0 /*EPS*/) && 169 | ((b.X() - a.X()) * (c.Y() - a.Y()) - (b.Y() - a.Y()) * (c.X() - a.X()) == 0.0 /*EPS*/); 170 | } 171 | 172 | template 173 | inline const T Volume(const Vec3 & a, const Vec3 & b, const Vec3 & c, const Vec3 & d) 174 | { 175 | return (a-d) * ((b-d) ^ (c-d)); 176 | } 177 | } 178 | #endif //HACD_VECTOR_INL -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd/inc/hacdVersion.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_VERSION_H 17 | #define HACD_VERSION_H 18 | #define HACD_VERSION_MAJOR 0 19 | #define HACD_VERSION_MINOR 0 20 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/hacd_CLI.cpp: -------------------------------------------------------------------------------- 1 | // This is the main DLL file. 2 | 3 | #include "hacd_CLI.h" 4 | 5 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by app.rc 4 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/btAlignedAllocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Bullet Continuous Collision Detection and Physics Library 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ 4 | 5 | This software is provided 'as-is', without any express or implied warranty. 6 | In no event will the authors be held liable for any damages arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it freely, 9 | subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 | 3. This notice may not be removed or altered from any source distribution. 14 | */ 15 | 16 | #ifndef BT_ALIGNED_ALLOCATOR 17 | #define BT_ALIGNED_ALLOCATOR 18 | 19 | ///we probably replace this with our own aligned memory allocator 20 | ///so we replace _aligned_malloc and _aligned_free with our own 21 | ///that is better portable and more predictable 22 | 23 | #include "btScalar.h" 24 | //#define BT_DEBUG_MEMORY_ALLOCATIONS 1 25 | #ifdef BT_DEBUG_MEMORY_ALLOCATIONS 26 | 27 | #define btAlignedAlloc(a,b) \ 28 | btAlignedAllocInternal(a,b,__LINE__,__FILE__) 29 | 30 | #define btAlignedFree(ptr) \ 31 | btAlignedFreeInternal(ptr,__LINE__,__FILE__) 32 | 33 | void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename); 34 | 35 | void btAlignedFreeInternal (void* ptr,int line,char* filename); 36 | 37 | #else 38 | void* btAlignedAllocInternal (size_t size, int alignment); 39 | void btAlignedFreeInternal (void* ptr); 40 | 41 | #define btAlignedAlloc(size,alignment) btAlignedAllocInternal(size,alignment) 42 | #define btAlignedFree(ptr) btAlignedFreeInternal(ptr) 43 | 44 | #endif 45 | typedef int size_type; 46 | 47 | typedef void *(btAlignedAllocFunc)(size_t size, int alignment); 48 | typedef void (btAlignedFreeFunc)(void *memblock); 49 | typedef void *(btAllocFunc)(size_t size); 50 | typedef void (btFreeFunc)(void *memblock); 51 | 52 | ///The developer can let all Bullet memory allocations go through a custom memory allocator, using btAlignedAllocSetCustom 53 | void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc); 54 | ///If the developer has already an custom aligned allocator, then btAlignedAllocSetCustomAligned can be used. The default aligned allocator pre-allocates extra memory using the non-aligned allocator, and instruments it. 55 | void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc); 56 | 57 | 58 | ///The btAlignedAllocator is a portable class for aligned memory allocations. 59 | ///Default implementations for unaligned and aligned allocations can be overridden by a custom allocator using btAlignedAllocSetCustom and btAlignedAllocSetCustomAligned. 60 | template < typename T , unsigned Alignment > 61 | class btAlignedAllocator { 62 | 63 | typedef btAlignedAllocator< T , Alignment > self_type; 64 | 65 | public: 66 | 67 | //just going down a list: 68 | btAlignedAllocator() {} 69 | /* 70 | btAlignedAllocator( const self_type & ) {} 71 | */ 72 | 73 | template < typename Other > 74 | btAlignedAllocator( const btAlignedAllocator< Other , Alignment > & ) {} 75 | 76 | typedef const T* const_pointer; 77 | typedef const T& const_reference; 78 | typedef T* pointer; 79 | typedef T& reference; 80 | typedef T value_type; 81 | 82 | pointer address ( reference ref ) const { return &ref; } 83 | const_pointer address ( const_reference ref ) const { return &ref; } 84 | pointer allocate ( size_type n , const_pointer * hint = 0 ) { 85 | (void)hint; 86 | return reinterpret_cast< pointer >(btAlignedAlloc( sizeof(value_type) * n , Alignment )); 87 | } 88 | void construct ( pointer ptr , const value_type & value ) { new (ptr) value_type( value ); } 89 | void deallocate( pointer ptr ) { 90 | btAlignedFree( reinterpret_cast< void * >( ptr ) ); 91 | } 92 | void destroy ( pointer ptr ) { ptr->~value_type(); } 93 | 94 | 95 | template < typename O > struct rebind { 96 | typedef btAlignedAllocator< O , Alignment > other; 97 | }; 98 | template < typename O > 99 | self_type & operator=( const btAlignedAllocator< O , Alignment > & ) { return *this; } 100 | 101 | friend bool operator==( const self_type & , const self_type & ) { return true; } 102 | }; 103 | 104 | 105 | 106 | #endif //BT_ALIGNED_ALLOCATOR 107 | 108 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/btConvexHullComputer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net 3 | 4 | This software is provided 'as-is', without any express or implied warranty. 5 | In no event will the authors be held liable for any damages arising from the use of this software. 6 | Permission is granted to anyone to use this software for any purpose, 7 | including commercial applications, and to alter it and redistribute it freely, 8 | subject to the following restrictions: 9 | 10 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 11 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 12 | 3. This notice may not be removed or altered from any source distribution. 13 | */ 14 | 15 | #ifndef BT_CONVEX_HULL_COMPUTER_H 16 | #define BT_CONVEX_HULL_COMPUTER_H 17 | 18 | #include "btVector3.h" 19 | #include "btAlignedObjectArray.h" 20 | 21 | /// Convex hull implementation based on Preparata and Hong 22 | /// See http://code.google.com/p/bullet/issues/detail?id=275 23 | /// Ole Kniemeyer, MAXON Computer GmbH 24 | class btConvexHullComputer 25 | { 26 | private: 27 | btScalar compute(const void* coords, bool doubleCoords, int stride, int count, btScalar shrink, btScalar shrinkClamp); 28 | 29 | public: 30 | 31 | class Edge 32 | { 33 | private: 34 | int next; 35 | int reverse; 36 | int targetVertex; 37 | 38 | friend class btConvexHullComputer; 39 | 40 | public: 41 | int getSourceVertex() const 42 | { 43 | return (this + reverse)->targetVertex; 44 | } 45 | 46 | int getTargetVertex() const 47 | { 48 | return targetVertex; 49 | } 50 | 51 | const Edge* getNextEdgeOfVertex() const // clockwise list of all edges of a vertex 52 | { 53 | return this + next; 54 | } 55 | 56 | const Edge* getNextEdgeOfFace() const // counter-clockwise list of all edges of a face 57 | { 58 | return (this + reverse)->getNextEdgeOfVertex(); 59 | } 60 | 61 | const Edge* getReverseEdge() const 62 | { 63 | return this + reverse; 64 | } 65 | }; 66 | 67 | 68 | // Vertices of the output hull 69 | btAlignedObjectArray vertices; 70 | 71 | // Edges of the output hull 72 | btAlignedObjectArray edges; 73 | 74 | // Faces of the convex hull. Each entry is an index into the "edges" array pointing to an edge of the face. Faces are planar n-gons 75 | btAlignedObjectArray faces; 76 | 77 | /* 78 | Compute convex hull of "count" vertices stored in "coords". "stride" is the difference in bytes 79 | between the addresses of consecutive vertices. If "shrink" is positive, the convex hull is shrunken 80 | by that amount (each face is moved by "shrink" length units towards the center along its normal). 81 | If "shrinkClamp" is positive, "shrink" is clamped to not exceed "shrinkClamp * innerRadius", where "innerRadius" 82 | is the minimum distance of a face to the center of the convex hull. 83 | 84 | The returned value is the amount by which the hull has been shrunken. If it is negative, the amount was so large 85 | that the resulting convex hull is empty. 86 | 87 | The output convex hull can be found in the member variables "vertices", "edges", "faces". 88 | */ 89 | btScalar compute(const float* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp) 90 | { 91 | return compute(coords, false, stride, count, shrink, shrinkClamp); 92 | } 93 | 94 | // same as above, but double precision 95 | btScalar compute(const double* coords, int stride, int count, btScalar shrink, btScalar shrinkClamp) 96 | { 97 | return compute(coords, true, stride, count, shrink, shrinkClamp); 98 | } 99 | }; 100 | 101 | 102 | #endif //BT_CONVEX_HULL_COMPUTER_H 103 | 104 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/btMinMax.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans http://continuousphysics.com/Bullet/ 3 | 4 | This software is provided 'as-is', without any express or implied warranty. 5 | In no event will the authors be held liable for any damages arising from the use of this software. 6 | Permission is granted to anyone to use this software for any purpose, 7 | including commercial applications, and to alter it and redistribute it freely, 8 | subject to the following restrictions: 9 | 10 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 11 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 12 | 3. This notice may not be removed or altered from any source distribution. 13 | */ 14 | 15 | 16 | 17 | #ifndef BT_GEN_MINMAX_H 18 | #define BT_GEN_MINMAX_H 19 | 20 | #include "btScalar.h" 21 | 22 | template 23 | SIMD_FORCE_INLINE const T& btMin(const T& a, const T& b) 24 | { 25 | return a < b ? a : b ; 26 | } 27 | 28 | template 29 | SIMD_FORCE_INLINE const T& btMax(const T& a, const T& b) 30 | { 31 | return a > b ? a : b; 32 | } 33 | 34 | template 35 | SIMD_FORCE_INLINE const T& btClamped(const T& a, const T& lb, const T& ub) 36 | { 37 | return a < lb ? lb : (ub < a ? ub : a); 38 | } 39 | 40 | template 41 | SIMD_FORCE_INLINE void btSetMin(T& a, const T& b) 42 | { 43 | if (b < a) 44 | { 45 | a = b; 46 | } 47 | } 48 | 49 | template 50 | SIMD_FORCE_INLINE void btSetMax(T& a, const T& b) 51 | { 52 | if (a < b) 53 | { 54 | a = b; 55 | } 56 | } 57 | 58 | template 59 | SIMD_FORCE_INLINE void btClamp(T& a, const T& lb, const T& ub) 60 | { 61 | if (a < lb) 62 | { 63 | a = lb; 64 | } 65 | else if (ub < a) 66 | { 67 | a = ub; 68 | } 69 | } 70 | 71 | #endif //BT_GEN_MINMAX_H 72 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/kdtree.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of ``kdtree'', a library for working with kd-trees. 3 | Copyright (C) 2007-2011 John Tsiombikas 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 3. The name of the author may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | OF SUCH DAMAGE. 26 | */ 27 | #ifndef _KDTREE_H_ 28 | #define _KDTREE_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | struct kdtree; 34 | struct kdres; 35 | 36 | 37 | /* create a kd-tree for "k"-dimensional data */ 38 | struct kdtree *kd_create(int k); 39 | 40 | /* free the struct kdtree */ 41 | void kd_free(struct kdtree *tree); 42 | 43 | /* remove all the elements from the tree */ 44 | void kd_clear(struct kdtree *tree); 45 | 46 | /* if called with non-null 2nd argument, the function provided 47 | * will be called on data pointers (see kd_insert) when nodes 48 | * are to be removed from the tree. 49 | */ 50 | void kd_data_destructor(struct kdtree *tree, void (*destr)(void*)); 51 | 52 | /* insert a node, specifying its position, and optional data */ 53 | int kd_insert(struct kdtree *tree, const double *pos, void *data); 54 | int kd_insertf(struct kdtree *tree, const float *pos, void *data); 55 | int kd_insert3(struct kdtree *tree, double x, double y, double z, void *data); 56 | int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data); 57 | 58 | /* Find the nearest node from a given point. 59 | * 60 | * This function returns a pointer to a result set with at most one element. 61 | */ 62 | struct kdres *kd_nearest(struct kdtree *tree, const double *pos); 63 | struct kdres *kd_nearestf(struct kdtree *tree, const float *pos); 64 | struct kdres *kd_nearest3(struct kdtree *tree, double x, double y, double z); 65 | struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z); 66 | 67 | /* Find the N nearest nodes from a given point. 68 | * 69 | * This function returns a pointer to a result set, with at most N elements, 70 | * which can be manipulated with the kd_res_* functions. 71 | * The returned pointer can be null as an indication of an error. Otherwise 72 | * a valid result set is always returned which may contain 0 or more elements. 73 | * The result set must be deallocated with kd_res_free after use. 74 | */ 75 | /* 76 | struct kdres *kd_nearest_n(struct kdtree *tree, const double *pos, int num); 77 | struct kdres *kd_nearest_nf(struct kdtree *tree, const float *pos, int num); 78 | struct kdres *kd_nearest_n3(struct kdtree *tree, double x, double y, double z); 79 | struct kdres *kd_nearest_n3f(struct kdtree *tree, float x, float y, float z); 80 | */ 81 | 82 | /* Find any nearest nodes from a given point within a range. 83 | * 84 | * This function returns a pointer to a result set, which can be manipulated 85 | * by the kd_res_* functions. 86 | * The returned pointer can be null as an indication of an error. Otherwise 87 | * a valid result set is always returned which may contain 0 or more elements. 88 | * The result set must be deallocated with kd_res_free after use. 89 | */ 90 | struct kdres *kd_nearest_range(struct kdtree *tree, const double *pos, double range); 91 | struct kdres *kd_nearest_rangef(struct kdtree *tree, const float *pos, float range); 92 | struct kdres *kd_nearest_range3(struct kdtree *tree, double x, double y, double z, double range); 93 | struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range); 94 | 95 | /* frees a result set returned by kd_nearest_range() */ 96 | void kd_res_free(struct kdres *set); 97 | 98 | /* returns the size of the result set (in elements) */ 99 | int kd_res_size(struct kdres *set); 100 | 101 | /* rewinds the result set iterator */ 102 | void kd_res_rewind(struct kdres *set); 103 | 104 | /* returns non-zero if the set iterator reached the end after the last element */ 105 | int kd_res_end(struct kdres *set); 106 | 107 | /* advances the result set iterator, returns non-zero on success, zero if 108 | * there are no more elements in the result set. 109 | */ 110 | int kd_res_next(struct kdres *set); 111 | 112 | /* returns the data pointer (can be null) of the current result set item 113 | * and optionally sets its position to the pointers(s) if not null. 114 | */ 115 | void *kd_res_item(struct kdres *set, double *pos); 116 | void *kd_res_itemf(struct kdres *set, float *pos); 117 | void *kd_res_item3(struct kdres *set, double *x, double *y, double *z); 118 | void *kd_res_item3f(struct kdres *set, float *x, float *y, float *z); 119 | 120 | /* equivalent to kd_res_item(set, 0) */ 121 | void *kd_res_item_data(struct kdres *set); 122 | 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | #endif /* _KDTREE_H_ */ 128 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/vhacdGraph.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 VHACD_GRAPH_H 17 | #define VHACD_GRAPH_H 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace VHACD 26 | { 27 | class GraphVertex; 28 | class GraphEdge; 29 | class Graph; 30 | class VHACD; 31 | 32 | class GraphVertex 33 | { 34 | public: 35 | bool AddEdge(long name) 36 | { 37 | m_edges.Insert(name); 38 | return true; 39 | } 40 | bool DeleteEdge(long name); 41 | GraphVertex(); 42 | ~GraphVertex(){}; 43 | private: 44 | long m_name; 45 | SArray m_edges; 46 | bool m_deleted; 47 | SArray m_ancestors; 48 | 49 | Real m_concavity; 50 | double m_volume; 51 | 52 | 53 | friend class GraphEdge; 54 | friend class Graph; 55 | friend class VHACD; 56 | }; 57 | 58 | class GraphEdge 59 | { 60 | public: 61 | GraphEdge(); 62 | ~GraphEdge() 63 | { 64 | delete m_convexHull; 65 | }; 66 | private: 67 | long m_name; 68 | long m_v1; 69 | long m_v2; 70 | double m_concavity; 71 | Real m_volume; 72 | Mesh * m_convexHull; 73 | bool m_deleted; 74 | 75 | friend class GraphVertex; 76 | friend class Graph; 77 | friend class VHACD; 78 | }; 79 | 80 | class Graph 81 | { 82 | public: 83 | size_t GetNEdges() const { return m_nE;} 84 | size_t GetNVertices() const { return m_nV;} 85 | bool EdgeCollapse(long v1, long v2); 86 | long AddVertex(); 87 | long AddEdge(long v1, long v2); 88 | bool DeleteEdge(long name); 89 | bool DeleteVertex(long name); 90 | long GetEdgeID(long v1, long v2) const; 91 | void Clear(); 92 | void Print() const; 93 | 94 | Graph(); 95 | virtual ~Graph(); 96 | void Allocate(size_t nV, size_t nE); 97 | 98 | private: 99 | size_t m_nCCs; 100 | size_t m_nV; 101 | size_t m_nE; 102 | std::vector m_edges; 103 | std::vector m_vertices; 104 | 105 | friend class VHACD; 106 | }; 107 | } 108 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/vhacdMaterial.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 VHACD_MATERIAL_H 17 | #define VHACD_MATERIAL_H 18 | #include 19 | #include 20 | namespace VHACD 21 | { 22 | struct Material 23 | { 24 | 25 | Vec3 m_diffuseColor; 26 | double m_ambientIntensity; 27 | Vec3 m_specularColor; 28 | Vec3 m_emissiveColor; 29 | double m_shininess; 30 | double m_transparency; 31 | Material(void) 32 | { 33 | m_diffuseColor.X() = 0.5; 34 | m_diffuseColor.Y() = 0.5; 35 | m_diffuseColor.Z() = 0.5; 36 | m_specularColor.X() = 0.5; 37 | m_specularColor.Y() = 0.5; 38 | m_specularColor.Z() = 0.5; 39 | m_ambientIntensity = 0.4; 40 | m_emissiveColor.X() = 0.0; 41 | m_emissiveColor.Y() = 0.0; 42 | m_emissiveColor.Z() = 0.0; 43 | m_shininess = 0.4; 44 | m_transparency = 0.0; 45 | }; 46 | }; 47 | } 48 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/vhacdMeshDecimator.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 VHACD_MESH_DECEMATOR_H 17 | #define VHACD_MESH_DECEMATOR_H 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace VHACD 28 | { 29 | typedef double Float; 30 | struct MDVertex 31 | { 32 | SArray m_edges; 33 | SArray m_triangles; 34 | Float m_Q[10]; 35 | // 0 1 2 3 36 | // 4 5 6 37 | // 7 8 38 | // 9 39 | bool m_tag; 40 | bool m_onBoundary; 41 | }; 42 | 43 | struct MDEdge 44 | { 45 | long m_v1; 46 | long m_v2; 47 | double m_qem; 48 | Vec3 m_pos; 49 | bool m_onBoundary; 50 | bool m_tag; 51 | }; 52 | struct MDEdgePriorityQueue 53 | { 54 | long m_name; 55 | double m_qem; 56 | inline friend bool operator<(const MDEdgePriorityQueue & lhs, const MDEdgePriorityQueue & rhs) { return (lhs.m_qem > rhs.m_qem);} 57 | inline friend bool operator>(const MDEdgePriorityQueue & lhs, const MDEdgePriorityQueue & rhs) { return (lhs.m_qem < rhs.m_qem);} 58 | }; 59 | typedef void (*CallBackFunction)(const char *); 60 | class MeshDecimator 61 | { 62 | public: 63 | //! Sets the call-back function 64 | //! @param callBack pointer to the call-back function 65 | void SetCallBack(CallBackFunction callBack) { m_callBack = callBack;} 66 | //! Gives the call-back function 67 | //! @return pointer to the call-back function 68 | const CallBackFunction GetCallBack() const { return m_callBack;} 69 | 70 | inline void SetEColManifoldConstraint(bool ecolManifoldConstraint) { m_ecolManifoldConstraint = ecolManifoldConstraint; } 71 | inline size_t GetNVertices()const {return m_nVertices;}; 72 | inline size_t GetNTriangles() const {return m_nTriangles;}; 73 | inline size_t GetNEdges() const {return m_nEdges;}; 74 | void GetMeshData(Vec3 * points, Vec3 * triangles) const; 75 | void GetMeshData(Mesh & mesh) const; 76 | void ReleaseMemory(); 77 | void Initialize(size_t nVertices, size_t nTriangles, 78 | Vec3 * points, 79 | Vec3 * triangles); 80 | bool Decimate(size_t targetNVertices = 100, 81 | size_t targetNTriangles = 0, 82 | double targetError = std::numeric_limits::max()); 83 | 84 | MeshDecimator(void); 85 | ~MeshDecimator(void); 86 | private : 87 | void EdgeCollapse(long v1, long v2); 88 | long GetTriangle(long v1, long v2, long v3) const; 89 | long GetEdge(long v1, long v2) const; 90 | long IsBoundaryEdge(long v1, long v2) const; 91 | bool IsBoundaryVertex(long v) const; 92 | void InitializePriorityQueue(); 93 | void InitializeQEM(); 94 | bool ManifoldConstraint(long v1, long v2) const; 95 | double ComputeEdgeCost(long v1, long v2, Vec3 & pos) const; 96 | bool EdgeCollapse(double & error); 97 | private: 98 | Vec3 * m_triangles; 99 | Vec3 * m_points; 100 | size_t m_nPoints; 101 | size_t m_nInitialTriangles; 102 | size_t m_nVertices; 103 | size_t m_nTriangles; 104 | size_t m_nEdges; 105 | double m_diagBB; 106 | std::vector m_vertices; 107 | std::vector m_edges; 108 | std::priority_queue< 109 | MDEdgePriorityQueue, 110 | std::vector, 111 | std::less > m_pqueue; 112 | CallBackFunction m_callBack; //>! call-back function 113 | bool * m_trianglesTags; 114 | bool m_ecolManifoldConstraint; 115 | }; 116 | } 117 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/vhacdVector.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 VHACD_VECTOR_H 17 | #define VHACD_VECTOR_H 18 | #include 19 | #include 20 | #include 21 | 22 | namespace VHACD 23 | { 24 | typedef double Real; 25 | //! Vector dim 3. 26 | template < typename T > class Vec3 27 | { 28 | public: 29 | T & operator[](size_t i) { return m_data[i];} 30 | const T & operator[](size_t i) const { return m_data[i];} 31 | T & X(); 32 | T & Y(); 33 | T & Z(); 34 | const T & X() const; 35 | const T & Y() const; 36 | const T & Z() const; 37 | void Normalize(); 38 | T GetNorm() const; 39 | void operator= (const Vec3 & rhs); 40 | void operator+=(const Vec3 & rhs); 41 | void operator-=(const Vec3 & rhs); 42 | void operator-=(T a); 43 | void operator+=(T a); 44 | void operator/=(T a); 45 | void operator*=(T a); 46 | Vec3 operator^ (const Vec3 & rhs) const; 47 | T operator* (const Vec3 & rhs) const; 48 | Vec3 operator+ (const Vec3 & rhs) const; 49 | Vec3 operator- (const Vec3 & rhs) const; 50 | Vec3 operator- () const; 51 | Vec3 operator* (T rhs) const; 52 | Vec3 operator/ (T rhs) const; 53 | Vec3(); 54 | Vec3(T a); 55 | Vec3(T x, T y, T z); 56 | Vec3(const Vec3 & rhs); 57 | /*virtual*/ ~Vec3(void); 58 | 59 | private: 60 | T m_data[3]; 61 | }; 62 | typedef double Real; 63 | //! Vector dim 2. 64 | template < typename T > class Vec2 65 | { 66 | public: 67 | T & operator[](size_t i) { return m_data[i];} 68 | const T & operator[](size_t i) const { return m_data[i];} 69 | T & X(); 70 | T & Y(); 71 | const T & X() const; 72 | const T & Y() const; 73 | void Normalize(); 74 | T GetNorm() const; 75 | void operator= (const Vec2 & rhs); 76 | void operator+=(const Vec2 & rhs); 77 | void operator-=(const Vec2 & rhs); 78 | void operator-=(T a); 79 | void operator+=(T a); 80 | void operator/=(T a); 81 | void operator*=(T a); 82 | T operator^ (const Vec2 & rhs) const; 83 | T operator* (const Vec2 & rhs) const; 84 | Vec2 operator+ (const Vec2 & rhs) const; 85 | Vec2 operator- (const Vec2 & rhs) const; 86 | Vec2 operator- () const; 87 | Vec2 operator* (T rhs) const; 88 | Vec2 operator/ (T rhs) const; 89 | Vec2(); 90 | Vec2(T a); 91 | Vec2(T x, T y); 92 | Vec2(const Vec2 & rhs); 93 | /*virtual*/ ~Vec2(void); 94 | 95 | private: 96 | T m_data[2]; 97 | }; 98 | 99 | 100 | 101 | 102 | 103 | 104 | template 105 | const bool Colinear(const Vec3 & a, const Vec3 & b, const Vec3 & c); 106 | template 107 | const T Volume(const Vec3 & a, const Vec3 & b, const Vec3 & c, const Vec3 & d); 108 | 109 | } 110 | #include "VHACDVector.inl" // template implementation 111 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/inc/vhacdVersion.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 VHACD_VERSION_H 17 | #define VHACD_VERSION_H 18 | #define VHACD_VERSION_MAJOR 0 19 | #define VHACD_VERSION_MINOR 0 20 | #endif -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/src/btAlignedAllocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Bullet Continuous Collision Detection and Physics Library 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ 4 | 5 | This software is provided 'as-is', without any express or implied warranty. 6 | In no event will the authors be held liable for any damages arising from the use of this software. 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it freely, 9 | subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 | 3. This notice may not be removed or altered from any source distribution. 14 | */ 15 | 16 | #include "btAlignedAllocator.h" 17 | 18 | int gNumAlignedAllocs = 0; 19 | int gNumAlignedFree = 0; 20 | int gTotalBytesAlignedAllocs = 0;//detect memory leaks 21 | 22 | static void *btAllocDefault(size_t size) 23 | { 24 | return malloc(size); 25 | } 26 | 27 | static void btFreeDefault(void *ptr) 28 | { 29 | free(ptr); 30 | } 31 | 32 | static btAllocFunc *sAllocFunc = btAllocDefault; 33 | static btFreeFunc *sFreeFunc = btFreeDefault; 34 | 35 | 36 | 37 | #if defined (BT_HAS_ALIGNED_ALLOCATOR) 38 | #include 39 | static void *btAlignedAllocDefault(size_t size, int alignment) 40 | { 41 | return _aligned_malloc(size, (size_t)alignment); 42 | } 43 | 44 | static void btAlignedFreeDefault(void *ptr) 45 | { 46 | _aligned_free(ptr); 47 | } 48 | #elif defined(__CELLOS_LV2__) 49 | #include 50 | 51 | static inline void *btAlignedAllocDefault(size_t size, int alignment) 52 | { 53 | return memalign(alignment, size); 54 | } 55 | 56 | static inline void btAlignedFreeDefault(void *ptr) 57 | { 58 | free(ptr); 59 | } 60 | #else 61 | static inline void *btAlignedAllocDefault(size_t size, int alignment) 62 | { 63 | void *ret; 64 | char *real; 65 | unsigned long offset; 66 | 67 | real = (char *)sAllocFunc(size + sizeof(void *) + (alignment-1)); 68 | if (real) { 69 | offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1); 70 | ret = (void *)((real + sizeof(void *)) + offset); 71 | *((void **)(ret)-1) = (void *)(real); 72 | } else { 73 | ret = (void *)(real); 74 | } 75 | return (ret); 76 | } 77 | 78 | static inline void btAlignedFreeDefault(void *ptr) 79 | { 80 | void* real; 81 | 82 | if (ptr) { 83 | real = *((void **)(ptr)-1); 84 | sFreeFunc(real); 85 | } 86 | } 87 | #endif 88 | 89 | 90 | static btAlignedAllocFunc *sAlignedAllocFunc = btAlignedAllocDefault; 91 | static btAlignedFreeFunc *sAlignedFreeFunc = btAlignedFreeDefault; 92 | 93 | void btAlignedAllocSetCustomAligned(btAlignedAllocFunc *allocFunc, btAlignedFreeFunc *freeFunc) 94 | { 95 | sAlignedAllocFunc = allocFunc ? allocFunc : btAlignedAllocDefault; 96 | sAlignedFreeFunc = freeFunc ? freeFunc : btAlignedFreeDefault; 97 | } 98 | 99 | void btAlignedAllocSetCustom(btAllocFunc *allocFunc, btFreeFunc *freeFunc) 100 | { 101 | sAllocFunc = allocFunc ? allocFunc : btAllocDefault; 102 | sFreeFunc = freeFunc ? freeFunc : btFreeDefault; 103 | } 104 | 105 | #ifdef BT_DEBUG_MEMORY_ALLOCATIONS 106 | //this generic allocator provides the total allocated number of bytes 107 | #include 108 | 109 | void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename) 110 | { 111 | void *ret; 112 | char *real; 113 | unsigned long offset; 114 | 115 | gTotalBytesAlignedAllocs += size; 116 | gNumAlignedAllocs++; 117 | 118 | 119 | real = (char *)sAllocFunc(size + 2*sizeof(void *) + (alignment-1)); 120 | if (real) { 121 | offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) & 122 | (alignment-1); 123 | ret = (void *)((real + 2*sizeof(void *)) + offset); 124 | *((void **)(ret)-1) = (void *)(real); 125 | *((int*)(ret)-2) = size; 126 | 127 | } else { 128 | ret = (void *)(real);//?? 129 | } 130 | 131 | printf("allocation#%d at address %x, from %s,line %d, size %d\n",gNumAlignedAllocs,real, filename,line,size); 132 | 133 | int* ptr = (int*)ret; 134 | *ptr = 12; 135 | return (ret); 136 | } 137 | 138 | void btAlignedFreeInternal (void* ptr,int line,char* filename) 139 | { 140 | 141 | void* real; 142 | gNumAlignedFree++; 143 | 144 | if (ptr) { 145 | real = *((void **)(ptr)-1); 146 | int size = *((int*)(ptr)-2); 147 | gTotalBytesAlignedAllocs -= size; 148 | 149 | printf("free #%d at address %x, from %s,line %d, size %d\n",gNumAlignedFree,real, filename,line,size); 150 | 151 | sFreeFunc(real); 152 | } else 153 | { 154 | printf("NULL ptr\n"); 155 | } 156 | } 157 | 158 | #else //BT_DEBUG_MEMORY_ALLOCATIONS 159 | 160 | void* btAlignedAllocInternal (size_t size, int alignment) 161 | { 162 | gNumAlignedAllocs++; 163 | void* ptr; 164 | ptr = sAlignedAllocFunc(size, alignment); 165 | // printf("btAlignedAllocInternal %d, %x\n",size,ptr); 166 | return ptr; 167 | } 168 | 169 | void btAlignedFreeInternal (void* ptr) 170 | { 171 | if (!ptr) 172 | { 173 | return; 174 | } 175 | 176 | gNumAlignedFree++; 177 | // printf("btAlignedFreeInternal %x\n",ptr); 178 | sAlignedFreeFunc(ptr); 179 | } 180 | 181 | #endif //BT_DEBUG_MEMORY_ALLOCATIONS 182 | 183 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd/src/vhacdGraph.cpp: -------------------------------------------------------------------------------- 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 | #include 16 | namespace VHACD 17 | { 18 | 19 | GraphEdge::GraphEdge() 20 | { 21 | m_v1 = -1; 22 | m_v2 = -1; 23 | m_name = -1; 24 | m_volume = 0; 25 | m_concavity = 0; 26 | m_deleted = false; 27 | m_convexHull = 0; 28 | } 29 | 30 | GraphVertex::GraphVertex() 31 | { 32 | m_name = -1; 33 | m_concavity = 0; 34 | m_volume = 0; 35 | m_deleted = false; 36 | } 37 | 38 | bool GraphVertex::DeleteEdge(long name) 39 | { 40 | return m_edges.Erase(name); 41 | } 42 | 43 | Graph::Graph() 44 | { 45 | m_nV = 0; 46 | m_nE = 0; 47 | m_nCCs = 0; 48 | } 49 | 50 | Graph::~Graph() 51 | { 52 | } 53 | 54 | void Graph::Allocate(size_t nV, size_t nE) 55 | { 56 | m_nV = nV; 57 | m_edges.reserve(nE); 58 | m_vertices.resize(nV); 59 | for(size_t i = 0; i < nV; i++) 60 | { 61 | m_vertices[i].m_name = static_cast(i); 62 | } 63 | } 64 | 65 | long Graph::AddVertex() 66 | { 67 | size_t name = m_vertices.size(); 68 | m_vertices.resize(name+1); 69 | m_vertices[name].m_name = static_cast(name); 70 | m_nV++; 71 | return static_cast(name); 72 | } 73 | 74 | long Graph::AddEdge(long v1, long v2) 75 | { 76 | size_t name = m_edges.size(); 77 | m_edges.push_back(GraphEdge()); 78 | m_edges[name].m_name = static_cast(name); 79 | m_edges[name].m_v1 = v1; 80 | m_edges[name].m_v2 = v2; 81 | m_vertices[v1].AddEdge(static_cast(name)); 82 | m_vertices[v2].AddEdge(static_cast(name)); 83 | m_nE++; 84 | return static_cast(name); 85 | } 86 | 87 | bool Graph::DeleteEdge(long name) 88 | { 89 | if (name < static_cast(m_edges.size())) 90 | { 91 | long v1 = m_edges[name].m_v1; 92 | long v2 = m_edges[name].m_v2; 93 | m_edges[name].m_deleted = true; 94 | m_vertices[v1].DeleteEdge(name); 95 | m_vertices[v2].DeleteEdge(name); 96 | m_nE--; 97 | return true; 98 | } 99 | return false; 100 | } 101 | bool Graph::DeleteVertex(long name) 102 | { 103 | if (name < static_cast(m_vertices.size())) 104 | { 105 | m_vertices[name].m_deleted = true; 106 | m_vertices[name].m_edges.Clear(); 107 | m_vertices[name].m_ancestors.Clear(); 108 | m_nV--; 109 | return true; 110 | } 111 | return false; 112 | } 113 | bool Graph::EdgeCollapse(long v1, long v2) 114 | { 115 | long edgeToDelete = GetEdgeID(v1, v2); 116 | if (edgeToDelete >= 0) 117 | { 118 | // delete the edge (v1, v2) 119 | DeleteEdge(edgeToDelete); 120 | 121 | size_t nA = m_vertices[v2].m_ancestors.Size(); 122 | m_vertices[v1].m_ancestors.PushBack(v2); 123 | for(size_t a = 0; a < nA; ++a) 124 | { 125 | m_vertices[v1].m_ancestors.PushBack(m_vertices[v2].m_ancestors[a]); 126 | } 127 | 128 | // update adjacency information 129 | SArray & v1Edges = m_vertices[v1].m_edges; 130 | long b = -1; 131 | long idEdge; 132 | for(size_t ed = 0; ed < m_vertices[v2].m_edges.Size(); ++ed) 133 | { 134 | idEdge = m_vertices[v2].m_edges[ed]; 135 | if (m_edges[idEdge].m_v1 == v2) 136 | { 137 | b = m_edges[idEdge].m_v2; 138 | } 139 | else 140 | { 141 | b = m_edges[idEdge].m_v1; 142 | } 143 | if (GetEdgeID(v1, b) >= 0) 144 | { 145 | m_edges[idEdge].m_deleted = true; 146 | m_vertices[b].DeleteEdge(idEdge); 147 | m_nE--; 148 | } 149 | else 150 | { 151 | m_edges[idEdge].m_v1 = v1; 152 | m_edges[idEdge].m_v2 = b; 153 | v1Edges.Insert(idEdge); 154 | } 155 | } 156 | // delete the vertex v2 157 | DeleteVertex(v2); 158 | return true; 159 | } 160 | return false; 161 | } 162 | 163 | long Graph::GetEdgeID(long v1, long v2) const 164 | { 165 | if (v1 < static_cast(m_vertices.size()) && !m_vertices[v1].m_deleted) 166 | { 167 | long idEdge; 168 | for(size_t ed = 0; ed < m_vertices[v1].m_edges.Size(); ++ed) 169 | { 170 | idEdge = m_vertices[v1].m_edges[ed]; 171 | if ( (m_edges[idEdge].m_v1 == v2) || 172 | (m_edges[idEdge].m_v2 == v2) ) 173 | { 174 | return m_edges[idEdge].m_name; 175 | } 176 | } 177 | } 178 | return -1; 179 | } 180 | 181 | void Graph::Print() const 182 | { 183 | std::cout << "-----------------------------" << std::endl; 184 | std::cout << "vertices (" << m_nV << ")" << std::endl; 185 | for (size_t v = 0; v < m_vertices.size(); ++v) 186 | { 187 | const GraphVertex & currentVertex = m_vertices[v]; 188 | if (!m_vertices[v].m_deleted) 189 | { 190 | 191 | std::cout << currentVertex.m_name << "\t"; 192 | long idEdge; 193 | for(size_t ed = 0; ed < currentVertex.m_edges.Size(); ++ed) 194 | { 195 | idEdge = currentVertex.m_edges[ed]; 196 | std::cout << "(" << m_edges[idEdge].m_v1 << "," << m_edges[idEdge].m_v2 << ") "; 197 | } 198 | std::cout << std::endl; 199 | } 200 | } 201 | 202 | std::cout << "vertices (" << m_nE << ")" << std::endl; 203 | for (size_t e = 0; e < m_edges.size(); ++e) 204 | { 205 | const GraphEdge & currentEdge = m_edges[e]; 206 | if (!m_edges[e].m_deleted) 207 | { 208 | std::cout << currentEdge.m_name << "\t(" 209 | << m_edges[e].m_v1 << "," 210 | << m_edges[e].m_v2 << ") "<< std::endl; 211 | } 212 | } 213 | } 214 | void Graph::Clear() 215 | { 216 | m_vertices.clear(); 217 | m_edges.clear(); 218 | m_nV = 0; 219 | m_nE = 0; 220 | } 221 | 222 | } -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd_CLI.cpp: -------------------------------------------------------------------------------- 1 | // This is the main DLL file. 2 | 3 | #include "vhacd_CLI.h" 4 | 5 | -------------------------------------------------------------------------------- /decomposition_hacd_CLI/vhacd_CLI.h: -------------------------------------------------------------------------------- 1 | // vhacd_CLI.h 2 | 3 | #pragma once 4 | 5 | #include "vhacdHACD.h" 6 | #include "vhacdMeshDecimator.h" 7 | 8 | 9 | using namespace System; 10 | 11 | 12 | namespace vhacd_CLI { 13 | 14 | public ref class Vect3D 15 | { 16 | public: 17 | Vect3D(double mX, double mY, double mZ) 18 | { 19 | X = mX; 20 | Y = mY; 21 | Z = mZ; 22 | } 23 | Vect3D() 24 | { 25 | X = 0; 26 | Y = 0; 27 | Z = 0; 28 | } 29 | double X; 30 | double Y; 31 | double Z; 32 | }; 33 | 34 | public ref class Triangle 35 | { 36 | public: 37 | Triangle(int mp1, int mp2, int mp3) 38 | { 39 | p1 = mp1; 40 | p2 = mp2; 41 | p3 = mp3; 42 | } 43 | int p1; 44 | int p2; 45 | int p3; 46 | }; 47 | 48 | 49 | void myCallBack(const char * msg, double progress, double concavity, size_t nVertices) 50 | { 51 | std::cout << msg; 52 | } 53 | 54 | 55 | public ref class vhacd_CLI_wrapper 56 | { 57 | public: 58 | vhacd_CLI_wrapper() 59 | { 60 | myMesh = new VHACD::Mesh(); 61 | points = new std::vector< VHACD::Vec3 >; 62 | triangles = new std::vector< VHACD::Vec3 >; 63 | parts = new std::vector< VHACD::Mesh * >; 64 | 65 | this->targetNTrianglesDecimatedMesh = 1000; 66 | this->depth =10; 67 | this->concavity = 0.01; 68 | this->posSampling = 10; 69 | this->angleSampling = 10; 70 | this->posRefine = 5; 71 | this->angleRefine = 5; 72 | this->alpha = 0.01; 73 | } 74 | 75 | ~vhacd_CLI_wrapper() { this->!vhacd_CLI_wrapper(); } 76 | 77 | !vhacd_CLI_wrapper() 78 | { 79 | delete parts; 80 | delete points; 81 | delete triangles; 82 | delete myMesh; 83 | } 84 | 85 | /// Preferences-setting functions: 86 | /* 87 | void SetVolumeWeight(double mval) 88 | { 89 | myHACD->SetVolumeWeight(mval); 90 | } 91 | */ 92 | 93 | 94 | 95 | /// Pass the mesh data as an array of vertexes 96 | /// and an array of triangles (indices of vertexes) 97 | void SetMesh(array ^managedpoints, array ^managedtriangles) 98 | { 99 | // marshal array in: 100 | points->clear(); 101 | for (int i = 0; i< managedpoints->GetLength(0); i++) 102 | { 103 | VHACD::Vec3 mpt(managedpoints[i]->X, managedpoints[i]->Y, managedpoints[i]->Z); 104 | points->push_back(mpt); 105 | } 106 | 107 | // marshal array in: 108 | triangles->clear(); 109 | for (int i = 0; i< managedtriangles->GetLength(0); i++) 110 | { 111 | VHACD::Vec3 mtri(managedtriangles[i]->p1, managedtriangles[i]->p2, managedtriangles[i]->p3); 112 | triangles->push_back(mtri); 113 | } 114 | 115 | bool decimatedMeshComputed = false; 116 | size_t nTriangles = triangles->size(); 117 | size_t nPoints = points->size(); 118 | VHACD::Vec3 * pPoints = &((*points)[0]); 119 | VHACD::Vec3 * pTriangles = &((*triangles)[0]); 120 | 121 | if (targetNTrianglesDecimatedMesh > 0 && targetNTrianglesDecimatedMesh < nTriangles) 122 | { 123 | decimatedMeshComputed = true; 124 | 125 | VHACD::MeshDecimator myMDecimator; 126 | //myMDecimator.SetCallBack(&myCallBack); 127 | myMDecimator.Initialize(nPoints, nTriangles, (VHACD::Vec3*)&(points[0]), (VHACD::Vec3*)&(triangles[0])); 128 | myMDecimator.Decimate(0, targetNTrianglesDecimatedMesh); 129 | 130 | nTriangles = myMDecimator.GetNTriangles(); 131 | nPoints = myMDecimator.GetNVertices(); 132 | pPoints = new VHACD::Vec3[nPoints]; 133 | pTriangles = new VHACD::Vec3[nTriangles]; 134 | myMDecimator.GetMeshData(pPoints, pTriangles); 135 | } 136 | 137 | myMesh->ResizePoints(nPoints); 138 | myMesh->ResizeTriangles(nTriangles); 139 | for(size_t p = 0; p < nPoints; ++p) myMesh->SetPoint(p, pPoints[p]); 140 | for(size_t t = 0; t < nTriangles; ++t) myMesh->SetTriangle(t, pTriangles[t]); 141 | if (decimatedMeshComputed) 142 | { 143 | delete [] pPoints; 144 | delete [] pTriangles; 145 | } 146 | 147 | } 148 | 149 | 150 | /// Compute the convex decomposition!!! 151 | /// Call this function after having set the preferences and 152 | /// after having used SetMesh(), and fetch results via GetNClusters() and GetClusterConvexHull() 153 | int Compute(bool fullCH, bool exportDistPoints) 154 | { 155 | VHACD::ApproximateConvexDecomposition(*this->myMesh, 156 | depth, 157 | posSampling, 158 | angleSampling, 159 | posRefine, 160 | angleRefine, 161 | alpha, 162 | concavity, 163 | *parts, 164 | 0); 165 | return parts->size(); 166 | } 167 | /* 168 | void Save(System::String^ mpath) 169 | { 170 | IntPtr p = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(mpath); 171 | char *pNewCharStr = static_cast(p.ToPointer()); 172 | 173 | myMesh->SaveVRML2(std::string(pNewCharStr), false); 174 | 175 | System::Runtime::InteropServices::Marshal::FreeHGlobal(p); 176 | } 177 | */ 178 | 179 | /// Get the number of computed convex hulls 180 | int GetNClusters() 181 | { 182 | return parts->size(); 183 | } 184 | 185 | /// Get the vertexes (and triangulation, if needed) 186 | /// of the Nth resulting convex hull. 187 | int GetClusterConvexHull(int ncluster, array^% managedpoints, array^% managedtriangles) 188 | { 189 | VHACD::Mesh ch; 190 | (*parts)[ncluster]->ComputeConvexHull(ch); 191 | 192 | size_t nPoints = ch.GetNPoints(); 193 | size_t nTriangles = ch.GetNTriangles(); 194 | VHACD::Vec3 * pointsCH = new VHACD::Vec3[nPoints]; 195 | VHACD::Vec3 * trianglesCH = new VHACD::Vec3[nTriangles]; 196 | 197 | //myVHACD->GetCH(ncluster, pointsCH, trianglesCH); 198 | //marshal array out: 199 | Array::Resize(managedpoints,nPoints); 200 | for (int i=0;i* parts; 214 | 215 | std::vector< VHACD::Vec3 >* points; 216 | std::vector< VHACD::Vec3 >* triangles; 217 | 218 | public: 219 | int targetNTrianglesDecimatedMesh; 220 | int depth; 221 | int posSampling; 222 | int angleSampling; 223 | int posRefine; 224 | int angleRefine; 225 | double alpha; 226 | double concavity; 227 | 228 | }; 229 | 230 | 231 | 232 | } 233 | -------------------------------------------------------------------------------- /installer/SetupModern20.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/installer/SetupModern20.bmp -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.13.0.3/.signature.p7s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/packages/Newtonsoft.Json.13.0.3/.signature.p7s -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.13.0.3/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2007 James Newton-King 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.13.0.3/Newtonsoft.Json.13.0.3.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/packages/Newtonsoft.Json.13.0.3/Newtonsoft.Json.13.0.3.nupkg -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.13.0.3/README.md: -------------------------------------------------------------------------------- 1 | # ![Logo](https://raw.githubusercontent.com/JamesNK/Newtonsoft.Json/master/Doc/icons/logo.jpg) Json.NET 2 | 3 | [![NuGet version (Newtonsoft.Json)](https://img.shields.io/nuget/v/Newtonsoft.Json.svg?style=flat-square)](https://www.nuget.org/packages/Newtonsoft.Json/) 4 | [![Build status](https://dev.azure.com/jamesnk/Public/_apis/build/status/JamesNK.Newtonsoft.Json?branchName=master)](https://dev.azure.com/jamesnk/Public/_build/latest?definitionId=8) 5 | 6 | Json.NET is a popular high-performance JSON framework for .NET 7 | 8 | ## Serialize JSON 9 | 10 | ```csharp 11 | Product product = new Product(); 12 | product.Name = "Apple"; 13 | product.Expiry = new DateTime(2008, 12, 28); 14 | product.Sizes = new string[] { "Small" }; 15 | 16 | string json = JsonConvert.SerializeObject(product); 17 | // { 18 | // "Name": "Apple", 19 | // "Expiry": "2008-12-28T00:00:00", 20 | // "Sizes": [ 21 | // "Small" 22 | // ] 23 | // } 24 | ``` 25 | 26 | ## Deserialize JSON 27 | 28 | ```csharp 29 | string json = @"{ 30 | 'Name': 'Bad Boys', 31 | 'ReleaseDate': '1995-4-7T00:00:00', 32 | 'Genres': [ 33 | 'Action', 34 | 'Comedy' 35 | ] 36 | }"; 37 | 38 | Movie m = JsonConvert.DeserializeObject(json); 39 | 40 | string name = m.Name; 41 | // Bad Boys 42 | ``` 43 | 44 | ## LINQ to JSON 45 | 46 | ```csharp 47 | JArray array = new JArray(); 48 | array.Add("Manual text"); 49 | array.Add(new DateTime(2000, 5, 23)); 50 | 51 | JObject o = new JObject(); 52 | o["MyArray"] = array; 53 | 54 | string json = o.ToString(); 55 | // { 56 | // "MyArray": [ 57 | // "Manual text", 58 | // "2000-05-23T00:00:00" 59 | // ] 60 | // } 61 | ``` 62 | 63 | ## Links 64 | 65 | - [Homepage](https://www.newtonsoft.com/json) 66 | - [Documentation](https://www.newtonsoft.com/json/help) 67 | - [NuGet Package](https://www.nuget.org/packages/Newtonsoft.Json) 68 | - [Release Notes](https://github.com/JamesNK/Newtonsoft.Json/releases) 69 | - [Contributing Guidelines](https://github.com/JamesNK/Newtonsoft.Json/blob/master/CONTRIBUTING.md) 70 | - [License](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md) 71 | - [Stack Overflow](https://stackoverflow.com/questions/tagged/json.net) 72 | -------------------------------------------------------------------------------- /packages/Newtonsoft.Json.13.0.3/packageIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/packages/Newtonsoft.Json.13.0.3/packageIcon.png -------------------------------------------------------------------------------- /to_put_in_app_dir/ChronoSolidworksImportTemplate/solid_import_cpp.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // PROJECT CHRONO - http://projectchrono.org 3 | // 4 | // Copyright (c) 2014 projectchrono.org 5 | // All rights reserved. 6 | // 7 | // Use of this source code is governed by a BSD-style license that can be found 8 | // in the LICENSE file at the top level of the distribution and at 9 | // http://projectchrono.org/license-chrono.txt. 10 | // 11 | // ============================================================================= 12 | // Template project for loading a C++ model exported by Chrono::Solidworks 13 | // into a Chrono C++ simulation. 14 | // ============================================================================= 15 | 16 | #include "chrono/physics/ChSystemNSC.h" 17 | #include "chrono/core/ChRealtimeStep.h" 18 | #include "chrono_irrlicht/ChVisualSystemIrrlicht.h" 19 | #include SOLIDWORKS_EXPORTED_HEADER 20 | 21 | // Use the namespace of Chrono 22 | using namespace chrono; 23 | using namespace chrono::irrlicht; 24 | 25 | int main(int argc, char* argv[]) { 26 | std::cout << "Copyright (c) 2024 projectchrono.org\nChrono version: " << CHRONO_VERSION << std::endl; 27 | 28 | // Set path to Chrono data directory 29 | SetChronoDataPath(CHRONO_DATA_DIR); 30 | 31 | // Create a Chrono physical system 32 | ChSystemNSC sys; 33 | sys.SetCollisionSystemType(chrono::ChCollisionSystem::Type::BULLET); 34 | 35 | // Customize collision envelopes and margin, if necessary 36 | // This is expecially important for very large or very small objects 37 | // Do this before creating shapes 38 | //ChCollisionModel::SetDefaultSuggestedEnvelope(0.001) 39 | //ChCollisionModel::SetDefaultSuggestedMargin(0.001) 40 | 41 | // Load the file generated by the SolidWorks CAD plugin and add it to the system 42 | std::unordered_map> motfun_map; 43 | try { 44 | ImportSolidworksSystemCpp(sys, &motfun_map); 45 | } 46 | catch (const std::exception& exc) { 47 | std::cout << exc.what() << std::endl; 48 | } 49 | 50 | // Log out all the names of the items inserted in the system 51 | sys.ShowHierarchy(std::cout); 52 | 53 | // Create the Irrlicht visualization system 54 | ChVisualSystemIrrlicht vis; 55 | vis.SetWindowSize(1024, 768); 56 | vis.SetWindowTitle("ChronoSolidworksImportCPP"); 57 | vis.Initialize(); 58 | vis.AddLogo(); 59 | vis.AddSkyBox(); 60 | vis.AddTypicalLights(); 61 | vis.AddCamera(ChVector3d(2, 2, 2), ChVector3d(0, 0, 0)); 62 | vis.AttachSystem(&sys); 63 | 64 | vis.EnableCollisionShapeDrawing(true); 65 | 66 | 67 | // Simulation loop 68 | ChRealtimeStepTimer realtime_timer; 69 | double timestep = 0.01; 70 | 71 | sys.SetSolverType(ChSolver::Type::BARZILAIBORWEIN); 72 | sys.GetSolver()->AsIterative()->SetMaxIterations(400); 73 | 74 | while (vis.Run()) { 75 | // Render scene 76 | vis.BeginScene(); 77 | vis.Render(); 78 | vis.EndScene(); 79 | 80 | // Perform the integration step 81 | sys.DoStepDynamics(timestep); 82 | 83 | // Spin in place to maintain soft real-time 84 | realtime_timer.Spin(timestep); 85 | } 86 | 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /to_put_in_app_dir/ChronoSolidworksImportTemplate/solid_import_json.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // PROJECT CHRONO - http://projectchrono.org 3 | // 4 | // Copyright (c) 2014 projectchrono.org 5 | // All rights reserved. 6 | // 7 | // Use of this source code is governed by a BSD-style license that can be found 8 | // in the LICENSE file at the top level of the distribution and at 9 | // http://projectchrono.org/license-chrono.txt. 10 | // 11 | // ============================================================================= 12 | // Template project for loading a Json model exported by Chrono::Solidworks 13 | // into a Chrono C++ simulation. 14 | // ============================================================================= 15 | 16 | #include "chrono/physics/ChSystemNSC.h" 17 | #include "chrono/core/ChRealtimeStep.h" 18 | #include "chrono/serialization/ChArchiveJSON.h" 19 | 20 | #undef CHRONO_VSG 21 | 22 | #ifdef CHRONO_COLLISION 23 | #include "chrono/collision/multicore/ChCollisionSystemMulticore.h" 24 | #endif 25 | 26 | #ifdef CHRONO_IRRLICHT 27 | #include "chrono_irrlicht/ChVisualSystemIrrlicht.h" 28 | using namespace chrono::irrlicht; 29 | #endif 30 | #ifdef CHRONO_VSG 31 | #include "chrono_vsg/ChVisualSystemVSG.h" 32 | using namespace chrono::vsg3d; 33 | #endif 34 | 35 | using namespace chrono; 36 | 37 | ChVisualSystem::Type vis_type = ChVisualSystem::Type::IRRLICHT; 38 | 39 | ChCollisionSystem::Type collision_type = ChCollisionSystem::Type::BULLET; 40 | 41 | 42 | int main(int argc, char* argv[]) { 43 | std::cout << "Copyright (c) 2024 projectchrono.org\nChrono version: " << CHRONO_VERSION << "\n\n"; 44 | 45 | // Set path to Chrono data directory 46 | SetChronoDataPath(CHRONO_DATA_DIR); 47 | 48 | // Create the physical system 49 | ChSystemNSC sys; 50 | sys.SetCollisionSystemType(collision_type); 51 | 52 | // Settings specific to Chrono multicore collision system 53 | if (collision_type == ChCollisionSystem::Type::MULTICORE) { 54 | #ifdef CHRONO_COLLISION 55 | auto collsys = std::static_pointer_cast(sys.GetCollisionSystem()); 56 | // Change the default number of broadphase bins 57 | collsys->SetBroadphaseGridResolution(ChVector3i(10, 10, 2)); 58 | // Change default narrowphase algorithm 59 | ////collsys->SetNarrowphaseAlgorithm(ChNarrowphase::Algorithm::MPR); 60 | collsys->SetEnvelope(0.005); 61 | // Enable active bounding box 62 | collsys->EnableActiveBoundingBox(ChVector3d(-10, -10, -20), ChVector3d(+10, +10, +10)); 63 | // Set number of threads used by the collision detection system 64 | collsys->SetNumThreads(4); 65 | #endif 66 | } 67 | 68 | 69 | // Load the file generated by the SolidWorks CAD plugin and add it to the system 70 | std::string jsonfile = SOLIDWORKS_EXPORTED_JSON; 71 | std::ifstream mfilei(jsonfile.c_str()); 72 | 73 | ChArchiveInJSON marchivein(mfilei); 74 | marchivein >> CHNVP(sys, "sys"); 75 | 76 | 77 | 78 | // Create the run-time visualization system 79 | #ifndef CHRONO_IRRLICHT 80 | if (vis_type == ChVisualSystem::Type::IRRLICHT) 81 | vis_type = ChVisualSystem::Type::VSG; 82 | #endif 83 | #ifndef CHRONO_VSG 84 | if (vis_type == ChVisualSystem::Type::VSG) 85 | vis_type = ChVisualSystem::Type::IRRLICHT; 86 | #endif 87 | 88 | std::shared_ptr vis; 89 | switch (vis_type) { 90 | case ChVisualSystem::Type::IRRLICHT: { 91 | #ifdef CHRONO_IRRLICHT 92 | auto vis_irr = chrono_types::make_shared(); 93 | vis_irr->SetWindowSize(1024, 768); 94 | vis_irr->SetWindowTitle("ChronoSolidworksImportJSON"); 95 | vis_irr->Initialize(); 96 | vis_irr->AddLogo(); 97 | vis_irr->AddSkyBox(); 98 | vis_irr->AddTypicalLights(); 99 | vis_irr->AddCamera(ChVector3d(2, 2, 2), ChVector3d(0, 0, 0)); 100 | vis_irr->AttachSystem(&sys); 101 | vis_irr->EnableCollisionShapeDrawing(true); 102 | 103 | vis = vis_irr; 104 | #endif 105 | break; 106 | } 107 | default: 108 | case ChVisualSystem::Type::VSG: { 109 | #ifdef CHRONO_VSG 110 | auto vis_vsg = chrono_types::make_shared(); 111 | vis_vsg->AttachSystem(&sys); 112 | vis_vsg->SetWindowTitle("ChronoSolidworksImportJSON"); 113 | vis_vsg->AddCamera(ChVector<>(2, 2, 2)); 114 | vis_vsg->SetWindowSize(ChVector2(1024, 768)); 115 | vis_vsg->SetWindowPosition(ChVector2(100, 100)); 116 | vis_vsg->SetClearColor(ChColor(0.8f, 0.85f, 0.9f)); 117 | vis_vsg->SetUseSkyBox(true); // use built-in path 118 | vis_vsg->SetCameraVertical(CameraVerticalDir::Y); 119 | vis_vsg->SetCameraAngleDeg(40.0); 120 | vis_vsg->SetLightIntensity(1.0f); 121 | vis_vsg->SetLightDirection(1.5 * CH_C_PI_2, CH_C_PI_4); 122 | vis_vsg->SetWireFrameMode(false); 123 | vis_vsg->Initialize(); 124 | 125 | vis = vis_vsg; 126 | #endif 127 | break; 128 | } 129 | } 130 | 131 | 132 | // Simulation loop 133 | ChRealtimeStepTimer realtime_timer; 134 | double timestep = 0.01; 135 | 136 | sys.SetSolverType(ChSolver::Type::BARZILAIBORWEIN); 137 | sys.GetSolver()->AsIterative()->SetMaxIterations(400); 138 | 139 | while (vis->Run()) { 140 | // Render scene 141 | vis->BeginScene(); 142 | vis->Render(); 143 | vis->EndScene(); 144 | 145 | // Perform the integration step 146 | sys.DoStepDynamics(timestep); 147 | 148 | // Spin in place to maintain soft real-time 149 | realtime_timer.Spin(timestep); 150 | } 151 | 152 | return 0; 153 | } 154 | -------------------------------------------------------------------------------- /to_put_in_app_dir/ChronoSolidworksImportTemplate/solid_import_pychrono.py.in: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # PROJECT CHRONO - http://projectchrono.org 3 | # 4 | # Copyright (c) 2014 projectchrono.org 5 | # All rights reserved. 6 | # 7 | # Use of this source code is governed by a BSD-style license that can be found 8 | # in the LICENSE file at the top level of the distribution and at 9 | # http://projectchrono.org/license-chrono.txt. 10 | # 11 | # ============================================================================= 12 | # Template project for loading a Python model exported by Chrono::Solidworks 13 | # into a PyChrono simulation. 14 | # ============================================================================= 15 | 16 | import pychrono as chrono 17 | import pychrono.irrlicht as chronoirr 18 | 19 | # The path to the Chrono data directory containing various assets (meshes, textures, data files) 20 | # is automatically set, relative to the default location of this demo. 21 | # If running from a different directory, you must change the path to the data directory with: 22 | #chrono.SetChronoDataPath('path/to/data') 23 | 24 | 25 | # Create a Chrono physical system 26 | sys = chrono.ChSystemNSC() 27 | sys.SetCollisionSystemType(chrono.ChCollisionSystem.Type_BULLET) 28 | 29 | # Customize collision envelopes and margin, if necessary 30 | # This is expecially important for very large or very small objects 31 | # Do this before creating shapes 32 | #chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.001) 33 | #chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.001) 34 | 35 | 36 | # Load the file generated by the SolidWorks CAD plugin and add it to the system 37 | print ("Loading Chrono scene...") 38 | 39 | exported_items = chrono.ImportSolidWorksSystem('@SOLIDWORKS_EXPORTED_FILE_PY@') # ENTER THE NAME OF SLDW EXPORT HERE 40 | 41 | print ("...done!") 42 | 43 | # Add items to the physical system 44 | for item in exported_items: 45 | sys.Add(item) 46 | 47 | # Print exported items 48 | print("List of items added to system:") 49 | for item in exported_items: 50 | print (" " + item.GetName()) 51 | 52 | # Create the Irrlicht visualization system 53 | vis = chronoirr.ChVisualSystemIrrlicht() 54 | vis.SetWindowSize(1024, 768) 55 | vis.SetWindowTitle('ChronoSolidworksImportPy') 56 | vis.Initialize() 57 | vis.AddLogo(chrono.GetChronoDataFile('logo_pychrono_alpha.png')) 58 | vis.AddSkyBox() 59 | vis.AddTypicalLights() 60 | vis.AddCamera(chrono.ChVector3d(2, 2, 2), chrono.ChVector3d(0, 0, 0)) 61 | vis.AttachSystem(sys) 62 | 63 | vis.EnableCollisionShapeDrawing(True) 64 | 65 | 66 | # Simulation loop 67 | realtime_timer = chrono.ChRealtimeStepTimer() 68 | timestep = 0.01 69 | 70 | sys.SetSolverType(chrono.ChSolver.Type_BARZILAIBORWEIN) 71 | sys.GetSolver().AsIterative().SetMaxIterations(400) 72 | 73 | while vis.Run(): 74 | # Render scene 75 | vis.BeginScene() 76 | vis.Render() 77 | vis.EndScene() 78 | 79 | # Perform the integration stpe 80 | sys.DoStepDynamics(timestep) 81 | 82 | # Spin in place to maintain soft real-time 83 | realtime_timer.Spin(timestep) 84 | -------------------------------------------------------------------------------- /to_put_in_app_dir/ChronoSolidworksImportTemplate/solid_import_pyparser.cpp: -------------------------------------------------------------------------------- 1 | // ============================================================================= 2 | // PROJECT CHRONO - http://projectchrono.org 3 | // 4 | // Copyright (c) 2014 projectchrono.org 5 | // All rights reserved. 6 | // 7 | // Use of this source code is governed by a BSD-style license that can be found 8 | // in the LICENSE file at the top level of the distribution and at 9 | // http://projectchrono.org/license-chrono.txt. 10 | // 11 | // ============================================================================= 12 | // Template project for loading a Python model exported by Chrono::Solidworks 13 | // into a Chrono C++ simulation. 14 | // ============================================================================= 15 | 16 | #include "chrono/physics/ChSystemNSC.h" 17 | #include "chrono/core/ChRealtimeStep.h" 18 | #include "chrono_irrlicht/ChVisualSystemIrrlicht.h" 19 | #include "chrono_parsers/ChParserPython.h" 20 | 21 | using namespace chrono; 22 | using namespace chrono::irrlicht; 23 | 24 | int main(int argc, char* argv[]) { 25 | std::cout << "Copyright (c) 2024 projectchrono.org\nChrono version: " << CHRONO_VERSION << std::endl; 26 | 27 | // Set path to Chrono data directory 28 | SetChronoDataPath(CHRONO_DATA_DIR); 29 | 30 | // Cache current path to Chrono data files 31 | auto data_path = GetChronoDataPath(); 32 | 33 | // Create a Chrono physical system 34 | ChSystemNSC sys; 35 | sys.SetCollisionSystemType(chrono::ChCollisionSystem::Type::BULLET); 36 | 37 | // Customize collision envelopes and margin, if necessary 38 | // This is expecially important for very large or very small objects 39 | // Do this before creating shapes 40 | //ChCollisionModel::SetDefaultSuggestedEnvelope(0.001) 41 | //ChCollisionModel::SetDefaultSuggestedMargin(0.001) 42 | 43 | 44 | // Python parsing engine 45 | parsers::ChPythonEngine pyengine; 46 | 47 | // Load the file generated by the SolidWorks CAD plugin and add it to the system 48 | try { 49 | pyengine.ImportSolidWorksSystem(SOLIDWORKS_EXPORTED_PY, sys); 50 | } 51 | catch (const std::exception& exc) { 52 | std::cout << exc.what() << std::endl; 53 | } 54 | 55 | // Log out all the names of the items inserted in the system 56 | sys.ShowHierarchy(std::cout); 57 | 58 | 59 | // Create the Irrlicht visualization system 60 | ChVisualSystemIrrlicht vis; 61 | vis.SetWindowSize(1024, 768); 62 | vis.SetWindowTitle("ChronoSolidworksImportCPP"); 63 | vis.Initialize(); 64 | vis.AddLogo(); 65 | vis.AddSkyBox(); 66 | vis.AddTypicalLights(); 67 | vis.AddCamera(ChVector3d(2, 2, 2), ChVector3d(0, 0, 0)); 68 | vis.AttachSystem(&sys); 69 | 70 | vis.EnableCollisionShapeDrawing(true); 71 | 72 | 73 | // Simulation loop 74 | ChRealtimeStepTimer realtime_timer; 75 | double timestep = 0.01; 76 | 77 | sys.SetSolverType(ChSolver::Type::BARZILAIBORWEIN); 78 | sys.GetSolver()->AsIterative()->SetMaxIterations(400); 79 | 80 | while (vis.Run()) { 81 | // Render scene 82 | vis.BeginScene(); 83 | vis.Render(); 84 | vis.EndScene(); 85 | 86 | // Perform the integration step 87 | sys.DoStepDynamics(timestep); 88 | 89 | // Spin in place to maintain soft real-time 90 | realtime_timer.Spin(timestep); 91 | } 92 | 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /to_put_in_app_dir/data/fonts/arial80.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/data/fonts/arial80.bmp -------------------------------------------------------------------------------- /to_put_in_app_dir/data/logo_pychrono_alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/data/logo_pychrono_alpha.png -------------------------------------------------------------------------------- /to_put_in_app_dir/data/skybox/sky_dn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/data/skybox/sky_dn.jpg -------------------------------------------------------------------------------- /to_put_in_app_dir/data/skybox/sky_lf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/data/skybox/sky_lf.jpg -------------------------------------------------------------------------------- /to_put_in_app_dir/data/skybox/sky_up.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/data/skybox/sky_up.jpg -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/addin_tester_simulation.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # 3 | # Test simulation to check integrity of Chrono::Solidworks Addin exporter 4 | # with respect to: 5 | # 1) bodies 6 | # 2) links 7 | # 3) visual shapes, colors, transparencies 8 | # 4) collision shapes 9 | # 5) markers 10 | # 6) rigid sub-assemblies, flexible sub-assemblies 11 | # 12 | #------------------------------------------------------------------------------- 13 | 14 | import pychrono as chrono 15 | import pychrono.irrlicht as chronoirr 16 | 17 | system = chrono.ChSystemNSC() 18 | system.Set_G_acc(chrono.ChVectorD(0, -9.81, 0)) 19 | 20 | filepath = "./test_py_export.py" 21 | imported_items = chrono.ImportSolidWorksSystem(filepath) 22 | for ii in imported_items: 23 | system.Add(ii) 24 | 25 | system.ShowHierarchy(chrono.GetLog()) 26 | 27 | # Customize contact material 28 | mat = chrono.ChMaterialSurfaceNSC() 29 | mat.SetFriction(0.3) 30 | mat.SetRestitution(1) 31 | for ii in system.Get_bodylist(): 32 | if (ii.GetCollisionModel()): 33 | ii.GetCollisionModel().SetAllShapesMaterial(mat) 34 | 35 | system.RemoveRedundantConstraints(False, 1e-6, True) 36 | system.DoFullAssembly() 37 | 38 | vis = chronoirr.ChVisualSystemIrrlicht(system, chrono.ChVectorD(0, 0, 5)) 39 | 40 | vis.EnableCollisionShapeDrawing(True) 41 | 42 | timestep = 0.002 43 | rt_timer = chrono.ChRealtimeStepTimer() 44 | 45 | solver = chrono.ChSolverBB() 46 | solver.SetMaxIterations(500) 47 | # solver.EnableWarmStart(True) 48 | # solver.EnableDiagonalPreconditioner(True) 49 | system.SetSolver(solver) 50 | 51 | while vis.Run(): 52 | vis.BeginScene() 53 | vis.Render() 54 | 55 | if not vis.GetUtilityFlag(): 56 | system.DoStepDynamics(timestep) 57 | vis.EndScene() 58 | rt_timer.Spin(timestep) -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/FlexibleSubAssem.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/FlexibleSubAssem.SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/MainAssembly.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/MainAssembly.SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part1.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part1.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part10.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part10.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part11.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part11.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part12.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part12.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part2.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part2.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part3.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part3.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part4.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part4.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part5.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part5.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part6.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part6.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part7.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part7.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part8.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part8.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/Part9.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/Part9.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/addin_tester/cad/RigidSubAssem.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/addin_tester/cad/RigidSubAssem.SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/collisions/capital.sldprt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/collisions/capital.sldprt -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/collisions/column.sldprt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/collisions/column.sldprt -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/collisions/demo_SW_collisions.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # 3 | # This file shows how to simulate collision shapes 4 | # 5 | # Author: Alessandro Tasora 6 | # 7 | # REMARK: this is part of Chrono::Solidworks add-in 8 | # - it assumes that you exported the .asm in this directory using the add-in 9 | # - PyChrono must be installed in your Python environment 10 | #------------------------------------------------------------------------------- 11 | 12 | import sys 13 | import pychrono as chrono 14 | import pychrono.irrlicht as chronoirr 15 | 16 | print("Demo program that shows how to use the SolidWorks add-in.") 17 | print(" 1) use the SolidWorks Add-in, load the .SLDASM,") 18 | print(" 2) from the Add-in, 'save as Python..' in a directory X") 19 | print(" 3) modify m_datapath in this file") 20 | print(" 3) modify ImportSolidWorksSystem(..) to match what you exported") 21 | print(" 4) move this .py file in directory X and execute it.") 22 | 23 | # Create Chrono physical system, non-smooth contact method 24 | my_system = chrono.ChSystemNSC() 25 | 26 | # Set collision detection engine 27 | my_system.SetCollisionSystemType(chrono.ChCollisionSystem.Type_BULLET) 28 | 29 | # Set the default outward/inward shape margins for collision detection, 30 | # this is epecially important for very large or very small objects. 31 | # This is a global setting to be put BEFORE creating objects/systems 32 | chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.005) 33 | chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.005) 34 | 35 | 36 | # Load the file generated by the SolidWorks CAD plugin and add it to the ChSystem. 37 | # NB: modify the argument of ImportSolidWorksSystem() to match what you exported. 38 | print ("Loading C::E scene...") 39 | 40 | exported_items = chrono.ImportSolidWorksSystem('./portal.py') 41 | 42 | print ("...loading done!") 43 | 44 | # Print exported items 45 | for my_item in exported_items: 46 | print (my_item.GetName()) 47 | 48 | # Add items to the physical system 49 | for my_item in exported_items: 50 | my_system.Add(my_item) 51 | 52 | 53 | # Create a contact material (surface property) to share between all objects. 54 | brick_material = chrono.ChContactMaterialNSC() 55 | brick_material.SetFriction(0.6) 56 | #brick_material.SetRestitution(0) 57 | #brick_material.SetDampingF(0.05) 58 | #brick_material.SetCompliance (0.000000003) 59 | #brick_material.SetComplianceT(0.000000001) 60 | 61 | for my_body in my_system.GetBodies(): 62 | if my_body.GetCollisionModel(): 63 | my_body.GetCollisionModel().SetAllShapesMaterial(brick_material) 64 | 65 | # Customize bodies color 66 | for my_body in my_system.GetBodies(): 67 | if my_body.GetVisualModel(): 68 | my_body.GetVisualShape(0).SetColor(chrono.ChColor(0.2, 0.2, 0.2)) 69 | 70 | 71 | # Create motion between table and ground: 72 | my_floor = my_system.SearchBody('floor^portal-1') 73 | if not my_floor: 74 | sys.exit('Error: cannot find floor from its name in the C::E system!') 75 | 76 | my_ground = my_system.SearchBody('SLDW_GROUND') 77 | if not my_ground: 78 | sys.exit('Error: cannot find ground from its name in the C::E system!') 79 | 80 | # Make the shaking motion 81 | my_floor.SetFixed(False) 82 | link_shaker = chrono.ChLinkLockLock() 83 | link_shaker.Initialize(my_floor, my_ground, chrono.ChFramed()) 84 | my_system.Add(link_shaker) 85 | 86 | my_functA = chrono.ChFunctionSine(1.4, 0.06, 0) 87 | my_functB = chrono.ChFunctionSine(0.1, 1, 0) 88 | my_funct = chrono.ChFunctionOperator() 89 | my_funct.SetFirstOperandFunction(my_functA) 90 | my_funct.SetSecondOperandFunction(my_functB) 91 | my_funct.SetOperationType(chrono.ChFunctionOperator.MUL) 92 | link_shaker.SetMotionX(my_funct) 93 | 94 | # Create the Irrlicht visualization 95 | vis = chronoirr.ChVisualSystemIrrlicht() 96 | vis.AttachSystem(my_system) 97 | vis.SetWindowSize(1024, 768) 98 | vis.SetWindowTitle('Test') 99 | vis.Initialize() 100 | vis.AddLogo(chrono.GetChronoDataPath() + 'logo_pychrono_alpha.png') 101 | vis.AddSkyBox() 102 | vis.AddCamera(chrono.ChVector3d(0, 1, 2)) 103 | vis.AddTypicalLights() 104 | 105 | vis.EnableCollisionShapeDrawing(True) 106 | 107 | timestep = 0.001 108 | 109 | # Simulation loop 110 | while vis.Run(): 111 | vis.BeginScene() 112 | vis.Render() 113 | vis.EndScene() 114 | my_system.DoStepDynamics(timestep) -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/collisions/portal.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/collisions/portal.SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/conveyor/assembly_conveyor.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/conveyor/assembly_conveyor.SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/conveyor/concrete.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/conveyor/concrete.jpeg -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/ConRod-Study 2.LOG: -------------------------------------------------------------------------------- 1 | No. of nodes = 35735 2 | No. of elements = 22241 3 | No. of DOF = 102885 4 | Total solution time = 00:00:03 5 | -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/ConRod.DSP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/ConRod.DSP -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/ConRod.GEN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/ConRod.GEN -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/ConRod.MAS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/ConRod.MAS -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/ConRod.sldprt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/ConRod.sldprt -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/Crankshaft.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/Crankshaft.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/Engine.sldasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/Engine.sldasm -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/Engine4c.sldasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/Engine4c.sldasm -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/Piston.sldprt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/Piston.sldprt -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/X.BAT: -------------------------------------------------------------------------------- 1 | C:\tasora\code\projectchrono\chrono-solidworks\to_put_in_SW_dir\chronoengine\examples\engine\ConRod-Study 2 2 | -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/demo_SW_engine.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # 3 | # This file shows how to simulate a four cylinder engine 4 | # 5 | # Author: Alessandro Tasora 6 | # 7 | # REMARK: this is part of Chrono::Solidworks add-in 8 | # - it assumes that you exported the .asm in this directory using the add-in 9 | # - PyChrono must be installed in your Python environment 10 | #------------------------------------------------------------------------------- 11 | 12 | 13 | import sys 14 | import pychrono as chrono 15 | import pychrono.irrlicht as chronoirr 16 | 17 | print("Demo program that shows how to use the SolidWorks add-in.") 18 | print(" 1) use the SolidWorks Add-in, load the .SLDASM,") 19 | print(" 2) from the Add-in, 'save as Python..' in a directory X") 20 | print(" 3) modify m_datapath in this file") 21 | print(" 3) modify ImportSolidWorksSystem(..) to match what you exported") 22 | print(" 4) move this .py file in directory X and execute it.") 23 | 24 | # Create Chrono physical system 25 | my_system = chrono.ChSystemNSC() 26 | my_system.SetGravitationalAcceleration(chrono.ChVector3d(0,-9.81,0)) 27 | 28 | # Load the file generated by the SolidWorks CAD plugin 29 | # and add it to the ChSystem. 30 | print ("Loading C::E scene...") 31 | 32 | exported_items = chrono.ImportSolidWorksSystem('./engine.py') 33 | 34 | print ("...loading done!") 35 | 36 | # Print exported items 37 | for my_item in exported_items: 38 | print (my_item.GetName()) 39 | 40 | # Add items to the physical system 41 | for my_item in exported_items: 42 | my_system.Add(my_item) 43 | 44 | 45 | # Optionally set some solver parameters. 46 | my_solver = chrono.ChSolverBB() 47 | my_solver.SetMaxIterations(600) 48 | my_system.SetSolver(my_solver) 49 | 50 | # Fetch a ChMarker from its name (it is a 'Coordinate system' in 51 | # the SolidWorks interface) 52 | 53 | my_marker = my_system.SearchMarker('Marker_shaft') 54 | if not my_marker : 55 | sys.exit('Error: cannot find marker from its name in the C::E system!') 56 | 57 | 58 | # Fetch two ChBodyAuxRef objects (the ground, the shaft) from 59 | # their names. Names are as they are named in SolidWorks - see also the dump of 60 | # my_system object with my_system.ShowHierarchy(chrono.GetLog()) if needed) 61 | # Note.. here we must upcast because Search() returns generic shared 62 | # pointer to a base class ChPhysicsItem, so we use CastToXXYYZZ() 63 | # my_shaft = chrono.CastToChBodyAuxRefShared(my_system.Search('Crankshaft-1')) 64 | # Or use the specialized SearchBody(). 65 | 66 | my_shaft = my_system.SearchBody('Crankshaft-1') 67 | if not my_shaft : 68 | sys.exit('Error: cannot find shaft from its name in the C::E system!') 69 | 70 | my_ground = my_system.SearchBody('SLDW_GROUND') 71 | if not my_ground : 72 | sys.exit('Error: cannot find ground from its name in the C::E system!') 73 | 74 | 75 | # Create an engine along the Z direction of the coordsystem specified by 76 | # the marker, and acting between shaft and ground 77 | revolute_frame = my_marker.GetAbsFrame() 78 | link_motor = chrono.ChLinkMotorRotationSpeed() 79 | link_motor.Initialize(my_shaft, my_ground, revolute_frame) 80 | link_motor.SetSpindleConstraint(chrono.ChLinkMotorRotationSpeed.SpindleConstraint_CYLINDRICAL)# Set_shaft_mode(chrono.ChLinkEngine.ENG_SHAFT_PRISM) 81 | link_motor.SetMotorFunction(chrono.ChFunctionConst(1.0*chrono.CH_2PI)) # 1.0 Hz to rad/s 82 | my_system.Add(link_motor) 83 | 84 | 85 | # Create the Irrlicht visualization 86 | vis = chronoirr.ChVisualSystemIrrlicht() 87 | vis.AttachSystem(my_system) 88 | vis.SetWindowSize(1024,768) 89 | vis.SetWindowTitle('Test') 90 | vis.Initialize() 91 | vis.AddLogo(chrono.GetChronoDataPath() + 'logo_pychrono_alpha.png') 92 | vis.AddSkyBox() 93 | vis.AddCamera(chrono.ChVector3d(0.5, 0.5, 0.5)) 94 | vis.AddTypicalLights() 95 | 96 | m_realtime_timer = chrono.ChRealtimeStepTimer() 97 | m_timestep = 0.01 98 | 99 | # Simulation loop 100 | while vis.Run(): 101 | vis.BeginScene() 102 | vis.Render() 103 | vis.EndScene() 104 | my_system.DoStepDynamics(m_timestep) 105 | m_realtime_timer.Spin(m_timestep) -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/engine/piston_rod.sldasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/engine/piston_rod.sldasm -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/ArmBase.sldprt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/ArmBase.sldprt -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300 .SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300 .SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-02.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-02.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-03.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-03.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-04.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-04.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-05.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-05.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-06.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-06.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-07.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-07.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-08.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-08.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-09.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-09.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-10.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-10.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-11.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-11.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-12.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-12.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/M-410iB-300-13.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/M-410iB-300-13.SLDPRT -------------------------------------------------------------------------------- /to_put_in_app_dir/examples/spider_robot/SPIDER_ROBOT.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/examples/spider_robot/SPIDER_ROBOT.SLDASM -------------------------------------------------------------------------------- /to_put_in_app_dir/icons/ChronoEngineAddIn_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/icons/ChronoEngineAddIn_128.png -------------------------------------------------------------------------------- /to_put_in_app_dir/icons/ChronoEngineAddIn_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/icons/ChronoEngineAddIn_20.png -------------------------------------------------------------------------------- /to_put_in_app_dir/icons/ChronoEngineAddIn_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/icons/ChronoEngineAddIn_32.png -------------------------------------------------------------------------------- /to_put_in_app_dir/icons/ChronoEngineAddIn_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/icons/ChronoEngineAddIn_40.png -------------------------------------------------------------------------------- /to_put_in_app_dir/icons/ChronoEngineAddIn_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/icons/ChronoEngineAddIn_64.png -------------------------------------------------------------------------------- /to_put_in_app_dir/icons/ChronoEngineAddIn_96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/projectchrono/chrono-solidworks/d6d9bc2208d25df84409053f6b5aba46202f063e/to_put_in_app_dir/icons/ChronoEngineAddIn_96.png -------------------------------------------------------------------------------- /to_put_in_app_dir/run_test.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Name: modulo1 3 | # Purpose: 4 | # 5 | # Author: tasora 6 | # 7 | # Created: 1/1/2019 8 | # Copyright: (c) tasora 2019 9 | # Licence: 10 | #------------------------------------------------------------------------------- 11 | #!/usr/bin/env python 12 | 13 | def main(): 14 | pass 15 | 16 | if __name__ == '__main__': 17 | main() 18 | 19 | 20 | import os 21 | import math 22 | import time 23 | import sys, getopt 24 | import pychrono as chrono 25 | import pychrono.postprocess as postprocess 26 | import pychrono.irrlicht as chronoirr 27 | 28 | 29 | # --------------------------------------------------------------------- 30 | # 31 | # Parse command-line parameters 32 | 33 | m_filename = "" 34 | m_timestep = 0.01 35 | m_length = 1.0 36 | m_visualization = "irrlicht" 37 | m_datapath = "" 38 | 39 | try: 40 | opts, args = getopt.getopt(sys.argv[1:],"f:d:T:v:p:",["filename=","timestep=","Tlength=","visualization=","datapath="]) 41 | except getopt.GetoptError: 42 | print ("run_test.py -f [-d -T -v -p ]") 43 | sys.exit(2) 44 | for opt, arg in opts: 45 | print ("opt:", opt, " arg", arg) 46 | if opt in ("-d", "--timestep"): 47 | m_timestep = float(arg) 48 | elif opt in ("-T", "--Tlength"): 49 | m_length = float(arg) 50 | elif opt in ("-f", "--filename"): 51 | m_filename = arg 52 | elif opt in ("-v", "--visualization"): 53 | m_visualization = arg 54 | elif opt in ("-p", "--datapath"): 55 | m_datapath = arg 56 | 57 | if m_filename == "": 58 | print ("run_test.py -f [-d -T -v -p ]") 59 | sys.exit(2) 60 | 61 | if not os.path.isfile(m_filename): 62 | print ("Error. Filename " + m_filename + " does not exist.") 63 | sys.exit(2) 64 | 65 | chrono.SetChronoDataPath(m_datapath) 66 | 67 | print (" file to load is ", m_filename) 68 | print (" timestep is ", m_timestep) 69 | print (" length is ", m_length) 70 | print (" data path for fonts etc.: ", m_datapath) 71 | 72 | 73 | 74 | # --------------------------------------------------------------------- 75 | # 76 | # load the file generated by the SolidWorks CAD plugin 77 | # and add it to the ChSystem. 78 | # 79 | 80 | m_absfilename = os.path.abspath(m_filename) 81 | 82 | print ("Loading C::E scene..."); 83 | 84 | exported_items = chrono.ImportSolidWorksSystem(m_absfilename) 85 | 86 | print ("...loading done!"); 87 | 88 | 89 | # Print exported items 90 | for my_item in exported_items: 91 | print (my_item.GetName()) 92 | 93 | # Add items to the physical system 94 | my_system = chrono.ChSystemNSC() 95 | for my_item in exported_items: 96 | my_system.Add(my_item) 97 | 98 | 99 | # Optionally set some solver parameters. 100 | 101 | #my_system.SetMaxPenetrationRecoverySpeed(1.00) 102 | my_solver = chrono.ChSolverBB() 103 | my_system.SetSolver(my_solver) 104 | my_solver.SetMaxIterations(600) 105 | my_solver.EnableWarmStart(True); 106 | my_system.Set_G_acc(chrono.ChVectorD(0,-9.8,0)) 107 | 108 | 109 | 110 | if m_visualization == "PovRay": 111 | 112 | # --------------------------------------------------------------------- 113 | # 114 | # Render a short animation by generating scripts 115 | # to be used with POV-Ray 116 | # 117 | 118 | pov_exporter = postprocess.ChPovRay(my_system) 119 | 120 | # Sets some file names for in-out processes. 121 | pov_exporter.SetTemplateFile ("_template_POV.pov") 122 | 123 | # Set the path where it will save all .pov, .ini, .asset and .dat files, 124 | # this directory will be created if not existing. For example: 125 | pov_exporter.SetBasePath("povray_pychrono_generated") 126 | 127 | # Sets the viewpoint, aimed point, lens angle 128 | pov_exporter.SetCamera(chrono.ChVectorD(0.2,0.3,0.5), chrono.ChVectorD(0,0,0), 35) 129 | 130 | # Sets the default ambient light and default light lamp 131 | pov_exporter.SetAmbientLight(chrono.ChColor(1,1,1)) 132 | pov_exporter.SetLight(chrono.ChVectorD(-2,2,-1), chrono.ChColor(1.1,1.2,1.2), True) 133 | 134 | # Sets other settings 135 | pov_exporter.SetPictureSize(640,480) 136 | pov_exporter.SetAmbientLight(chrono.ChColor(2,2,2)) 137 | 138 | # Turn on the rendering of xyz axes for the centers of gravity or reference frames: 139 | #pov_exporter.SetShowCOGs (1, 0.05) 140 | #pov_exporter.SetShowFrames(1, 0.02) 141 | #pov_exporter.SetShowLinks(1, 0.03) 142 | pov_exporter.SetShowContacts(True, 143 | postprocess.ChPovRay.ContactSymbol_VECTOR_SCALELENGTH, 144 | 0.2, # scale 145 | 0.0007, # width 146 | 0.1, # max size 147 | True,0,0.5 ) # colormap on, blue at 0, red at 0.5 148 | 149 | # Add additional POV objects/lights/materials in the following way, entering 150 | # an optional text using the POV scene description laguage. This will be 151 | # appended to the generated .pov file. 152 | # For multi-line strings, use the python ''' easy string delimiter. 153 | pov_exporter.SetCustomPOVcommandsScript( 154 | ''' 155 | light_source{ <1,3,1.5> color rgb<1.1,1.1,1.1> } 156 | ''') 157 | 158 | # Tell which physical items you want to render 159 | pov_exporter.AddAll() 160 | 161 | 162 | # Create the two .pov and .ini files for POV-Ray (this must be done 163 | # only once at the beginning of the simulation). 164 | pov_exporter.ExportScript() 165 | 166 | 167 | # Perform a short simulation 168 | nstep =0 169 | while (my_system.GetChTime() < m_length) : 170 | 171 | my_system.DoStepDynamics(m_timestep) 172 | 173 | #if math.fmod(nstep,10) ==0 : 174 | print ('time=', my_system.GetChTime() ) 175 | 176 | # Create the incremental nnnn.dat and nnnn.pov files that will be load 177 | # by the pov .ini script in POV-Ray (do this at each simulation timestep) 178 | pov_exporter.ExportData() 179 | 180 | nstep = nstep +1 181 | 182 | print ("\n\nOk, Simulation done!"); 183 | time.sleep(2) 184 | 185 | 186 | 187 | if m_visualization == "Irrlicht": 188 | 189 | # --------------------------------------------------------------------- 190 | # 191 | # Create an Irrlicht application to visualize the system 192 | # 193 | 194 | # Create the Irrlicht visualization 195 | vis = chronoirr.ChVisualSystemIrrlicht() 196 | vis.AttachSystem(my_system) 197 | vis.SetWindowSize(1024,768) 198 | vis.SetWindowTitle('Test') 199 | vis.Initialize() 200 | vis.AddLogo(chrono.GetChronoDataPath() + 'logo_pychrono_alpha.png') 201 | vis.AddSkyBox() 202 | vis.AddCamera(chrono.ChVectorD(1, 1, 1)) 203 | vis.AddTypicalLights() 204 | 205 | # ==IMPORTANT!== Use this function for adding a ChIrrNodeAsset to all items 206 | # in the system. These ChIrrNodeAsset assets are 'proxies' to the Irrlicht meshes. 207 | # If you need a finer control on which item really needs a visualization proxy in 208 | # Irrlicht, just use application.AssetBind(myitem); on a per-item basis. 209 | #vis.BindAll() 210 | 211 | # ==IMPORTANT!== Use this function for 'converting' into Irrlicht meshes the assets 212 | # that you added to the bodies into 3D shapes, they can be visualized by Irrlicht! 213 | #vis.UpdateAll() 214 | 215 | # Simulation loop 216 | while vis.Run(): 217 | vis.BeginScene() 218 | vis.Render() 219 | vis.EndScene() 220 | my_system.DoStepDynamics(m_timestep) 221 | 222 | --------------------------------------------------------------------------------