Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test branch #89

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added mesh4.3dm
Binary file not shown.
Binary file added meshtest.3dm
Binary file not shown.
1,094 changes: 868 additions & 226 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"compute-rhino3d": "^0.12.0",
"cors": "2.8.5",
"debug": "~2.6.9",
"express": "~4.16.1",
"express": "^4.18.2",
"hbs": "^4.2.0",
"http-errors": "~1.6.3",
"md5-file": "5.0.0",
Expand Down
68 changes: 68 additions & 0 deletions src/examples/1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="apple-touch-icon" sizes="180x180" href="../favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../favicon/favicon-16x16.png">
<link rel="manifest" href="../favicon/site.webmanifest">
<title>Boolean test</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100%; }
input {width: 90%;}
#container {position: relative;}
#container canvas, #overlay { position: absolute;}
#overlay {z-index: 1; width: 100%}

#loader {
border: 5px solid #92c1ff; /* Light grey */
border-top: 5px solid #100827; /* Grey */
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
position: absolute;
top: 50%;
left: 50%;
z-index: 2;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div id="loader"></div>
<div id="container">
<div id="overlay">
<div>
<input type="range" id="RH_IN:size" name="RH_IN:size" min="0" max="100" value="100" step="10">
<label for="RH_IN:size">RH_IN:size</label>
</div>
<div>
<input type="checkbox" id="RH_IN:bool" name="RH_IN:bool">
<label for="RH_IN:bool">RH_IN:bool</label>
</div>
<p>Example by Marek</p>
</div>
</div>

<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.140.2/build/three.module.js",
"three/examples/jsm/controls/OrbitControls": "https://unpkg.com/three@0.140.2/examples/jsm/controls/OrbitControls.js",
"three/examples/jsm/loaders/3DMLoader": "https://unpkg.com/three@0.140.2/examples/jsm/loaders/3DMLoader.js"
}
}
</script>

<script type="module" src="./script.js"></script>
</body>
</html>
112 changes: 112 additions & 0 deletions src/examples/1/init.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<html>
<head>
<meta charset="utf-8">
<link rel="apple-touch-icon" sizes="180x180" href="favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
<link rel="manifest" href="favicon/site.webmanifest">
<title>Compute RestHopper Test</title>
</head>
<body>
<button id="solveButton" name="button" onclick="run()">Initialize Cache</button>
<div id="log" style="font-family: sans-serif;"></div>
<script>

let logDiv = document.getElementById('log')
let total = 0
let params = {}

init()

function init() {

// set this to the target appserver url
let url = window.location.href
url = url.substring(0, url.lastIndexOf('/'))
url = url.substring(0, url.lastIndexOf('/')) + '/solve'

params.definition = 'bool_test2.gh'
params.url = url

// The min, max, and step values below should match the values used for the input sliders in index.html

//count
params.count = {}
params.count.min = 0
params.count.max = 100
params.count.step = 10
params.count.cnt = ( params.count.max - params.count.min ) / params.count.step

//radius
params.radius = {}
params.radius.min = 1
params.radius.max = 10
params.radius.step = 1
params.radius.cnt = ( params.radius.max - params.radius.min ) / params.radius.step

//length
params.length = {}
params.length.min = 1
params.length.max = 10
params.length.step = 1
params.length.cnt = ( params.length.max - params.length.min ) / params.length.step

total = ( ( params.count.cnt + 1 ) * ( params.radius.cnt + 1 ) * ( params.length.cnt + 1 ) )

logDiv.textContent = 'Solutions to solve: ' + total

}

function run() {

document.getElementById('solveButton').disabled = true

warmUp().then( ()=>{
console.log('done')
logDiv.textContent = 'done'
} )
}

async function warmUp() {

let cnt = 1

for (let i = params.count.min; i <= params.count.max; i = i + params.count.step) {

for (let j = params.radius.min; j <= params.radius.max; j = j + params.radius.step) {

for (let k = params.length.min; k <= params.length.max; k = k + params.length.step) {

console.log(`Solution: ${cnt} / ${total}`)
logDiv.textContent = `Solution: ${cnt} / ${total}`
console.log(`Params: Count ${i} - Radius ${j} - Length ${k}`)

let data = {}
data.definition = params.definition
data.inputs = {
'Count': i,
'Radius': j,
'Length': k
}

const request = {
'method':'POST',
'body': JSON.stringify(data),
'headers': {'Content-Type': 'application/json'}
}

let response = await fetch(params.url, request)
let responseJson = await response.json()

cnt ++

}

}

}

}
</script>
</body>
</html>
Loading