├── .gitignore
├── arcsim
├── .gitignore
├── AdaptiveCloth.sln
├── AdaptiveCloth
│ ├── AdaptiveCloth.vcxproj
│ ├── AdaptiveCloth.vcxproj.filters
│ ├── AdaptiveCloth.vcxproj.user
│ ├── Application.cpp
│ ├── Application.h
│ ├── Main.cpp
│ ├── auglag.cpp
│ ├── auglag.hpp
│ ├── bah.cpp
│ ├── bah.hpp
│ ├── blockvectors.hpp
│ ├── bvh.cpp
│ ├── bvh.hpp
│ ├── cloth.cpp
│ ├── cloth.hpp
│ ├── collision.cpp
│ ├── collision.hpp
│ ├── collisionutil.cpp
│ ├── collisionutil.hpp
│ ├── conf.cpp
│ ├── conf.hpp
│ ├── constraint.cpp
│ ├── constraint.hpp
│ ├── dde.cpp
│ ├── dde.hpp
│ ├── display.cpp
│ ├── display.hpp
│ ├── displayphysics.cpp
│ ├── displayphysics.hpp
│ ├── displayreplay.cpp
│ ├── displayreplay.hpp
│ ├── displaytesting.cpp
│ ├── displaytesting.hpp
│ ├── dynamicremesh.cpp
│ ├── dynamicremesh.hpp
│ ├── geometry.cpp
│ ├── geometry.hpp
│ ├── handle.cpp
│ ├── handle.hpp
│ ├── io.cpp
│ ├── io.hpp
│ ├── lbfgs.cpp
│ ├── lsnewton.cpp
│ ├── magic.cpp
│ ├── magic.hpp
│ ├── mesh.cpp
│ ├── mesh.hpp
│ ├── misc.cpp
│ ├── misc.hpp
│ ├── morph.cpp
│ ├── morph.hpp
│ ├── mot_parser.cpp
│ ├── mot_parser.hpp
│ ├── nearobs.cpp
│ ├── nearobs.hpp
│ ├── nlcg.cpp
│ ├── obstacle.cpp
│ ├── obstacle.hpp
│ ├── opengl.hpp
│ ├── optimization.hpp
│ ├── physics.cpp
│ ├── physics.hpp
│ ├── plasticity.cpp
│ ├── plasticity.hpp
│ ├── popfilter.cpp
│ ├── popfilter.hpp
│ ├── proximity.cpp
│ ├── proximity.hpp
│ ├── remesh.cpp
│ ├── remesh.hpp
│ ├── runphysics.cpp
│ ├── runphysics.hpp
│ ├── separate.cpp
│ ├── separate.hpp
│ ├── separateobs.cpp
│ ├── separateobs.hpp
│ ├── simulation.cpp
│ ├── simulation.hpp
│ ├── sparse.hpp
│ ├── spline.cpp
│ ├── spline.hpp
│ ├── strainlimiting.cpp
│ ├── strainlimiting.hpp
│ ├── taucs.cpp
│ ├── taucs.hpp
│ ├── tensormax.cpp
│ ├── tensormax.hpp
│ ├── timer.cpp
│ ├── timer.hpp
│ ├── transformation.cpp
│ ├── transformation.hpp
│ ├── trustregion.cpp
│ ├── util.cpp
│ ├── util.hpp
│ ├── vectors.cpp
│ ├── vectors.hpp
│ └── winport.hpp
├── Configurations
│ ├── crumple-pnas.json
│ ├── crumple.json
│ ├── crush.json
│ ├── crush2.json
│ ├── cylinder.json
│ ├── dart.json
│ ├── dress-blue.json
│ ├── dress-yellow.json
│ ├── flag.json
│ ├── fold.json
│ ├── karate.json
│ ├── pcb.json
│ ├── pcb_flag.json
│ ├── sleeve.json
│ ├── sphere-annotated.json
│ ├── sphere.json
│ ├── square-pop.json
│ ├── square.json
│ └── tshirt.json
├── Materials
│ ├── 11oz-black-denim.json
│ ├── PcbBending.json
│ ├── aluminium.json
│ ├── camel-ponte-roma.json
│ ├── gray-interlock.json
│ ├── ivory-rib-knit.json
│ ├── navy-sparkle-sweat.json
│ ├── paper.json
│ ├── pink-ribbon-brown.json
│ ├── royal-target.json
│ ├── tango-red-jet-set.json
│ ├── white-dots-on-blk.json
│ └── white-swim-solid.json
└── Meshes
│ ├── dance-paused.mot
│ ├── dance.mot
│ ├── dress.ma
│ ├── dress.poly
│ ├── dress2.ma
│ ├── dress3.ma
│ ├── dressp.svg
│ ├── female-objs
│ └── shrink.hs
│ ├── karate-smooth.mot
│ ├── karate.ma
│ ├── karate.mot
│ ├── locking-clinder.mtl
│ ├── locking-square.mtl
│ ├── locking-square.obj.mtl
│ ├── nodefiles
│ ├── flag.node
│ ├── mktablecloth.py
│ ├── square.1.ele
│ ├── square.1.node
│ └── square.node
│ ├── pants.mtl
│ ├── scripts
│ ├── Obj.hs
│ ├── count.hs
│ ├── cylinder.hs
│ ├── ffwd.sh
│ ├── flip.hs
│ ├── fold.hs
│ ├── pause.hs
│ ├── plastic.hs
│ ├── rotate.hs
│ ├── shrink.hs
│ ├── svg2poly.hs
│ └── translate.hs
│ ├── shrinkobj.py
│ └── sphere.mot
├── bending_validation
├── AssembleMatrix.m
├── BendingCurve.m
├── BuildTopo.m
├── CreateCloth.m
├── DihedralBendingHessianForce.m
├── GenerateModulusForSampling.m
├── GetHW.m
├── LICENSE
├── LoadMasterCurve.m
├── Main.m
├── PlotMasterCurve.m
├── README.md
├── ReadObj.m
├── SetFixed.m
├── SpringHessianForce.m
├── UpdateXV.m
├── master_curve.png
├── master_curve_data.mat
└── ribbon.obj
├── dataset
└── dataset.csv
├── evaluation
├── backbones
│ ├── alexnet.py
│ ├── base.py
│ ├── effnet.py
│ ├── effnet_util.py
│ ├── resnet.py
│ └── vgg16.py
├── depth_data
│ ├── mesh0
│ │ ├── 0.png
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ └── density.txt
│ ├── mesh1
│ │ ├── 0.png
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ └── density.txt
│ ├── mesh2
│ │ ├── 0.png
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ └── density.txt
│ └── mesh3
│ │ ├── 0.png
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ └── density.txt
├── evaluation.py
├── network.pth
├── proputil.py
└── resnet.py
├── readme.md
└── subspace
├── dataloader.py
├── init_dataset.py
├── sampling.py
├── test.txt
├── train.txt
├── vae.py
└── vae_subspace.pkl
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | .vs/
3 | Third-Party
4 | Output/
--------------------------------------------------------------------------------
/arcsim/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.572
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AdaptiveCloth", "AdaptiveCloth\AdaptiveCloth.vcxproj", "{66DC224B-8EB7-40F0-B026-E2A0B2CF554B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Release|x64 = Release|x64
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {66DC224B-8EB7-40F0-B026-E2A0B2CF554B}.Debug|x64.ActiveCfg = Debug|x64
15 | {66DC224B-8EB7-40F0-B026-E2A0B2CF554B}.Debug|x64.Build.0 = Debug|x64
16 | {66DC224B-8EB7-40F0-B026-E2A0B2CF554B}.Release|x64.ActiveCfg = Release|x64
17 | {66DC224B-8EB7-40F0-B026-E2A0B2CF554B}.Release|x64.Build.0 = Release|x64
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {D378786E-332C-4407-ABD6-DB4C024F6F14}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/AdaptiveCloth.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(SolutionDir)
5 | WindowsLocalDebugger
6 |
7 |
8 | $(SolutionDir)
9 | WindowsLocalDebugger
10 |
11 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/Application.cpp:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *************************** Application ****************************
3 | *************************************************************************/
4 |
5 | #include
6 | #include
7 | #include "Application.h"
8 |
9 | #include "display.hpp"
10 | #include "runphysics.hpp"
11 | #include "displayphysics.hpp"
12 |
13 | using namespace ArcSim;
14 | using namespace std::chrono_literals;
15 |
16 | /*************************************************************************
17 | *************************** Application ****************************
18 | *************************************************************************/
19 | Application::Application() : m_IsRunning(false)
20 | {
21 |
22 | }
23 |
24 | static bool s_IsRunning = false;
25 |
26 | void idle()
27 | {
28 |
29 | if (!s_IsRunning)
30 | return;
31 |
32 | sim_step();
33 | redisplay();
34 | }
35 |
36 | extern void zoom(bool in);
37 |
38 | static void keyboard(unsigned char key, int x, int y)
39 | {
40 | unsigned char esc = 27, space = ' ';
41 | if (key == esc)
42 | {
43 | exit(EXIT_SUCCESS);
44 | }
45 | else if (key == space)
46 | {
47 | ::s_IsRunning = !::s_IsRunning;
48 | }
49 | else if (key == 's')
50 | {
51 | ::s_IsRunning = !::s_IsRunning;
52 | idle();
53 | ::s_IsRunning = !::s_IsRunning;
54 | }
55 | else if (key == 'z')
56 | {
57 | zoom(true);
58 | }
59 | else if (key == 'x')
60 | {
61 | zoom(false);
62 | }
63 | }
64 |
65 |
66 | void Application::RunSimulate(std::string jsonPath, std::string savingPath)
67 | {
68 | init_physics(jsonPath, savingPath, false);
69 |
70 | GlutCallbacks cb;
71 | cb.idle = idle;
72 | cb.keyboard = keyboard;
73 |
74 | run_glut(cb);
75 | }
76 |
77 |
78 | Application::~Application()
79 | {
80 |
81 | }
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/Application.h:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *************************** Application ****************************
3 | *************************************************************************/
4 | #pragma once
5 |
6 | #include
7 |
8 | namespace ArcSim
9 | {
10 | /*********************************************************************
11 | ************************* Application **************************
12 | *********************************************************************/
13 |
14 | class Application
15 | {
16 |
17 | public:
18 |
19 | Application();
20 | ~Application();
21 |
22 | public:
23 |
24 | void RunSimulate(std::string jsonPath, std::string savingPath = "");
25 |
26 | private:
27 |
28 |
29 |
30 | private:
31 |
32 | bool m_IsRunning;
33 | };
34 | }
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/Main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #include "io.hpp"
28 | #include "misc.hpp"
29 | #include "display.hpp"
30 | #include "runphysics.hpp"
31 | #include "displayreplay.hpp"
32 | #include "displayphysics.hpp"
33 | #include "displaytesting.hpp"
34 | #include
35 |
36 | #include "Application.h"
37 |
38 | using namespace std;
39 |
40 | extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }
41 |
42 | // implement this anywhere in any .cpp file
43 | extern void debug(const vector &args);
44 |
45 | int main(int argc, char **argv)
46 | {
47 | struct Action
48 | {
49 | string name;
50 | void(*run) (const vector &args);
51 | } actions[] = {
52 | {"simulate", display_physics},
53 | {"simulateoffline", run_physics},
54 | {"resume", display_resume},
55 | {"resumeoffline", resume_physics},
56 | {"replay", display_replay},
57 | {"merge", merge_meshes},
58 | {"split", split_meshes},
59 | {"test", display_testing},
60 | {"tri2obj", tri2obj},
61 | {"debug", debug}
62 | };
63 | int nactions = sizeof(actions) / sizeof(Action);
64 | string name = (argc <= 1) ? "" : argv[1];
65 | vector args;
66 | for (int a = 2; a < argc; a++)
67 | args.push_back(argv[a]);
68 | for (int i = 0; i < nactions; i++)
69 | {
70 | if (name == actions[i].name)
71 | {
72 | actions[i].run(args);
73 | exit(EXIT_SUCCESS);
74 | }
75 | }
76 |
77 | cout << "Usage: " << endl;
78 | cout << " " << argv[0] << " []" << endl;
79 | cout << "where is one of" << endl;
80 | for (int i = 0; i < nactions; i++)
81 | cout << " " << actions[i].name << endl;
82 | cout << endl;
83 | cout << "Run '" << argv[0] << " ' without extra arguments ";
84 | cout << "to get more information about a particular command." << endl;
85 |
86 | /////////////////////////////////////////////////////////
87 |
88 | ArcSim::Application App;
89 |
90 | App.RunSimulate("Configurations\\pcb.json");
91 | // App.RunSimulate("Configurations\\flag.json");
92 | // App.RunSimulate("Configurations\\dress-blue.json");
93 | // App.RunSimulate("Configurations\\dress-yellow.json");
94 |
95 | exit(EXIT_SUCCESS);
96 | }
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/auglag.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #ifndef AUGLAG_HPP
28 | #define AUGLAG_HPP
29 |
30 | #include "sparse.hpp"
31 | #include "vectors.hpp"
32 |
33 | struct NLOpt
34 | { // nonlinear optimization problem
35 | // minimize objective s.t. constraints = or <= 0
36 | int nvar, ncon;
37 | virtual void initialize(double *x) const = 0;
38 | virtual void precompute(const double *x) const {}
39 | virtual double objective(const double *x) const = 0;
40 | virtual void obj_grad(const double *x, double *grad) const = 0; // set
41 | virtual double constraint(const double *x, int j, int &sign) const = 0;
42 | virtual void con_grad(const double *x, int j, double factor,
43 | double *grad) const = 0; // add factor*gradient
44 | virtual void finalize(const double *x) const = 0;
45 | };
46 |
47 | void augmented_lagrangian_method(const NLOpt &problem, bool verbose = false);
48 |
49 | // convenience functions for when optimization variables are Vec3-valued
50 |
51 | inline Vec3 get_subvec(const double *x, int i)
52 | {
53 | return Vec3(x[i * 3 + 0], x[i * 3 + 1], x[i * 3 + 2]);
54 | }
55 | inline void set_subvec(double *x, int i, const Vec3 &xi)
56 | {
57 | for (int j = 0; j < 3; j++) x[i * 3 + j] = xi[j];
58 | }
59 | inline void add_subvec(double *x, int i, const Vec3 &xi)
60 | {
61 | for (int j = 0; j < 3; j++) x[i * 3 + j] += xi[j];
62 | }
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/bah.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #ifndef BAH_HPP
28 | #define BAH_HPP
29 |
30 | // Bounding area hierarchy for triangles in 2D
31 | // based on bvh.hpp
32 |
33 | #include "mesh.hpp"
34 | #include "util.hpp"
35 |
36 | struct Box
37 | {
38 | Vec2 umin, umax;
39 | Box() : umin(Vec2(infinity)), umax(Vec2(-infinity)) {}
40 | Box(const Vec2 &u) : umin(u), umax(u) {}
41 | Box &operator+= (const Vec2 &u);
42 | Box &operator+= (const Box &box);
43 | bool overlaps(const Box &box) const;
44 | Vec2 size() const;
45 | Vec2 center() const;
46 | };
47 |
48 | struct BahNode
49 | {
50 | Box box;
51 | Face *face;
52 | BahNode *parent;
53 | BahNode *left;
54 | BahNode *right;
55 | BahNode();
56 | BahNode(BahNode*, Face*, const Box&);
57 | BahNode(BahNode*, Face**, unsigned int, Box*, Vec2*);
58 | ~BahNode();
59 | };
60 |
61 | BahNode *new_bah_tree(const Mesh &mesh);
62 | void delete_bah_tree(BahNode *root);
63 |
64 | typedef void(*BahCallback) (Face *face0, const Face *face1);
65 | void for_overlapping_faces(Face *face, const BahNode *node,
66 | BahCallback callback);
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/blockvectors.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #ifndef BLOCKVECTORS_HPP
28 | #define BLOCKVECTORS_HPP
29 |
30 | #include "vectors.hpp"
31 |
32 | template
33 | Vec mat_to_vec(const Mat &A)
34 | {
35 | Vec a;
36 | for (int i = 0; i < m; i++)
37 | for (int j = 0; j < n; j++)
38 | a[i + j * m] = A(i, j);
39 | return a;
40 | }
41 |
42 | template
43 | Mat vec_to_mat(const Vec &a)
44 | {
45 | Mat A;
46 | for (int i = 0; i < m; i++)
47 | for (int j = 0; j < n; j++)
48 | A(i, j) = a[i + j * m];
49 | return A;
50 | }
51 |
52 | template Mat blockdiag(const Mat &A)
53 | {
54 | Mat B = 0;
55 | for (int b = 0; b < bn; b++)
56 | for (int i = 0; i < m; i++)
57 | for (int j = 0; j < n; j++)
58 | B(b*m + i, b*n + j) = A(i, j);
59 | return B;
60 | }
61 |
62 | template Mat transpose()
63 | {
64 | Mat T = 0;
65 | for (int i = 0; i < m; i++)
66 | for (int j = 0; j < n; j++)
67 | T(n*i + j, i + j * m) = 1;
68 | return T;
69 | }
70 |
71 | template Mat symmetrize();
72 |
73 | template <> inline Mat<3, 4> symmetrize<2>()
74 | {
75 | Mat<3, 4> S = Mat<3, 4>(0);
76 | S(0, 0) = 1.f;
77 | S(1, 3) = 1.f;
78 | S(2, 1) = S(2, 2) = 1 / 2.f;
79 | return S;
80 | }
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/cloth.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #include "cloth.hpp"
28 |
29 | void compute_masses(Cloth & cloth)
30 | {
31 | for (int v = 0; v < cloth.mesh.verts.size(); v++)
32 | cloth.mesh.verts[v]->mass = 0.0f;
33 |
34 | for (int n = 0; n < cloth.mesh.nodes.size(); n++)
35 | cloth.mesh.nodes[n]->mass = 0.0f;
36 |
37 | for (int f = 0; f < cloth.mesh.faces.size(); f++)
38 | {
39 | Face * pFace = cloth.mesh.faces[f];
40 |
41 | pFace->mass = pFace->restArea * cloth.materials[pFace->label]->density;
42 |
43 | for (int v = 0; v < 3; v++)
44 | {
45 | pFace->v[v]->mass += pFace->mass / 3.0f;
46 |
47 | pFace->v[v]->node->mass += pFace->mass / 3.0f;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/cloth.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #pragma once
28 |
29 | #include "dde.hpp"
30 | #include "mesh.hpp"
31 |
32 | struct Cloth
33 | {
34 | Mesh mesh;
35 |
36 | struct Material
37 | {
38 | double density; // area density
39 | StretchingSamples stretching;
40 | BendingData bending;
41 | PrincipalCurvatureBasedBendingData pcb_bending;
42 | double damping; // stiffness-proportional damping coefficient
43 | double strain_min, strain_max; // strain limits
44 | double yield_curv, weakening; // plasticity parameters
45 | };
46 |
47 | std::vector materials;
48 |
49 | struct Remeshing
50 | {
51 | double refine_angle, refine_compression, refine_velocity;
52 | double size_min, size_max; // size limits
53 | double aspect_min; // aspect ratio control
54 | } remeshing;
55 | };
56 |
57 | void compute_masses(Cloth &cloth);
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/collision.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 |
31 | struct Mesh;
32 | struct Constraint;
33 |
34 | void collision_response (std::vector & meshes,
35 | const std::vector & cons,
36 | const std::vector & obs_meshes);
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/collisionutil.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #ifndef COLLISIONUTIL_HPP
28 | #define COLLISIONUTIL_HPP
29 |
30 | #include "bvh.hpp"
31 |
32 | typedef DeformBVHNode BVHNode;
33 | typedef DeformBVHTree BVHTree;
34 |
35 | struct AccelStruct
36 | {
37 | BVHTree tree;
38 | BVHNode *root;
39 | std::vector leaves;
40 | AccelStruct(const Mesh &mesh, bool ccd);
41 | };
42 |
43 | void update_accel_struct(AccelStruct &acc);
44 |
45 | void mark_all_inactive(AccelStruct &acc);
46 | void mark_active(AccelStruct &acc, const Face *face);
47 |
48 | // callback must be safe to parallelize via OpenMP
49 | typedef void(*BVHCallback) (const Face *face0, const Face *face1);
50 |
51 | void for_overlapping_faces(BVHNode *node, float thickness,
52 | BVHCallback callback);
53 | void for_overlapping_faces(BVHNode *node0, BVHNode *node1, float thickness,
54 | BVHCallback callback);
55 | void for_overlapping_faces(const std::vector &accs,
56 | const std::vector &obs_accs,
57 | double thickness, BVHCallback callback,
58 | bool parallel = true);
59 | void for_faces_overlapping_obstacles(const std::vector &accs,
60 | const std::vector &obs_accs,
61 | double thickness, BVHCallback callback,
62 | bool parallel = true);
63 |
64 | std::vector create_accel_structs
65 | (const std::vector &meshes, bool ccd);
66 | void destroy_accel_structs(std::vector &accs);
67 |
68 | // find index of mesh containing specified element
69 | template
70 | int find_mesh(const Prim *p, const std::vector &meshes);
71 |
72 | extern const std::vector *meshes; // to check if element is cloth or obs
73 | extern const std::vector *obs_meshes;
74 | template bool is_free(const Primitive *p)
75 | {
76 | return find_mesh(p, *::meshes) != -1;
77 | }
78 |
79 | #endif
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/conf.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #ifndef CONF_HPP
28 | #define CONF_HPP
29 |
30 | #include "simulation.hpp"
31 |
32 | void load_json(const std::string &filename, Simulation &sim);
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/arcsim/AdaptiveCloth/constraint.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright ©2013 The Regents of the University of California
3 | (Regents). All Rights Reserved. Permission to use, copy, modify, and
4 | distribute this software and its documentation for educational,
5 | research, and not-for-profit purposes, without fee and without a
6 | signed licensing agreement, is hereby granted, provided that the
7 | above copyright notice, this paragraph and the following two
8 | paragraphs appear in all copies, modifications, and
9 | distributions. Contact The Office of Technology Licensing, UC
10 | Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620,
11 | (510) 643-7201, for commercial licensing opportunities.
12 |
13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
14 | INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
15 | LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
16 | DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY
17 | OF SUCH DAMAGE.
18 |
19 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING
22 | DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS
23 | IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
24 | UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 | */
26 |
27 | #ifndef CONSTRAINT_HPP
28 | #define CONSTRAINT_HPP
29 |
30 | #include