diff --git a/dist/CDemo.js b/dist/CDemo.js deleted file mode 100644 index e99c7b3..0000000 --- a/dist/CDemo.js +++ /dev/null @@ -1 +0,0 @@ -var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=function shell_read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){return read(f)}}readBinary=function readBinary(f){var data;if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!=="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function allocateUTF8OnStack(str){var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8Array(str,HEAP8,ret,size);return ret}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||134217728;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(what);throw e}function hasPrefix(str,prefix){return String.prototype.startsWith?str.startsWith(prefix):str.indexOf(prefix)===0}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return hasPrefix(filename,dataURIPrefix)}var fileURIPrefix="file://";function isFileURI(filename){return hasPrefix(filename,fileURIPrefix)}var wasmBinaryFile="CDemo.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch==="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["j"];updateGlobalBufferAndViews(wasmMemory.buffer);wasmTable=Module["asm"]["p"];removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&typeof fetch==="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){wasmTable.get(func)()}else{wasmTable.get(func)(callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var ExceptionInfoAttrs={DESTRUCTOR_OFFSET:0,REFCOUNT_OFFSET:4,TYPE_OFFSET:8,CAUGHT_OFFSET:12,RETHROWN_OFFSET:13,SIZE:16};function ___cxa_allocate_exception(size){return _malloc(size+ExceptionInfoAttrs.SIZE)+ExceptionInfoAttrs.SIZE}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-ExceptionInfoAttrs.SIZE;this.set_type=function(type){HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]=type};this.get_type=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.TYPE_OFFSET>>2]};this.set_destructor=function(destructor){HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]=destructor};this.get_destructor=function(){return HEAP32[this.ptr+ExceptionInfoAttrs.DESTRUCTOR_OFFSET>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.CAUGHT_OFFSET>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+ExceptionInfoAttrs.RETHROWN_OFFSET>>0]!=0};this.init=function(type,destructor){this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2];HEAP32[this.ptr+ExceptionInfoAttrs.REFCOUNT_OFFSET>>2]=prev-1;return prev===1}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}function _abort(){abort()}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function abortOnCannotGrowMemory(requestedSize){abort("OOM")}function _emscripten_resize_heap(requestedSize){abortOnCannotGrowMemory(requestedSize)}function _exit(status){exit(status)}var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream,curr){var buffer=SYSCALLS.buffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},get64:function(low,high){return low}};function _fd_close(fd){return 0}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=num;return 0}var asmLibraryArg={"h":___cxa_allocate_exception,"g":___cxa_throw,"b":_abort,"d":_emscripten_memcpy_big,"e":_emscripten_resize_heap,"i":_exit,"f":_fd_close,"c":_fd_seek,"a":_fd_write};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["k"]).apply(null,arguments)};var _Example2d=Module["_Example2d"]=function(){return(_Example2d=Module["_Example2d"]=Module["asm"]["l"]).apply(null,arguments)};var _solost=Module["_solost"]=function(){return(_solost=Module["_solost"]=Module["asm"]["m"]).apply(null,arguments)};var _main=Module["_main"]=function(){return(_main=Module["_main"]=Module["asm"]["n"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["o"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["q"]).apply(null,arguments)};var calledRun;function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}var calledMain=false;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function callMain(args){var entryFunction=Module["_main"];args=args||[];var argc=args.length+1;var argv=stackAlloc((argc+1)*4);HEAP32[argv>>2]=allocateUTF8OnStack(thisProgram);for(var i=1;i>2)+i]=allocateUTF8OnStack(args[i-1])}HEAP32[(argv>>2)+argc]=0;try{var ret=entryFunction(argc,argv);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="unwind"){noExitRuntime=true;return}else{var toLog=e;if(e&&typeof e==="object"&&e.stack){toLog=[e,e.stack]}err("exception thrown: "+toLog);quit_(1,e)}}finally{calledMain=true}}function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(shouldRunNow)callMain(args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&noExitRuntime&&status===0){return}if(noExitRuntime){}else{EXITSTATUS=status;exitRuntime();if(Module["onExit"])Module["onExit"](status);ABORT=true}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"])shouldRunNow=false;run(); diff --git a/dist/CDemo.wasm b/dist/CDemo.wasm deleted file mode 100755 index dca0509..0000000 Binary files a/dist/CDemo.wasm and /dev/null differ diff --git a/dist/bundle.js b/dist/bundle.js index baba7e7..ce76c00 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -4026,7 +4026,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Sketcher\": () => (/* binding */ Sketcher)\n/* harmony export */ });\n/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ \"./node_modules/three/build/three.module.js\");\n/* harmony import */ var _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../node_modules/three/src/Three */ \"./node_modules/three/src/Three.js\");\n\n\n\n\n\nclass Sketcher extends _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Group {\n constructor(camera, domElement, plane) {\n super()\n this.camera = camera;\n this.domElement = domElement;\n this.scene = scene;\n this.plane = plane;\n this.matrixAutoUpdate = false;\n this.sketchNormal = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, 0, 1)\n this.orientSketcher(plane)\n\n\n this.add(new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.PlaneHelper(this.plane, 1, 0xffff00));\n\n\n this.linesGroup = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Group()\n this.linesArr = this.linesGroup.children\n this.pointsGroup = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Group()\n this.ptsArr = this.pointsGroup.children\n this.add(this.linesGroup)\n this.add(this.pointsGroup)\n\n window.lg = this.linesArr\n window.pg = this.ptsArr\n\n this.pickThreshold = 100\n this.grabbedObject = null\n\n this.lineMaterial = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.LineBasicMaterial({\n color: 0x555,\n })\n this.pointMaterial = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.PointsMaterial({\n color: 0xAAA,\n size: 3,\n })\n\n this.pointStart = this.pointStart.bind(this);\n this.pointEnd = this.pointEnd.bind(this);\n this.move = this.move.bind(this);\n this.keyHandler = this.keyHandler.bind(this);\n this.picker = this.picker.bind(this);\n this.grabbedMove = this.grabbedMove.bind(this);\n this.grabEnd = this.grabEnd.bind(this);\n this.raycaster = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Raycaster();\n\n\n window.addEventListener('keydown', this.keyHandler)\n domElement.addEventListener('pointerdown', this.picker)\n\n\n this.mode = \"\"\n\n\n }\n\n orientSketcher() {\n\n const theta = this.sketchNormal.angleTo(this.plane.normal)\n const axis = this.sketchNormal.clone().cross(this.plane.normal).normalize()\n const rot = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Matrix4().makeRotationAxis(axis, theta)\n const trans = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Matrix4().makeTranslation(0, 0, this.plane.constant)\n\n this.matrix = rot.multiply(trans) // world matrix will auto update in next render\n this.inverse = this.matrix.clone().invert()\n\n }\n\n keyHandler(e) {\n switch (e.key) {\n case 'Escape':\n this.clear()\n this.mode = \"\"\n break;\n case 'l':\n this.addLine()\n this.mode = \"line\"\n break;\n case 'b':\n this.writeBuff()\n break;\n case '=':\n this.plane.applyMatrix4(new three__WEBPACK_IMPORTED_MODULE_1__.Matrix4().makeRotationY(0.1))\n this.orientSketcher()\n\n this.dispatchEvent({ type: 'change' })\n break;\n case '-':\n this.plane.applyMatrix4(new three__WEBPACK_IMPORTED_MODULE_1__.Matrix4().makeRotationY(-0.1))\n this.orientSketcher()\n\n this.dispatchEvent({ type: 'change' })\n break;\n }\n }\n\n\n picker(e) {\n if (this.mode || e.buttons != 1) return\n this.raycaster.setFromCamera(\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Vector2(\n (e.clientX / window.innerWidth) * 2 - 1,\n - (e.clientY / window.innerHeight) * 2 + 1\n ),\n this.camera\n );\n\n // console.log(this.ptsArr)\n const candidates = this.raycaster.intersectObjects(this.ptsArr)\n // console.log(candidates)\n\n\n if (!candidates.length) return;\n\n let minDist = candidates[0].distanceToRay\n let idx = 0\n\n for (let i = 1; i < candidates.length; i++) {\n if (candidates.distanceToRay < minDist) {\n minDist = candidates.distanceToRay\n idx = i\n }\n }\n\n if (minDist < this.pickThreshold) {\n this.grabPtIdx = this.ptsArr.indexOf(\n candidates[idx].object\n )\n } else {\n return\n }\n\n this.domElement.addEventListener('pointermove', this.grabbedMove);\n this.domElement.addEventListener('pointerup', this.grabEnd);\n }\n\n grabbedMove(e) {\n const mouseLoc = this.getLocation(e);\n\n this.moveLinePt(this.grabPtIdx, mouseLoc)\n\n this.dispatchEvent({ type: 'change' })\n }\n\n moveLinePt(ptIdx, absPos) {\n this.ptsArr[ptIdx].geometry.attributes.position.set(absPos);\n this.ptsArr[ptIdx].geometry.attributes.position.needsUpdate = true;\n\n const lineIdx = Math.floor(ptIdx / 2)\n const endPtIdx = (ptIdx % 2) * 3\n this.linesArr[lineIdx].geometry.attributes.position.set(absPos, endPtIdx)\n this.linesArr[lineIdx].geometry.attributes.position.needsUpdate = true;\n }\n\n grabEnd() {\n this.domElement.removeEventListener('pointermove', this.grabbedMove)\n this.domElement.removeEventListener('pointerup', this.grabEnd)\n this.ptsArr[this.grabPtIdx].geometry.computeBoundingSphere()\n // this.grabbedObject = null\n }\n\n\n addLine() {\n this.domElement.addEventListener('pointerdown', this.pointStart)\n }\n\n clear() {\n if (this.mode == \"\") return\n\n this.domElement.removeEventListener('pointerdown', this.pointStart)\n this.domElement.removeEventListener('pointermove', this.move);\n this.domElement.removeEventListener('pointerdown', this.pointEnd);\n this.domElement.removeEventListener('pointerdown', this.pointEnd);\n\n const lastLine = this.linesArr[this.linesArr.length - 1]\n this.linesGroup.remove(lastLine)\n lastLine.geometry.dispose()\n\n const lastPoints = this.ptsArr.slice(this.ptsArr.length - 2)\n this.pointsGroup.remove(...lastPoints)\n lastPoints.forEach(obj => obj.geometry.dispose())\n\n this.dispatchEvent({ type: 'change' })\n }\n\n getLocation(e) {\n this.raycaster.setFromCamera(\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Vector2(\n (e.clientX / window.innerWidth) * 2 - 1,\n - (e.clientY / window.innerHeight) * 2 + 1\n ),\n this.camera\n );\n // return this.worldToLocal(this.raycaster.ray.intersectPlane(this.plane)).toArray()\n return this.raycaster.ray.intersectPlane(this.plane).applyMatrix4(this.inverse).toArray()\n }\n\n pointStart(e) {\n if (e.buttons !== 1) return\n const mouseLoc = this.getLocation(e);\n\n this.lineGeom = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry()\n this.lineGeom.setAttribute('position',\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferAttribute(\n new Float32Array(6), 3\n )\n );\n this.lineGeom.attributes.position.set(mouseLoc)\n this.line = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.LineSegments(this.lineGeom, this.lineMaterial);\n this.line.frustumCulled = false;\n this.linesGroup.add(this.line)\n\n this.p1Geom = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry()\n this.p1Geom.setAttribute('position',\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferAttribute(\n new Float32Array(3), 3\n )\n );\n this.p1Geom.attributes.position.set(mouseLoc)\n this.p1 = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Points(this.p1Geom, this.pointMaterial);\n this.pointsGroup.add(this.p1)\n\n this.p2Geom = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry()\n this.p2Geom.setAttribute('position',\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferAttribute(\n new Float32Array(3), 3\n )\n );\n this.p2 = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Points(this.p2Geom, this.pointMaterial);\n this.pointsGroup.add(this.p2)\n\n this.domElement.removeEventListener('pointerdown', this.pointStart)\n this.domElement.addEventListener('pointermove', this.move)\n this.domElement.addEventListener('pointerdown', this.pointEnd)\n }\n\n\n move(e) {\n const mouseLoc = this.getLocation(e);\n this.lineGeom.attributes.position.set(mouseLoc, 3)\n this.lineGeom.attributes.position.needsUpdate = true;\n this.p2Geom.attributes.position.set(mouseLoc);\n this.p2Geom.attributes.position.needsUpdate = true;\n this.p2Geom.computeBoundingSphere();\n this.dispatchEvent({ type: 'change' })\n }\n\n pointEnd(e) {\n if (e.buttons !== 1) return;\n this.domElement.removeEventListener('pointermove', this.move);\n this.domElement.removeEventListener('pointerdown', this.pointEnd);\n\n\n this.pointStart(e)\n }\n\n writeBuff() {\n // const linesBuf = new Float32Array(this.linesArr.length * 4)\n // const xyOnly = [0,1,3,4];\n // let p = 0\n // for (let i = 0; i < this.linesArr.length; i++) {\n // for (let j of xyOnly) {\n // linesBuf[p++] = this.linesArr[i].geometry.attributes.position.array[j]\n // }\n // }\n\n let ptsBuf = new Float32Array(this.ptsArr.length * 2)\n for (let i = 0, p = 0; i < this.ptsArr.length; i++) {\n for (let j = 0; j < 2; j++) {\n ptsBuf[p++] = this.ptsArr[i].geometry.attributes.position.array[j]\n }\n }\n console.log(ptsBuf)\n\n buffer = Module._malloc(ptsBuf.length * ptsBuf.BYTES_PER_ELEMENT)\n Module.HEAPF32.set(ptsBuf, buffer >> 2)\n\n Module[\"_solver\"](buffer)\n }\n}\n\n\n\n\n\n//# sourceURL=webpack:///./src/Sketcher.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Sketcher\": () => (/* binding */ Sketcher)\n/* harmony export */ });\n/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ \"./node_modules/three/build/three.module.js\");\n/* harmony import */ var _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../node_modules/three/src/Three */ \"./node_modules/three/src/Three.js\");\n\n\n\n\n\nclass Sketcher extends _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Group {\n constructor(camera, domElement, plane) {\n super()\n this.camera = camera;\n this.domElement = domElement;\n this.scene = scene;\n this.plane = plane;\n this.matrixAutoUpdate = false;\n this.sketchNormal = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, 0, 1)\n this.orientSketcher(plane)\n\n\n this.add(new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.PlaneHelper(this.plane, 1, 0xffff00));\n\n\n this.linesGroup = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Group()\n this.linesArr = this.linesGroup.children\n this.pointsGroup = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Group()\n this.ptsArr = this.pointsGroup.children\n this.add(this.linesGroup)\n this.add(this.pointsGroup)\n\n window.lg = this.linesArr\n window.pg = this.ptsArr\n\n this.pickThreshold = 100\n this.grabbedObject = null\n\n this.lineMaterial = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.LineBasicMaterial({\n color: 0x555,\n })\n this.pointMaterial = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.PointsMaterial({\n color: 0xAAA,\n size: 3,\n })\n\n this.pointStart = this.pointStart.bind(this);\n this.pointEnd = this.pointEnd.bind(this);\n this.move = this.move.bind(this);\n this.keyHandler = this.keyHandler.bind(this);\n this.picker = this.picker.bind(this);\n this.grabbedMove = this.grabbedMove.bind(this);\n this.grabEnd = this.grabEnd.bind(this);\n this.raycaster = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Raycaster();\n\n\n window.addEventListener('keydown', this.keyHandler)\n domElement.addEventListener('pointerdown', this.picker)\n\n\n this.mode = \"\"\n\n\n }\n\n orientSketcher() {\n\n const theta = this.sketchNormal.angleTo(this.plane.normal)\n const axis = this.sketchNormal.clone().cross(this.plane.normal).normalize()\n const rot = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Matrix4().makeRotationAxis(axis, theta)\n const trans = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Matrix4().makeTranslation(0, 0, this.plane.constant)\n\n this.matrix = rot.multiply(trans) // world matrix will auto update in next render\n this.inverse = this.matrix.clone().invert()\n\n }\n\n keyHandler(e) {\n switch (e.key) {\n case 'Escape':\n this.clear()\n this.mode = \"\"\n break;\n case 'l':\n this.addLine()\n this.mode = \"line\"\n break;\n case 'b':\n this.solve()\n break;\n case '=':\n this.plane.applyMatrix4(new three__WEBPACK_IMPORTED_MODULE_1__.Matrix4().makeRotationY(0.1))\n this.orientSketcher()\n\n this.dispatchEvent({ type: 'change' })\n break;\n case '-':\n this.plane.applyMatrix4(new three__WEBPACK_IMPORTED_MODULE_1__.Matrix4().makeRotationY(-0.1))\n this.orientSketcher()\n\n this.dispatchEvent({ type: 'change' })\n break;\n }\n }\n\n\n picker(e) {\n if (this.mode || e.buttons != 1) return\n this.raycaster.setFromCamera(\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Vector2(\n (e.clientX / window.innerWidth) * 2 - 1,\n - (e.clientY / window.innerHeight) * 2 + 1\n ),\n this.camera\n );\n\n // console.log(this.ptsArr)\n const candidates = this.raycaster.intersectObjects(this.ptsArr)\n // console.log(candidates)\n\n\n if (!candidates.length) return;\n\n let minDist = candidates[0].distanceToRay\n let idx = 0\n\n for (let i = 1; i < candidates.length; i++) {\n if (candidates.distanceToRay < minDist) {\n minDist = candidates.distanceToRay\n idx = i\n }\n }\n\n if (minDist < this.pickThreshold) {\n this.grabPtIdx = this.ptsArr.indexOf(\n candidates[idx].object\n )\n } else {\n return\n }\n\n this.domElement.addEventListener('pointermove', this.grabbedMove);\n this.domElement.addEventListener('pointerup', this.grabEnd);\n }\n\n grabbedMove(e) {\n const mouseLoc = this.getLocation(e);\n\n this.moveLinePt(this.grabPtIdx, mouseLoc)\n\n this.dispatchEvent({ type: 'change' })\n }\n\n moveLinePt(ptIdx, absPos) {\n this.ptsArr[ptIdx].geometry.attributes.position.set(absPos);\n this.ptsArr[ptIdx].geometry.attributes.position.needsUpdate = true;\n\n const lineIdx = Math.floor(ptIdx / 2)\n const endPtIdx = (ptIdx % 2) * 3\n this.linesArr[lineIdx].geometry.attributes.position.set(absPos, endPtIdx)\n this.linesArr[lineIdx].geometry.attributes.position.needsUpdate = true;\n }\n\n grabEnd() {\n this.domElement.removeEventListener('pointermove', this.grabbedMove)\n this.domElement.removeEventListener('pointerup', this.grabEnd)\n this.ptsArr[this.grabPtIdx].geometry.computeBoundingSphere()\n // this.grabbedObject = null\n }\n\n\n addLine() {\n this.domElement.addEventListener('pointerdown', this.pointStart)\n }\n\n clear() {\n if (this.mode == \"\") return\n\n this.domElement.removeEventListener('pointerdown', this.pointStart)\n this.domElement.removeEventListener('pointermove', this.move);\n this.domElement.removeEventListener('pointerdown', this.pointEnd);\n this.domElement.removeEventListener('pointerdown', this.pointEnd);\n\n const lastLine = this.linesArr[this.linesArr.length - 1]\n this.linesGroup.remove(lastLine)\n lastLine.geometry.dispose()\n\n const lastPoints = this.ptsArr.slice(this.ptsArr.length - 2)\n this.pointsGroup.remove(...lastPoints)\n lastPoints.forEach(obj => obj.geometry.dispose())\n\n this.dispatchEvent({ type: 'change' })\n }\n\n getLocation(e) {\n this.raycaster.setFromCamera(\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Vector2(\n (e.clientX / window.innerWidth) * 2 - 1,\n - (e.clientY / window.innerHeight) * 2 + 1\n ),\n this.camera\n );\n // return this.worldToLocal(this.raycaster.ray.intersectPlane(this.plane)).toArray()\n return this.raycaster.ray.intersectPlane(this.plane).applyMatrix4(this.inverse).toArray()\n }\n\n pointStart(e) {\n if (e.buttons !== 1) return\n const mouseLoc = this.getLocation(e);\n\n this.lineGeom = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry()\n this.lineGeom.setAttribute('position',\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferAttribute(\n new Float32Array(6), 3\n )\n );\n this.lineGeom.attributes.position.set(mouseLoc)\n this.line = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.LineSegments(this.lineGeom, this.lineMaterial);\n this.line.frustumCulled = false;\n this.linesGroup.add(this.line)\n\n this.p1Geom = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry()\n this.p1Geom.setAttribute('position',\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferAttribute(\n new Float32Array(3), 3\n )\n );\n this.p1Geom.attributes.position.set(mouseLoc)\n this.p1 = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Points(this.p1Geom, this.pointMaterial);\n this.pointsGroup.add(this.p1)\n\n this.p2Geom = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry()\n this.p2Geom.setAttribute('position',\n new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.BufferAttribute(\n new Float32Array(3), 3\n )\n );\n this.p2 = new _node_modules_three_src_Three__WEBPACK_IMPORTED_MODULE_0__.Points(this.p2Geom, this.pointMaterial);\n this.pointsGroup.add(this.p2)\n\n this.domElement.removeEventListener('pointerdown', this.pointStart)\n this.domElement.addEventListener('pointermove', this.move)\n this.domElement.addEventListener('pointerdown', this.pointEnd)\n }\n\n\n move(e) {\n const mouseLoc = this.getLocation(e);\n this.lineGeom.attributes.position.set(mouseLoc, 3)\n this.lineGeom.attributes.position.needsUpdate = true;\n this.p2Geom.attributes.position.set(mouseLoc);\n this.p2Geom.attributes.position.needsUpdate = true;\n this.p2Geom.computeBoundingSphere();\n this.dispatchEvent({ type: 'change' })\n }\n\n pointEnd(e) {\n if (e.buttons !== 1) return;\n this.domElement.removeEventListener('pointermove', this.move);\n this.domElement.removeEventListener('pointerdown', this.pointEnd);\n\n\n this.pointStart(e)\n }\n\n solve() {\n // const linesBuf = new Float32Array(this.linesArr.length * 4)\n // const xyOnly = [0,1,3,4];\n // let p = 0\n // for (let i = 0; i < this.linesArr.length; i++) {\n // for (let j of xyOnly) {\n // linesBuf[p++] = this.linesArr[i].geometry.attributes.position.array[j]\n // }\n // }\n\n let ptsBuf = new Float32Array(this.ptsArr.length * 2)\n for (let i = 0, p = 0; i < this.ptsArr.length; i++) {\n for (let j = 0; j < 2; j++) {\n ptsBuf[p++] = this.ptsArr[i].geometry.attributes.position.array[j]\n }\n }\n\n buffer = Module._malloc(ptsBuf.length * ptsBuf.BYTES_PER_ELEMENT)\n Module.HEAPF32.set(ptsBuf, buffer >> 2)\n\n Module[\"_solver\"](this.ptsArr.length/2, buffer)\n\n Module._free(buffer)\n }\n}\n\n\n\n\n\n//# sourceURL=webpack:///./src/Sketcher.js?"); /***/ }), diff --git a/dist/solver.js b/dist/solver.js index 6adf626..30678c6 100644 --- a/dist/solver.js +++ b/dist/solver.js @@ -736,10 +736,6 @@ function cwrap(ident, returnType, argTypes, opts) { // We used to include malloc/free by default in the past. Show a helpful error in // builds with assertions. -function _free() { - // Show a helpful error since we used to include free by default in the past. - abort("free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS"); -} var ALLOC_NORMAL = 0; // Tries to use _malloc() var ALLOC_STACK = 1; // Lives for the duration of the current function call @@ -1199,7 +1195,7 @@ function updateGlobalBufferAndViews(buf) { var TOTAL_STACK = 5242880; if (Module['TOTAL_STACK']) assert(TOTAL_STACK === Module['TOTAL_STACK'], 'the stack size can no longer be determined at runtime') -var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216; +var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 134217728; if (!Object.getOwnPropertyDescriptor(Module, 'INITIAL_MEMORY')) { Object.defineProperty(Module, 'INITIAL_MEMORY', { configurable: true, @@ -1217,7 +1213,7 @@ assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' // If memory is defined in wasm, the user can't provide it. assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -s IMPORTED_MEMORY to define wasmMemory externally'); -assert(INITIAL_MEMORY == 16777216, 'Detected runtime INITIAL_MEMORY setting. Use -s IMPORTED_MEMORY to define wasmMemory dynamically'); +assert(INITIAL_MEMORY == 134217728, 'Detected runtime INITIAL_MEMORY setting. Use -s IMPORTED_MEMORY to define wasmMemory dynamically'); // include: runtime_init_table.js // In regular non-RELOCATABLE mode the table is exported @@ -1615,7 +1611,7 @@ function createWasm() { // This assertion doesn't hold when emscripten is run in --post-link // mode. // TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode. - //assert(wasmMemory.buffer.byteLength === 16777216); + //assert(wasmMemory.buffer.byteLength === 134217728); updateGlobalBufferAndViews(wasmMemory.buffer); wasmTable = Module['asm']['__indirect_function_table']; @@ -1767,6 +1763,100 @@ var ASM_CONSTS = { return demangleAll(js); } + var ExceptionInfoAttrs={DESTRUCTOR_OFFSET:0,REFCOUNT_OFFSET:4,TYPE_OFFSET:8,CAUGHT_OFFSET:12,RETHROWN_OFFSET:13,SIZE:16}; + function ___cxa_allocate_exception(size) { + // Thrown object is prepended by exception metadata block + return _malloc(size + ExceptionInfoAttrs.SIZE) + ExceptionInfoAttrs.SIZE; + } + + function _atexit(func, arg) { + } + function ___cxa_atexit(a0,a1 + ) { + return _atexit(a0,a1); + } + + function ExceptionInfo(excPtr) { + this.excPtr = excPtr; + this.ptr = excPtr - ExceptionInfoAttrs.SIZE; + + this.set_type = function(type) { + HEAP32[(((this.ptr)+(ExceptionInfoAttrs.TYPE_OFFSET))>>2)] = type; + }; + + this.get_type = function() { + return HEAP32[(((this.ptr)+(ExceptionInfoAttrs.TYPE_OFFSET))>>2)]; + }; + + this.set_destructor = function(destructor) { + HEAP32[(((this.ptr)+(ExceptionInfoAttrs.DESTRUCTOR_OFFSET))>>2)] = destructor; + }; + + this.get_destructor = function() { + return HEAP32[(((this.ptr)+(ExceptionInfoAttrs.DESTRUCTOR_OFFSET))>>2)]; + }; + + this.set_refcount = function(refcount) { + HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)] = refcount; + }; + + this.set_caught = function (caught) { + caught = caught ? 1 : 0; + HEAP8[(((this.ptr)+(ExceptionInfoAttrs.CAUGHT_OFFSET))>>0)] = caught; + }; + + this.get_caught = function () { + return HEAP8[(((this.ptr)+(ExceptionInfoAttrs.CAUGHT_OFFSET))>>0)] != 0; + }; + + this.set_rethrown = function (rethrown) { + rethrown = rethrown ? 1 : 0; + HEAP8[(((this.ptr)+(ExceptionInfoAttrs.RETHROWN_OFFSET))>>0)] = rethrown; + }; + + this.get_rethrown = function () { + return HEAP8[(((this.ptr)+(ExceptionInfoAttrs.RETHROWN_OFFSET))>>0)] != 0; + }; + + // Initialize native structure fields. Should be called once after allocated. + this.init = function(type, destructor) { + this.set_type(type); + this.set_destructor(destructor); + this.set_refcount(0); + this.set_caught(false); + this.set_rethrown(false); + } + + this.add_ref = function() { + var value = HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)]; + HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)] = value + 1; + }; + + // Returns true if last reference released. + this.release_ref = function() { + var prev = HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)]; + HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)] = prev - 1; + assert(prev > 0); + return prev === 1; + }; + } + + var exceptionLast=0; + + var uncaughtExceptionCount=0; + function ___cxa_throw(ptr, type, destructor) { + var info = new ExceptionInfo(ptr); + // Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception. + info.init(type, destructor); + exceptionLast = ptr; + uncaughtExceptionCount++; + throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."; + } + + function _abort() { + abort(); + } + function _emscripten_memcpy_big(dest, src, num) { HEAPU8.copyWithin(dest, src, src + num); } @@ -1788,14 +1878,6 @@ var ASM_CONSTS = { exit(status); } - function flush_NO_FILESYSTEM() { - // flush anything remaining in the buffers during shutdown - if (typeof _fflush !== 'undefined') _fflush(0); - var buffers = SYSCALLS.buffers; - if (buffers[1].length) SYSCALLS.printChar(1, 10); - if (buffers[2].length) SYSCALLS.printChar(2, 10); - } - var SYSCALLS={mappings:{},buffers:[null,[],[]],printChar:function(stream, curr) { var buffer = SYSCALLS.buffers[stream]; assert(buffer); @@ -1818,6 +1900,22 @@ var ASM_CONSTS = { else assert(high === -1); return low; }}; + function _fd_close(fd) { + abort('it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM'); + return 0; + } + + function _fd_seek(fd, offset_low, offset_high, whence, newOffset) { + abort('it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM'); + } + + function flush_NO_FILESYSTEM() { + // flush anything remaining in the buffers during shutdown + if (typeof _fflush !== 'undefined') _fflush(0); + var buffers = SYSCALLS.buffers; + if (buffers[1].length) SYSCALLS.printChar(1, 10); + if (buffers[2].length) SYSCALLS.printChar(2, 10); + } function _fd_write(fd, iov, iovcnt, pnum) { // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0 var num = 0; @@ -1866,9 +1964,15 @@ function intArrayToString(array) { var asmLibraryArg = { + "__cxa_allocate_exception": ___cxa_allocate_exception, + "__cxa_atexit": ___cxa_atexit, + "__cxa_throw": ___cxa_throw, + "abort": _abort, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "exit": _exit, + "fd_close": _fd_close, + "fd_seek": _fd_seek, "fd_write": _fd_write, "setTempRet0": _setTempRet0 }; @@ -1885,6 +1989,9 @@ var _main = Module["_main"] = createExportWrapper("main"); /** @type {function(...*):?} */ var _malloc = Module["_malloc"] = createExportWrapper("malloc"); +/** @type {function(...*):?} */ +var _free = Module["_free"] = createExportWrapper("free"); + /** @type {function(...*):?} */ var ___errno_location = Module["___errno_location"] = createExportWrapper("__errno_location"); diff --git a/dist/solver.wasm b/dist/solver.wasm index 90433a5..f6efd4e 100755 Binary files a/dist/solver.wasm and b/dist/solver.wasm differ diff --git a/src/Sketcher.js b/src/Sketcher.js index d384a51..4eafdb7 100644 --- a/src/Sketcher.js +++ b/src/Sketcher.js @@ -81,7 +81,7 @@ export class Sketcher extends THREE.Group { this.mode = "line" break; case 'b': - this.writeBuff() + this.solve() break; case '=': this.plane.applyMatrix4(new Matrix4().makeRotationY(0.1)) @@ -258,7 +258,7 @@ export class Sketcher extends THREE.Group { this.pointStart(e) } - writeBuff() { + solve() { // const linesBuf = new Float32Array(this.linesArr.length * 4) // const xyOnly = [0,1,3,4]; // let p = 0 @@ -274,12 +274,13 @@ export class Sketcher extends THREE.Group { ptsBuf[p++] = this.ptsArr[i].geometry.attributes.position.array[j] } } - console.log(ptsBuf) buffer = Module._malloc(ptsBuf.length * ptsBuf.BYTES_PER_ELEMENT) Module.HEAPF32.set(ptsBuf, buffer >> 2) - Module["_solver"](buffer) + Module["_solver"](this.ptsArr.length/2, buffer) + + Module._free(buffer) } } diff --git a/wasm/notes b/wasm/notes index 0684ce9..d10b6cf 100644 --- a/wasm/notes +++ b/wasm/notes @@ -1 +1,138 @@ -emcc ./wasm/solver.c ./wasm/libslvs.a -L./wasm/ -lslvs -o ./dist/solver.js -s TOTAL_MEMORY=134217728 -s EXPORTED_FUNCTIONS='[_main, _solver]' \ No newline at end of file +emcc ./wasm/solver.c ./wasm/libslvs.a -L./wasm/ -lslvs -o ./dist/solver.js -s TOTAL_MEMORY=134217728 -s EXPORTED_FUNCTIONS='[_main, _solver, _free]' + + + +int solver(int nLines, float *ptr) +{ + // for (int i=0; i 0) + { + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + con_id++, g, + SLVS_C_POINTS_COINCIDENT, + 200, + 0.0, + pt_id - 1, pt_id - 2, 0, 0); + } + else + { + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + con_id++, g, + SLVS_C_POINTS_COINCIDENT, + 200, + 0.0, + pt_id - 1, 101, 0, 0); + } + + printf("h:%i\n", h); + + sys.param[sys.params++] = Slvs_MakeParam(h++, g, (float)*ptr++); + sys.param[sys.params++] = Slvs_MakeParam(h++, g, (float)*ptr++); + + sys.entity[sys.entities++] = Slvs_MakePoint2d(pt_id++, g, 200, h - 2, h - 1); + + sys.entity[sys.entities++] = Slvs_MakeLineSegment(line_id++, g, + 200, pt_id - 1, pt_id - 2); + + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + con_id++, g, + SLVS_C_PT_PT_DISTANCE, + 200, + 30.0, + pt_id - 1, pt_id - 2, 0, 0); + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + con_id++, g, + SLVS_C_VERTICAL, + 200, + 0.0, + 0, 0, line_id-1, 0); + } + + /* If the solver fails, then ask it to report which constraints caused + * the problem. */ + sys.calculateFaileds = 1; + + sys.dragged[0] = 10; + sys.dragged[1] = 11; + sys.dragged[2] = 14; + sys.dragged[3] = 15; + + /* And solve. */ + Slvs_Solve(&sys, g); + + // printf("%i,wtf\n", sys.result); + if (sys.result == SLVS_RESULT_OKAY) + { + printf("solved okay\n"); + + for (int i = 0; i < nLines * 4; i++) + { + // *buf_pt_start++ = (float)sys.param[ptStart++].val; + printf("%f\n", sys.param[ptStart++].val); + } + } + else + { + int i; + printf("solve failed: problematic constraints are:"); + for (i = 0; i < sys.faileds; i++) + { + printf(" %d", sys.failed[i]); + } + printf("\n"); + if (sys.result == SLVS_RESULT_INCONSISTENT) + { + printf("system inconsistent\n"); + } + else + { + printf("system nonconvergent\n"); + } + } + sys.params = sys.constraints = sys.entities = 0; + return 0; +} \ No newline at end of file diff --git a/wasm/solver.c b/wasm/solver.c index 7cafa87..d82920e 100644 --- a/wasm/solver.c +++ b/wasm/solver.c @@ -6,7 +6,7 @@ * Copyright 2008-2013 Jonathan Westhues. *---------------------------------------------------------------------------*/ #ifdef WIN32 -# include +#include #endif #include #include @@ -19,12 +19,13 @@ static Slvs_System sys; static void *CheckMalloc(size_t n) { - void *r = malloc(n); - if(!r) { - printf("out of memory!\n"); - exit(-1); - } - return r; + void *r = malloc(n); + if (!r) + { + printf("out of memory!\n"); + exit(-1); + } + return r; } /*----------------------------------------------------------------------------- @@ -33,49 +34,52 @@ static void *CheckMalloc(size_t n) *---------------------------------------------------------------------------*/ void Example3d() { - /* This will contain a single group, which will arbitrarily number 1. */ - Slvs_hGroup g = 1; + /* This will contain a single group, which will arbitrarily number 1. */ + Slvs_hGroup g = 1; - /* A point, initially at (x y z) = (10 10 10) */ - sys.param[sys.params++] = Slvs_MakeParam(1, g, 10.0); - sys.param[sys.params++] = Slvs_MakeParam(2, g, 10.0); - sys.param[sys.params++] = Slvs_MakeParam(3, g, 10.0); - sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3); - /* and a second point at (20 20 20) */ - sys.param[sys.params++] = Slvs_MakeParam(4, g, 20.0); - sys.param[sys.params++] = Slvs_MakeParam(5, g, 20.0); - sys.param[sys.params++] = Slvs_MakeParam(6, g, 20.0); - sys.entity[sys.entities++] = Slvs_MakePoint3d(102, g, 4, 5, 6); - /* and a line segment connecting them. */ - sys.entity[sys.entities++] = Slvs_MakeLineSegment(200, g, - SLVS_FREE_IN_3D, 101, 102); + /* A point, initially at (x y z) = (10 10 10) */ + sys.param[sys.params++] = Slvs_MakeParam(1, g, 10.0); + sys.param[sys.params++] = Slvs_MakeParam(2, g, 10.0); + sys.param[sys.params++] = Slvs_MakeParam(3, g, 10.0); + sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3); + /* and a second point at (20 20 20) */ + sys.param[sys.params++] = Slvs_MakeParam(4, g, 20.0); + sys.param[sys.params++] = Slvs_MakeParam(5, g, 20.0); + sys.param[sys.params++] = Slvs_MakeParam(6, g, 20.0); + sys.entity[sys.entities++] = Slvs_MakePoint3d(102, g, 4, 5, 6); + /* and a line segment connecting them. */ + sys.entity[sys.entities++] = Slvs_MakeLineSegment(200, g, + SLVS_FREE_IN_3D, 101, 102); - /* The distance between the points should be 30.0 units. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 1, g, - SLVS_C_PT_PT_DISTANCE, - SLVS_FREE_IN_3D, - 30.0, - 101, 102, 0, 0); + /* The distance between the points should be 30.0 units. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 1, g, + SLVS_C_PT_PT_DISTANCE, + SLVS_FREE_IN_3D, + 30.0, + 101, 102, 0, 0); - /* Let's tell the solver to keep the second point as close to constant + /* Let's tell the solver to keep the second point as close to constant * as possible, instead moving the first point. */ - sys.dragged[0] = 4; - sys.dragged[1] = 5; - sys.dragged[2] = 6; + // sys.dragged[0] = 4; + // sys.dragged[1] = 5; + // sys.dragged[2] = 6; - /* Now that we have written our system, we solve. */ - Slvs_Solve(&sys, g); + /* Now that we have written our system, we solve. */ + Slvs_Solve(&sys, g); - if(sys.result == SLVS_RESULT_OKAY) { - printf("okay; now at (%.3f %.3f %.3f)\n" - " (%.3f %.3f %.3f)\n", - sys.param[0].val, sys.param[1].val, sys.param[2].val, - sys.param[3].val, sys.param[4].val, sys.param[5].val); - printf("%d DOF\n", sys.dof); - } else { - printf("solve failed"); - } + if (sys.result == SLVS_RESULT_OKAY) + { + printf("okay; now at (%.3f %.3f %.3f)\n" + " (%.3f %.3f %.3f)\n", + sys.param[0].val, sys.param[1].val, sys.param[2].val, + sys.param[3].val, sys.param[4].val, sys.param[5].val); + printf("%d DOF\n", sys.dof); + } + else + { + printf("solve failed"); + } } /*----------------------------------------------------------------------------- @@ -85,108 +89,107 @@ void Example3d() *---------------------------------------------------------------------------*/ void Example2d(float xx) { - Slvs_hGroup g; - double qw, qx, qy, qz; + Slvs_hGroup g; + double qw, qx, qy, qz; - g = 1; - /* First, we create our workplane. Its origin corresponds to the origin + g = 1; + /* First, we create our workplane. Its origin corresponds to the origin * of our base frame (x y z) = (0 0 0) */ - sys.param[sys.params++] = Slvs_MakeParam(1, g, 0.0); - sys.param[sys.params++] = Slvs_MakeParam(2, g, 0.0); - sys.param[sys.params++] = Slvs_MakeParam(3, g, 0.0); - sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3); - /* and it is parallel to the xy plane, so it has basis vectors (1 0 0) + sys.param[sys.params++] = Slvs_MakeParam(1, g, 0.0); + sys.param[sys.params++] = Slvs_MakeParam(2, g, 0.0); + sys.param[sys.params++] = Slvs_MakeParam(3, g, 0.0); + sys.entity[sys.entities++] = Slvs_MakePoint3d(101, g, 1, 2, 3); + /* and it is parallel to the xy plane, so it has basis vectors (1 0 0) * and (0 1 0). */ - Slvs_MakeQuaternion(1, 0, 0, - 0, 1, 0, &qw, &qx, &qy, &qz); - sys.param[sys.params++] = Slvs_MakeParam(4, g, qw); - sys.param[sys.params++] = Slvs_MakeParam(5, g, qx); - sys.param[sys.params++] = Slvs_MakeParam(6, g, qy); - sys.param[sys.params++] = Slvs_MakeParam(7, g, qz); - sys.entity[sys.entities++] = Slvs_MakeNormal3d(102, g, 4, 5, 6, 7); + Slvs_MakeQuaternion(1, 0, 0, + 0, 1, 0, &qw, &qx, &qy, &qz); + sys.param[sys.params++] = Slvs_MakeParam(4, g, qw); + sys.param[sys.params++] = Slvs_MakeParam(5, g, qx); + sys.param[sys.params++] = Slvs_MakeParam(6, g, qy); + sys.param[sys.params++] = Slvs_MakeParam(7, g, qz); + sys.entity[sys.entities++] = Slvs_MakeNormal3d(102, g, 4, 5, 6, 7); - sys.entity[sys.entities++] = Slvs_MakeWorkplane(200, g, 101, 102); + sys.entity[sys.entities++] = Slvs_MakeWorkplane(200, g, 101, 102); - /* Now create a second group. We'll solve group 2, while leaving group 1 + /* Now create a second group. We'll solve group 2, while leaving group 1 * constant; so the workplane that we've created will be locked down, * and the solver can't move it. */ - g = 2; - /* These points are represented by their coordinates (u v) within the + g = 2; + /* These points are represented by their coordinates (u v) within the * workplane, so they need only two parameters each. */ - sys.param[sys.params++] = Slvs_MakeParam(11, g, 10.0); - sys.param[sys.params++] = Slvs_MakeParam(12, g, 20.0); - sys.entity[sys.entities++] = Slvs_MakePoint2d(301, g, 200, 11, 12); + sys.param[sys.params++] = Slvs_MakeParam(11, g, 10.0); + sys.param[sys.params++] = Slvs_MakeParam(12, g, 20.0); + sys.entity[sys.entities++] = Slvs_MakePoint2d(301, g, 200, 11, 12); - sys.param[sys.params++] = Slvs_MakeParam(13, g, 20.0); - sys.param[sys.params++] = Slvs_MakeParam(14, g, 10.0); - sys.entity[sys.entities++] = Slvs_MakePoint2d(302, g, 200, 13, 14); + sys.param[sys.params++] = Slvs_MakeParam(13, g, 20.0); + sys.param[sys.params++] = Slvs_MakeParam(14, g, 10.0); + sys.entity[sys.entities++] = Slvs_MakePoint2d(302, g, 200, 13, 14); - /* And we create a line segment with those endpoints. */ - sys.entity[sys.entities++] = Slvs_MakeLineSegment(400, g, - 200, 301, 302); + /* And we create a line segment with those endpoints. */ + sys.entity[sys.entities++] = Slvs_MakeLineSegment(400, g, + 200, 301, 302); - /* Now three more points. */ - - sys.param[sys.params++] = Slvs_MakeParam(15, g, 110.0); - sys.param[sys.params++] = Slvs_MakeParam(16, g, 120.0); - sys.entity[sys.entities++] = Slvs_MakePoint2d(303, g, 200, 15, 16); + /* Now three more points. */ - sys.param[sys.params++] = Slvs_MakeParam(17, g, 120.0); - sys.param[sys.params++] = Slvs_MakeParam(18, g, 110.0); - sys.entity[sys.entities++] = Slvs_MakePoint2d(304, g, 200, 17, 18); + sys.param[sys.params++] = Slvs_MakeParam(15, g, 110.0); + sys.param[sys.params++] = Slvs_MakeParam(16, g, 120.0); + sys.entity[sys.entities++] = Slvs_MakePoint2d(303, g, 200, 15, 16); - sys.param[sys.params++] = Slvs_MakeParam(19, g, 115.0); - sys.param[sys.params++] = Slvs_MakeParam(20, g, xx); - sys.entity[sys.entities++] = Slvs_MakePoint2d(305, g, 200, 19, 20); + sys.param[sys.params++] = Slvs_MakeParam(17, g, 120.0); + sys.param[sys.params++] = Slvs_MakeParam(18, g, 110.0); + sys.entity[sys.entities++] = Slvs_MakePoint2d(304, g, 200, 17, 18); - /* And arc, centered at point 303, starting at point 304, ending at + sys.param[sys.params++] = Slvs_MakeParam(19, g, 115.0); + sys.param[sys.params++] = Slvs_MakeParam(20, g, xx); + sys.entity[sys.entities++] = Slvs_MakePoint2d(305, g, 200, 19, 20); + + /* And arc, centered at point 303, starting at point 304, ending at * point 305. */ - sys.entity[sys.entities++] = Slvs_MakeArcOfCircle(401, g, 200, 102, - 303, 304, 305); + sys.entity[sys.entities++] = Slvs_MakeArcOfCircle(401, g, 200, 102, + 303, 304, 305); - /* Now one more point, and a distance */ - sys.param[sys.params++] = Slvs_MakeParam(21, g, 200.0); - sys.param[sys.params++] = Slvs_MakeParam(22, g, 200.0); - sys.entity[sys.entities++] = Slvs_MakePoint2d(306, g, 200, 21, 22); + /* Now one more point, and a distance */ + sys.param[sys.params++] = Slvs_MakeParam(21, g, 200.0); + sys.param[sys.params++] = Slvs_MakeParam(22, g, 200.0); + sys.entity[sys.entities++] = Slvs_MakePoint2d(306, g, 200, 21, 22); - sys.param[sys.params++] = Slvs_MakeParam(23, g, 30.0); - sys.entity[sys.entities++] = Slvs_MakeDistance(307, g, 200, 23); + sys.param[sys.params++] = Slvs_MakeParam(23, g, 30.0); + sys.entity[sys.entities++] = Slvs_MakeDistance(307, g, 200, 23); - /* And a complete circle, centered at point 306 with radius equal to + /* And a complete circle, centered at point 306 with radius equal to * distance 307. The normal is 102, the same as our workplane. */ - sys.entity[sys.entities++] = Slvs_MakeCircle(402, g, 200, - 306, 102, 307); + sys.entity[sys.entities++] = Slvs_MakeCircle(402, g, 200, + 306, 102, 307); + /* The length of our line segment is 30.0 units. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 1, g, + SLVS_C_PT_PT_DISTANCE, + 200, + 30.0, + 301, 302, 0, 0); - /* The length of our line segment is 30.0 units. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 1, g, - SLVS_C_PT_PT_DISTANCE, - 200, - 30.0, - 301, 302, 0, 0); - - /* And the distance from our line segment to the origin is 10.0 units. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 2, g, - SLVS_C_PT_LINE_DISTANCE, - 200, - 10.0, - 101, 0, 400, 0); - /* And the line segment is vertical. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 3, g, - SLVS_C_VERTICAL, - 200, - 0.0, - 0, 0, 400, 0); - /* And the distance from one endpoint to the origin is 15.0 units. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 4, g, - SLVS_C_PT_PT_DISTANCE, - 200, - 15.0, - 301, 101, 0, 0); + /* And the distance from our line segment to the origin is 10.0 units. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 2, g, + SLVS_C_PT_LINE_DISTANCE, + 200, + 10.0, + 101, 0, 400, 0); + /* And the line segment is vertical. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 3, g, + SLVS_C_VERTICAL, + 200, + 0.0, + 0, 0, 400, 0); + /* And the distance from one endpoint to the origin is 15.0 units. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 4, g, + SLVS_C_PT_PT_DISTANCE, + 200, + 15.0, + 301, 101, 0, 0); #if 0 /* And same for the other endpoint; so if you add this constraint then * the sketch is overconstrained and will signal an error. */ @@ -198,84 +201,180 @@ void Example2d(float xx) 302, 101, 0, 0); #endif /* 0 */ - /* The arc and the circle have equal radius. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 6, g, - SLVS_C_EQUAL_RADIUS, - 200, - 0.0, - 0, 0, 401, 402); - /* The arc has radius 17.0 units. */ - sys.constraint[sys.constraints++] = Slvs_MakeConstraint( - 7, g, - SLVS_C_DIAMETER, - 200, - 17.0*2, - 0, 0, 401, 0); + /* The arc and the circle have equal radius. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 6, g, + SLVS_C_EQUAL_RADIUS, + 200, + 0.0, + 0, 0, 401, 402); + /* The arc has radius 17.0 units. */ + sys.constraint[sys.constraints++] = Slvs_MakeConstraint( + 7, g, + SLVS_C_DIAMETER, + 200, + 17.0 * 2, + 0, 0, 401, 0); - /* If the solver fails, then ask it to report which constraints caused + /* If the solver fails, then ask it to report which constraints caused * the problem. */ - sys.calculateFaileds = 1; + sys.calculateFaileds = 1; - /* And solve. */ - Slvs_Solve(&sys, g); + /* And solve. */ + Slvs_Solve(&sys, g); - if(sys.result == SLVS_RESULT_OKAY) { - printf("solved okay\n"); - printf("line from (%.3f %.3f) to (%.3f %.3f)\n", - sys.param[7].val, sys.param[8].val, - sys.param[9].val, sys.param[10].val); + if (sys.result == SLVS_RESULT_OKAY) + { + printf("solved okay\n"); + printf("line from (%.3f %.3f) to (%.3f %.3f)\n", + sys.param[7].val, sys.param[8].val, + sys.param[9].val, sys.param[10].val); - printf("arc center (%.3f %.3f) start (%.3f %.3f) finish (%.3f %.3f)\n", - sys.param[11].val, sys.param[12].val, - sys.param[13].val, sys.param[14].val, - sys.param[15].val, sys.param[16].val); + printf("arc center (%.3f %.3f) start (%.3f %.3f) finish (%.3f %.3f)\n", + sys.param[11].val, sys.param[12].val, + sys.param[13].val, sys.param[14].val, + sys.param[15].val, sys.param[16].val); - printf("circle center (%.3f %.3f) radius %.3f\n", - sys.param[17].val, sys.param[18].val, - sys.param[19].val); - printf("%d DOF\n", sys.dof); - } else { - int i; - printf("solve failed: problematic constraints are:"); - for(i = 0; i < sys.faileds; i++) { - printf(" %d", sys.failed[i]); - } - printf("\n"); - if(sys.result == SLVS_RESULT_INCONSISTENT) { - printf("system inconsistent\n"); - } else { - printf("system nonconvergent\n"); - } + printf("circle center (%.3f %.3f) radius %.3f\n", + sys.param[17].val, sys.param[18].val, + sys.param[19].val); + printf("%d DOF\n", sys.dof); + } + else + { + int i; + printf("solve failed: problematic constraints are:"); + for (i = 0; i < sys.faileds; i++) + { + printf(" %d", sys.failed[i]); } + printf("\n"); + if (sys.result == SLVS_RESULT_INCONSISTENT) + { + printf("system inconsistent\n"); + } + else + { + printf("system nonconvergent\n"); + } + } } - -int solver(float *ptr) +int solver(int nLines, float *ptr) { + // for (int i=0; i