From bbe3877673ca24b500731cf15190b1ee59317fc6 Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de> Date: Wed, 5 Apr 2017 18:05:54 +0200 Subject: [PATCH] Remove `dele`, `deln`, `find` and `select` commands --- ui/commands.cc | 471 ------------------------------------------------ ui/commands.doc | 88 --------- 2 files changed, 559 deletions(-) diff --git a/ui/commands.cc b/ui/commands.cc index 29cafcca0..6898717fd 100644 --- a/ui/commands.cc +++ b/ui/commands.cc @@ -2847,67 +2847,6 @@ Exit_gn: } -/** \brief Implementation of \ref deln. */ -static INT DeleteNodeCommand (INT argc, char **argv) -{ - MULTIGRID *theMG; - INT sopt,i; - - /* following variables: keep type for sscanf */ - int id; - - theMG = currMG; - if (theMG==NULL) - { - PrintErrorMessage('E',"deln","no open multigrid"); - return (CMDERRORCODE); - } - - /* check options */ - sopt = false; - for (i=1; i<argc; i++) - switch (argv[i][0]) - { - case 's' : - sopt = true; - break; - - default : - PrintErrorMessageF('E', "DeleteNodeCommand", "Unknown option '%s'", argv[i]); - return (PARAMERRORCODE); - } - - if (sopt) - { - if (SELECTIONMODE(theMG)==nodeSelection) - for (i=0; i<SELECTIONSIZE(theMG); i++) - if (DeleteNode(GRID_ON_LEVEL(theMG,0),(NODE *)SELECTIONOBJECT(theMG,i))!=GM_OK) - { - PrintErrorMessage('E',"deln","deleting the node failed"); - return (CMDERRORCODE); - } - ClearSelection(theMG); - - return (OKCODE); - } - - if (sscanf(argv[0],"deln %d",&id)!=1) - { - PrintErrorMessage('E',"deln","specify the ID of the node to be deleted"); - return (PARAMERRORCODE); - } - - /* NB: toplevel=0 is checked by DeleteNode() */ - if (DeleteNodeWithID(GRID_ON_LEVEL(theMG,0),id)!=GM_OK) - { - PrintErrorMessage('E',"deln","deleting the node failed"); - return (CMDERRORCODE); - } - - return (OKCODE); -} - - /** \brief Implementation of \ref move. */ static INT MoveNodeCommand (INT argc, char **argv) { @@ -3261,67 +3200,6 @@ NEXTTOKEN: } -/** \brief Implementation of \ref dele. */ -static INT DeleteElementCommand (INT argc, char **argv) -{ - MULTIGRID *theMG; - INT i,sopt; - - /* following variables: keep type for sscanf */ - int id; - - theMG = currMG; - if (theMG==NULL) - { - PrintErrorMessage('E',"dele","no open multigrid"); - return (CMDERRORCODE); - } - - /* check options */ - sopt = false; - for (i=1; i<argc; i++) - switch (argv[i][0]) - { - case 's' : - sopt = true; - break; - - default : - PrintErrorMessageF('E', "DeleteElementCommand", "Unknown option '%s'", argv[i]); - return (PARAMERRORCODE); - } - - if (sopt) - { - if (SELECTIONMODE(theMG)==elementSelection) - for (i=0; i<SELECTIONSIZE(theMG); i++) - if (DeleteElement(theMG,(ELEMENT *)SELECTIONOBJECT(theMG,i))!=GM_OK) - { - PrintErrorMessage('E',"dele","deleting the element failed"); - return (CMDERRORCODE); - } - ClearSelection(theMG); - - return (OKCODE); - } - - if (sscanf(argv[0],"dele %d",&id)!=1) - { - PrintErrorMessage('E',"dele","specify the ID of the element to be deleted"); - return (PARAMERRORCODE); - } - - /* NB: toplevel=0 is checked by DeleteElement() */ - if (DeleteElementWithID(theMG,id)!=GM_OK) - { - PrintErrorMessage('E',"dele","deleting the element failed"); - return (CMDERRORCODE); - } - - return (OKCODE); -} - - /** \brief Implementation of \ref adapt. */ static INT AdaptCommand (INT argc, char **argv) { @@ -4588,351 +4466,6 @@ static INT SetIndexCommand (INT argc, char **argv) } -/** \brief Implementation of \ref find. */ -static INT FindCommand (INT argc, char **argv) -{ - MULTIGRID *theMG; - GRID *theGrid; - NODE *theNode; - VECTOR *theVector; - ELEMENT *theElement; - DOUBLE xc[DIM],tolc[DIM]; - INT i,j,select,isNode,isElement,isVector; - - /* following variables: keep type for sscanf */ - double x[DIM_MAX],tol; - - theMG = currMG; - if (theMG==NULL) - { - PrintErrorMessage('E',"find","no open multigrid"); - return (CMDERRORCODE); - } - theGrid = GRID_ON_LEVEL(theMG,CURRENTLEVEL(theMG)); - - /* check pararmeters */ - if (sscanf(argv[0],"find %lf %lf %lf",x,x+1,x+2)!=DIM) - { - PrintErrorMessage('E', "FindCommand", "could not get coordinates"); - return (PARAMERRORCODE); - } - for (i=0; i<DIM; i++) - xc[i] = x[i]; - - /* check options */ - select = isNode = isElement = isVector = false; - for (i=1; i<argc; i++) - switch (argv[i][0]) - { - case 'n' : - if (sscanf(argv[i],"n %lf",&tol)!=1) - { - PrintErrorMessage('E', "FindCommand", "could not read tolerance"); - return (PARAMERRORCODE); - } - for (j=0; j<DIM; j++) - tolc[j] = tol; - theNode = FindNodeFromPosition(theGrid,xc,tolc); - if (theNode==NULL) - { - PrintErrorMessage('W',"find","no node is matching"); - return (CMDERRORCODE); - } - isNode = true; - break; - - case 'v' : - if (sscanf(argv[i],"v %lf",&tol)!=1) - { - PrintErrorMessage('E', "FindCommand", "could not read tolerance"); - return (PARAMERRORCODE); - } - for (j=0; j<DIM; j++) - tolc[j] = tol; - theVector = FindVectorFromPosition(theGrid,xc,tolc); - if (theVector==NULL) - { - PrintErrorMessage('W',"find","no vector is matching"); - return (CMDERRORCODE); - } - isVector = true; - break; - - case 'e' : - theElement = FindElementFromPosition(theGrid,xc); - if (theElement==NULL) - { - PrintErrorMessage('W',"find","no element is matching"); - return (CMDERRORCODE); - } - isElement = true; - break; - - case 's' : - select = true; - break; - - default : - PrintErrorMessageF('E', "FindCommand", "Unknown option '%s'", argv[i]); - return (PARAMERRORCODE); - } - - if (select) - { - if (isNode) - if (AddNodeToSelection(theMG,theNode)!=GM_OK) - { - PrintErrorMessage('E',"find","selecting the node failed"); - return (CMDERRORCODE); - } - - if (isVector) - if (AddVectorToSelection(theMG,theVector)!=GM_OK) - { - PrintErrorMessage('E',"find","selecting the vector failed"); - return (CMDERRORCODE); - } - - if (isElement) - if (AddElementToSelection(theMG,theElement)!=GM_OK) - { - PrintErrorMessage('E',"find","selecting the element failed"); - return (CMDERRORCODE); - } - } - else - { - if (isNode) - ListNode(theMG,theNode,false,false,false,false); - - if (isVector) - ListVector(theMG,theVector,false,false,LV_MOD_DEFAULT); - - if (isElement) - ListElement(theMG,theElement,false,false,false,false); - } - - return (OKCODE); -} - - -/** \brief Implementation of \ref select. */ -static INT SelectCommand (INT argc, char **argv) -{ - MULTIGRID *theMG; - NODE *theNode; - ELEMENT *theElement; - VECTOR *theVector; - INT i,level; - char c; - - /* following variables: keep type for sscanf */ - int id; - - #ifdef ModelP - if (!CONTEXT(me)) { - PRINTDEBUG(ui,0,("%2d: SelectCommand(): me not in Context," \ - " no selection of elements\n",me)) - return(OKCODE); - } - #endif - - theMG = currMG; - if (theMG==NULL) - { - PrintErrorMessage('E',"select","no open multigrid"); - return (CMDERRORCODE); - } - - /* check options */ - for (i=1; i<argc; i++) - switch (argv[i][0]) - { - case 'c' : - ClearSelection(theMG); - break; - - case 'n' : - if (sscanf(argv[i],"n %c %d",&c,&id)!=2) - { - PrintErrorMessage('E',"select","could not get +/- or ID"); - return (PARAMERRORCODE); - } - if (c=='+') - { - /* search node */ - theNode = NULL; - for (level=0; level<=TOPLEVEL(theMG); level++) - if ((theNode=FindNodeFromId(GRID_ON_LEVEL(theMG,level),id))!=NULL) - break; - if (theNode==NULL) - { - PrintErrorMessageF('E',"select","node with ID %ld not found",(long)id); - return (CMDERRORCODE); - } - if (AddNodeToSelection(theMG,theNode)!=GM_OK) - { - PrintErrorMessage('E',"select","selecting the node failed"); - return (CMDERRORCODE); - } - } - else if (c=='-') - { - if (SELECTIONMODE(theMG)==nodeSelection) - for (i=0; i<SELECTIONSIZE(theMG); i++) - { - theNode = (NODE *)SELECTIONOBJECT(theMG,i); - if (ID(theNode)==id) - break; - } - if (theNode==NULL) - { - PrintErrorMessageF('E',"select","node with ID %ld is not in selection",(long)id); - return (CMDERRORCODE); - } - if (RemoveNodeFromSelection(theMG,theNode)!=GM_OK) - { - PrintErrorMessage('E',"select","removing the node failed"); - return (CMDERRORCODE); - } - } - else - { - PrintErrorMessage('E',"select","specify + or - with n option"); - return (PARAMERRORCODE); - } - break; - - case 'e' : - if (sscanf(argv[i],"e %c %d",&c,&id)!=2) - { - PrintErrorMessage('E',"select","could not get +/- or ID"); - return (PARAMERRORCODE); - } - if (c=='+') - { - /* search element */ - theElement = NULL; - for (level=0; level<=TOPLEVEL(theMG); level++) - if ((theElement=FindElementFromId(GRID_ON_LEVEL(theMG,level),id))!=NULL) - break; - if (theElement==NULL) - { - PrintErrorMessageF('E',"select","element with ID %ld not found",(long)id); - return (CMDERRORCODE); - } - if (AddElementToSelection(theMG,theElement)!=GM_OK) - { - PrintErrorMessage('E',"select","selecting the element failed"); - return (CMDERRORCODE); - } - } - else if (c=='-') - { - if (SELECTIONMODE(theMG)==elementSelection) - for (i=0; i<SELECTIONSIZE(theMG); i++) - { - theElement = (ELEMENT *)SELECTIONOBJECT(theMG,i); - if (ID(theElement)==id) - break; - } - if (theElement==NULL) - { - PrintErrorMessageF('E',"select","element with ID %ld is not in selection",(long)id); - return (CMDERRORCODE); - } - if (RemoveElementFromSelection(theMG,theElement)!=GM_OK) - { - PrintErrorMessage('E',"select","removing the element failed"); - return (CMDERRORCODE); - } - } - else - { - PrintErrorMessage('E',"select","specify + or - with n option"); - return (PARAMERRORCODE); - } - break; - - case 'v' : - if (sscanf(argv[i],"v %c %d",&c,&id)!=2) - { - PrintErrorMessage('E',"select","could not get +/- or ID"); - return (PARAMERRORCODE); - } - if (c=='+') - { - /* search vector */ - theVector = NULL; - for (level=0; level<=TOPLEVEL(theMG); level++) - if ((theVector=FindVectorFromIndex(GRID_ON_LEVEL(theMG,level),id))!=NULL) - break; - if (theVector==NULL) - { - PrintErrorMessageF('E',"select","vector with ID %ld not found",(long)id); - return (CMDERRORCODE); - } - if (AddVectorToSelection(theMG,theVector)!=GM_OK) - { - PrintErrorMessage('E',"select","selecting the vector failed"); - return (CMDERRORCODE); - } - } - else if (c=='-') - { - if (SELECTIONMODE(theMG)==vectorSelection) - for (i=0; i<SELECTIONSIZE(theMG); i++) - { - theVector = (VECTOR *)SELECTIONOBJECT(theMG,i); - if (ID(theVector)==id) - break; - } - if (theVector==NULL) - { - PrintErrorMessageF('E',"select","vector with ID %ld is not in selection",(long)id); - return (CMDERRORCODE); - } - if (RemoveVectorFromSelection(theMG,theVector)!=GM_OK) - { - PrintErrorMessage('E',"select","removing the vector failed"); - return (CMDERRORCODE); - } - } - else - { - PrintErrorMessage('E',"select","specify + or - with n option"); - return (PARAMERRORCODE); - } - break; - - case 'i' : - if (SELECTIONSIZE(theMG)==0) - UserWrite("nothing selected\n"); - else switch (SELECTIONMODE(theMG)) - { - case elementSelection : - UserWriteF("%d elements selected (use for example 'elist $s')\n",SELECTIONSIZE(theMG)); - break; - case nodeSelection : - UserWriteF("%d nodes selected (use for example 'nlist $s')\n",SELECTIONSIZE(theMG)); - break; - case vectorSelection : - UserWriteF("%d vectors selected (use for example 'vmlist $s')\n",SELECTIONSIZE(theMG)); - break; - default : - UserWrite("unknown selection type\n"); - } - break; - - default : - PrintErrorMessageF('E', "SelectCommand", "Unknown option '%s'", argv[i]); - return (PARAMERRORCODE); - } - - return (OKCODE); -} - - /** \brief Implementation of \ref extracon. */ static INT ExtraConnectionCommand (INT argc, char **argv) { @@ -6506,18 +6039,14 @@ INT NS_DIM_PREFIX InitCommands () if (CreateCommand("bn", InsertBoundaryNodeCommand )==NULL) return (__LINE__); if (CreateCommand("ngbn", NGInsertBoundaryNodeCommand )==NULL) return (__LINE__); if (CreateCommand("gn", InsertGlobalNodeCommand )==NULL) return (__LINE__); - if (CreateCommand("deln", DeleteNodeCommand )==NULL) return (__LINE__); if (CreateCommand("move", MoveNodeCommand )==NULL) return (__LINE__); if (CreateCommand("ie", InsertElementCommand )==NULL) return (__LINE__); if (CreateCommand("ngie", NGInsertElementCommand )==NULL) return (__LINE__); - if (CreateCommand("dele", DeleteElementCommand )==NULL) return (__LINE__); if (CreateCommand("refine", AdaptCommand )==NULL) return (__LINE__); if (CreateCommand("adapt", AdaptCommand )==NULL) return (__LINE__); if (CreateCommand("fixcoarsegrid", FixCoarseGridCommand )==NULL) return (__LINE__); if (CreateCommand("collapse", CollapseCommand )==NULL) return (__LINE__); if (CreateCommand("mark", MarkCommand )==NULL) return (__LINE__); - if (CreateCommand("find", FindCommand )==NULL) return (__LINE__); - if (CreateCommand("select", SelectCommand )==NULL) return (__LINE__); if (CreateCommand("mglist", MGListCommand )==NULL) return (__LINE__); if (CreateCommand("glist", GListCommand )==NULL) return (__LINE__); if (CreateCommand("nlist", NListCommand )==NULL) return (__LINE__); diff --git a/ui/commands.doc b/ui/commands.doc index 1b2cc7357..8f33a0e26 100644 --- a/ui/commands.doc +++ b/ui/commands.doc @@ -910,24 +910,6 @@ freeaverage $nv uwTrans $s sol $nv unTrans $s sol; */ /****************************************************************************/ -/****************************************************************************/ -/** \page deln deln - Delete a node and vertex - - \section Description - This command deletes a node and the corresponding vertex - of the current multigrid, calling the function 'DeleteNode'. - -\section Syntax - 'deln \<Id> | $s' - - <li> \<Id> - ID of the node to be deleted - <li> $s - delete ALL nodes from the selection - - \section Keywords - multigrid, delete, remove, node, edit -*/ -/****************************************************************************/ - /****************************************************************************/ /** \page move move - Move a node and vertex @@ -968,24 +950,6 @@ freeaverage $nv uwTrans $s sol $nv unTrans $s sol; */ /****************************************************************************/ -/****************************************************************************/ -/** \page dele dele - Delete an element - - \section Description - This command deletes the specified element of a multigrid - with only level 0, calling the function 'DeleteElement'. - -\section Syntax - 'dele \<Id> | $s' - - <li> \<Id> - ID of the element to be deleted - <li> $s - delete all elements from the selection - - \section Keywords - multigrid, delete, remove, element, edit -*/ -/****************************************************************************/ - /****************************************************************************/ /** \page adapt adapt - Adapt the current multigrid @@ -1220,58 +1184,6 @@ freeaverage $nv uwTrans $s sol $nv unTrans $s sol; */ /****************************************************************************/ -/****************************************************************************/ -/** \page find find - Find (and select) a node (element) from a given position - - \section Description - This function finds (and selects) a node (element) from a given position, - where some tolerance can be specified. - It finds a node (element) on the current level of the current multigrid, - using the functions - 'FindNodeFromPosition', 'FindElementFromPosition' - 'AddNodeToSelection', 'RemoveNodeFromSelection', - 'AddElementToSelection' and 'RemoveElementFromSelection' - -\section Syntax - find \<x> \<y> \<z> {$n \<tol> | $v \<tol> | $e} [$s] - - <li> \<x> \<y> \<z> - specify as much coordinates as the space has dimensions - <li> $n \<tol> - find a node maching the position with tolerance \<tol> - <li> $v \<tol> - find a vector maching the position with tolerance \<tol> - <li> $e - find an element maching the position - <li> $s - add the selected node (element) to the selection buffer - (if not specified the node is just listed) - - \section Keywords - multigrid, node, element, position, find, select -*/ -/****************************************************************************/ - -/****************************************************************************/ -/** \page select select - Select a node or element from a given position - - \section Description - This function finds (and selects) a node (element) from a given position, - where some tolerance can be specified. - It adds/removes nodes/elements from the selection buffer of the current - multigrid, using the functions - 'FindNodeFromId', 'FindElementFromId' - 'AddNodeToSelection', 'RemoveNodeFromSelection', - 'AddElementToSelection' and 'RemoveElementFromSelection' - -\section Syntax - 'select $i | $c | $n {+|-} \<Id> | $e {+|-} \<Id>' - - <li> $i - print type and number of list members - <li> $c - clear the selection buffer - <li> $n~{+|-}~\<Id> - add (+) or remove (-) the node with \<Id> to (from) the selection buffer - <li> $e~{+|-}~\<Id> - add (+) or remove (-) the element with \<Id> to (from) the selection buffer - - \section Keywords - multigrid, select, element, node -*/ -/****************************************************************************/ - /****************************************************************************/ /** \page extracon extracon - Display number of (and delete) extra connections -- GitLab