00001 /* 00002 PROJETO USPDesigner 00003 MODULO: LOW (Operadores Basicos) 00004 Copyright (C) 1989 a 2008, Marcos Tsuzuki, All rights reserved 00005 Universidade de Sao Paulo, EPUSP-PMR 00006 00007 NOME DO ARQUIVO: lowaddhe.cpp 00008 Coded by Marcos Tsuzuki 00009 00010 Redistribution and use in source and binary forms, with or without 00011 modification, are permitted provided that the following conditions 00012 are met: 00013 00014 1. Redistributions of source code must retain the above copyright 00015 notice, this list of conditions and the following disclaimer. 00016 00017 2. Redistributions in binary form must reproduce the above copyright 00018 notice, this list of conditions and the following disclaimer in the 00019 documentation and/or other materials provided with the distribution. 00020 00021 3. The names of its contributors may not be used to endorse or promote 00022 products derived from this software without specific prior written 00023 permission. 00024 00025 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00026 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00027 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00028 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00029 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 00037 00038 Any feedback is very welcome. 00039 email: mtsuzuki at usp.br (remove space) 00040 */ 00041 #include <stdio.h> 00042 #include "memvirtu.h" 00043 #include "lowparam.h" 00044 #include "lowsolid.h" 00045 00046 /* In the implementation of the allocator, the actual initialization */ 00047 /* of halfedges and edges is performed by procedure addhe. The procedure */ 00048 /* allocates a new halfedge, links it into loop l at the front of an */ 00049 /* existing halfedge where, and sets the outer pointers appropriately. */ 00050 /* Note that addhe is written so as to handle the special cases of an */ 00051 /* empty original loop (where->edg == NIL) or no loop at all (where == */ 00052 /* NIL). */ 00053 /* The inverse procedure delhe performs the opposite actions. Note in */ 00054 /* particular how it creates an "empty" loop in the case that he->edg != */ 00055 /* NIL and he->nxt == he. */ 00056 /* Algorithms of ESM (Educational Solid Modeler) will do the bulk of */ 00057 /* their work with Euler Operators. Occasionally, however, they will also*/ 00058 /* use some of the functions described above. For instance, the */ 00059 /* sectioning algorithm will use new, addlist and dellist to actually */ 00060 /* divide the sectioned solid. */ 00061 00062 HPTYPE MSD_lowAddHE(EPTYPE e, VPTYPE v, HPTYPE where, int orient) 00063 { 00064 HPTYPE he; 00065 00066 if (HalEdg(where) == ENIL) 00067 { 00068 he = where; 00069 } 00070 else 00071 { 00072 if ((he = (HPTYPE)MSD_lowNewElement(HALFEDGE, NNIL)) == HNIL) 00073 { 00074 return(HNIL); 00075 } 00076 HalNxt(HalPrv(where)) = he; 00077 HalPrv(he) = HalPrv(where); 00078 HalPrv(where) = he; 00079 HalNxt(he) = where; 00080 } 00081 HalEdg(he) = e; 00082 HalVtx(he) = v; 00083 HalWLoop(he) = HalWLoop(where); 00084 00085 if (orient == PLUS) 00086 { 00087 EdgHe1(e) = he; 00088 } 00089 else 00090 { 00091 EdgHe2(e) = he; 00092 } 00093 return(he); 00094 } 00095 00096 HPTYPE MSD_lowDelHE(HPTYPE he) 00097 { 00098 HPTYPE hhe; 00099 00100 if (HalEdg(he) == ENIL) 00101 { 00102 MSD_lowDelElement(HALFEDGE, (NPTYPE)he, NNIL); 00103 return(HNIL); 00104 } 00105 if (HalNxt(he) == he) 00106 { 00107 HalEdg(he) = ENIL; 00108 return(he); 00109 } 00110 hhe = HalPrv(he); 00111 HalNxt(HalPrv(he)) = HalNxt(he); 00112 HalPrv(HalNxt(he)) = HalPrv(he); /****************** 01/03/95 */ 00113 MSD_lowDelElement(HALFEDGE, (NPTYPE)he, NNIL); 00114 return(hhe); 00115 }