//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== #include "bbwtAddMesh.h" #include "bbwtPackage.h" #include namespace bbwt { BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,AddMesh) BBTK_BLACK_BOX_IMPLEMENTATION(AddMesh,bbtk::AtomicBlackBox); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void AddMesh::Process() { // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value // INPUT/OUTPUT ACCESSORS ARE OF THE FORM : // void bbSet{Input|Output}NAME(const TYPE&) // const TYPE& bbGet{Input|Output}NAME() const // Where : // * NAME is the name of the input/output // (the one provided in the attribute 'name' of the tag 'input') // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') std::string meshFileName=bbGetInputMesh(); printf("EED AddMesh::Process meshFileName=%s\n",meshFileName.c_str()); bool ok=true; FILE *ff = fopen( bbGetInputMesh().c_str(), "r" ); char strtmp[255]; long int numberPoints; if (ff==NULL) { ok=false; } else { fgets(strtmp,255,ff); fgets(strtmp,255,ff); fgets(strtmp,255,ff); fgets(strtmp,255,ff); fscanf(ff,"%s %ld", strtmp,&numberPoints ); if (numberPoints==0) { ok=false; } fclose(ff); } Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetInputViewerWt(); char strPointer[15]; sprintf(strPointer,"%p",this); std::string mMesh = w->jsRef() + ".mMesh"+strPointer; std::string mRemoveActor= w->jsRef() + ".mRemoveActor"+strPointer; std::string mRenderer = w->jsRef() + ".mRenderer"; if (ok==false) { ok=false; meshFileName="imagesTMP/bunny.vtk"; } /* mMesh.transform.translateX(88.9);\ mMesh.transform.translateY(102.9);\ mMesh.transform.rotateZ(180);\ */ /* " + mCont+" = false;\ "+mRenderer+".onShowtime = function()\ {\ if(!" + mCont +")\ {\ " + mMesh+".visible = true;\ " + mCont+" = true;\ }\ };\ */ if (ok==true) { std::string jsCom = "\ try\ {\ if ("+mRemoveActor+"==true){ " + mRenderer+".add( " + mMesh+"); } \ " + mMesh+".transform.matrix.identity;\ " + mMesh+".transform.translateX(88.9);\ " + mMesh+".transform.translateY(102.9);\ " + mMesh+".transform.rotateZ(180);\ " + mMesh+".opacity = 1;\ " + mMesh+".file = '"+meshFileName+"';\ " + mMesh+".modified(true);\ " + mMesh+".color = [0,1,1];\ " + mRenderer+".render();\ } catch(err) {\ var mMesh = new X.mesh();\ " + mMesh+" = mMesh;\ mMesh.file = '"+meshFileName+"';\ mMesh.color = [1,1,0];\ mMesh.opacity=0.5;\ mMesh.transform.matrix.makeOrtho;\ "+mRemoveActor+" = false;\ "+mRenderer+".add("+mMesh+");\ "+mRenderer+".render();\ }"; // std::cout<<"DEBUG ADD OBJECT ---- "<doJavaScript(jsCom); Wt::WApplication::instance()->doJavaScript(jsCom); } else { std::string jsCom = "\ try\ {\ "+mRenderer+".remove("+mMesh+");\ "+mRemoveActor+"=true;\ } catch(err) {\ }"; Wt::WApplication::instance()->doJavaScript(jsCom); }// ok } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void AddMesh::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputMesh(""); bbSetInputViewerWt(NULL); } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void AddMesh::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void AddMesh::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbwt