Changeset f5a3167 in git


Ignore:
Timestamp:
Nov 24, 2009, 3:47:08 PM (14 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
6d0c34789bdabdaacd82a5c41c3c7fca1d2eb99e
Parents:
38f763ebc0e6bb2edf001bab9337f25e3968589e
Message:
facet copy constructor
used in enqueue
facet::areEqual is now of class gcone but still compares facets
Cleanup in enqueue


git-svn-id: file:///usr/local/Singular/svn/trunk@12322 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r38f763 rf5a3167  
    123123               
    124124/** \brief The copy constructor
     125* By default only copies the fNormal, f2Normals and UCN
    125126*/
    126127facet::facet(const facet& f)
    127128{
    128 //      this->setFacetNormal(f.getFacetNormal());
    129 //      this->setUCN(f.getUCN());
    130 //      this->isFlippable=f.isFlippable;
    131 //      facet* f2Copy;
    132 //      f2Copy=f.codim2Ptr;
    133 //      facet* f2Act;
    134 //      f2Act=this->codim2Ptr;
    135 //      while(f2Copy!=NULL)
    136 //      {
    137 //              if(f2Act==NULL)
    138 //              {
    139 //                      f2Act=new facet(2);                     
    140 //              }
    141 //              else
    142 //              {
    143 //                      f2Act->next = new facet(2);
    144 //              }
    145 //              f2Act->setFacetNormal(f2Copy->getFacetNormal());
    146 //              f2Copy = f2Copy->next;
    147 //      }
     129        this->fNormal=ivCopy(f.fNormal);
     130        this->UCN=f.UCN;
     131        this->isFlippable=f.isFlippable;
     132        facet* f2Copy;
     133        f2Copy=f.codim2Ptr;
     134        facet* f2Act;
     135        f2Act=this->codim2Ptr;
     136        while(f2Copy!=NULL)
     137        {
     138                if(f2Act==NULL)
     139                {
     140                        f2Act=new facet(2);
     141                        this->codim2Ptr=f2Act;                 
     142                }
     143                else
     144                {
     145                        facet* marker;
     146                        marker = f2Act;
     147                        f2Act->next = new facet(2);
     148                        f2Act = f2Act->next;
     149                        f2Act->prev = marker;
     150                }
     151                f2Act->setFacetNormal(f2Copy->getFacetNormal());
     152                f2Act->setUCN(f2Copy->getUCN());
     153                f2Copy = f2Copy->next;
     154        }       
    148155}
    149156               
     
    173180               
    174181/** \brief Comparison of facets*/
    175 bool facet::areEqual(facet &f, facet &g)
     182bool gcone::areEqual(facet *f, facet *s)
    176183{
    177184        bool res = TRUE;
    178         intvec *fNormal = new intvec(pVariables);
    179         intvec *gNormal = new intvec(pVariables);
    180         fNormal = f.getFacetNormal();
    181         gNormal = g.getFacetNormal();
    182         if((fNormal == gNormal))//||(gcone::isParallel(fNormal,gNormal)))
    183         {
    184                 if(f.numCodim2Facets==g.numCodim2Facets)
    185                 {
    186                         facet *f2Act;
    187                         facet *g2Act;
    188                         f2Act = f.codim2Ptr;
    189                         g2Act = g.codim2Ptr;
    190                         intvec *f2N = new intvec(pVariables);
    191                         intvec *g2N = new intvec(pVariables);
    192                         while(f2Act->next!=NULL && g2Act->next!=NULL)
     185        int notParallelCtr=0;
     186        int ctr=0;
     187        intvec* fNormal;// = new intvec(pVariables);
     188        intvec* sNormal;// = new intvec(pVariables);
     189        fNormal = f->getFacetNormal();
     190        sNormal = s->getFacetNormal();
     191        if(!isParallel(fNormal,sNormal))
     192                notParallelCtr++;
     193        else//parallelity, so we check the codim2-facets
     194        {
     195                facet* f2Act;
     196                facet* s2Act;
     197                f2Act = f->codim2Ptr;
     198                intvec* f2Normal;
     199                intvec* s2Normal;
     200                ctr=0;
     201                while(f2Act!=NULL)
     202                {
     203                        f2Normal = f2Act->getFacetNormal();
     204                        s2Act = s->codim2Ptr;
     205                        while(s2Act!=NULL)
    193206                        {
    194                                 for(int ii=0;ii<f2N->length();ii++)
    195                                 {
    196                                         if(f2Act->getFacetNormal() != g2Act->getFacetNormal())
    197                                         {
    198                                                 res=FALSE;                                                             
    199                                         }
    200                                         if (res==FALSE)
    201                                                 break;
    202                                 }
    203                                 if(res==FALSE)
    204                                         break;
    205                                
    206                                 f2Act = f2Act->next;
    207                                 g2Act = g2Act->next;
    208                         }//while
    209                 }//if           
    210         }//if
     207                                s2Normal = s2Act->getFacetNormal();
     208                                bool foo=areEqual(f2Normal,s2Normal);
     209                                if(foo)
     210                                        ctr++;
     211                                s2Act = s2Act->next;                                                                           
     212                        }
     213                        f2Act = f2Act->next;
     214                }
     215        }
     216        if(ctr==f->numCodim2Facets)
     217                res=TRUE;
    211218        else
    212         {
    213                 res = FALSE;
    214         }
     219                res=FALSE;                             
    215220        return res;
    216 }
     221}       
    217222               
    218223/** Stores the facet normal \param intvec*/
     
    20382043                                        if(slAct==NULL)
    20392044                                        {
    2040                                                 slAct = new facet();
     2045                                                slAct = new facet(*fCopy);
    20412046                                                slHead = slAct;                                                         
    20422047                                        }
    20432048                                        else
    20442049                                        {
    2045                                                 slAct->next = new facet();
     2050                                                slAct->next = new facet(*fCopy);
    20462051                                                slAct = slAct->next;
    2047                                         }                                                       
    2048                                         slAct->setFacetNormal(fAct->getFacetNormal());
    2049                                         slAct->setUCN(fAct->getUCN());
    2050                                         slAct->isFlippable=fAct->isFlippable;
    2051                                         facet *f2Copy;
    2052                                         f2Copy = fCopy->codim2Ptr;
    2053                                         sl2Act = slAct->codim2Ptr;
    2054                                         while(f2Copy!=NULL)
    2055                                         {
    2056                                                 if(sl2Act==NULL)
    2057                                                 {
    2058                                                         sl2Act = new facet(2);
    2059                                                         slAct->codim2Ptr = sl2Act;                                     
    2060                                                 }
    2061                                                 else
    2062                                                 {
    2063                                                         facet *marker;
    2064                                                         marker = sl2Act;
    2065                                                         sl2Act->next = new facet(2);
    2066                                                         sl2Act = sl2Act->next;
    2067                                                         sl2Act->prev = marker;
    2068                                                 }
    2069                                                 sl2Act->setFacetNormal(f2Copy->getFacetNormal());
    2070                                                 sl2Act->setUCN(f2Copy->getUCN());
    2071                                                 f2Copy = f2Copy->next;
    20722052                                        }
     2053                                        //NOTE Below went into copy constructor                                                 
     2054//                                      slAct->setFacetNormal(fAct->getFacetNormal());
     2055//                                      slAct->setUCN(fAct->getUCN());
     2056//                                      slAct->isFlippable=fAct->isFlippable;
     2057//                                      facet *f2Copy;
     2058//                                      f2Copy = fCopy->codim2Ptr;
     2059//                                      sl2Act = slAct->codim2Ptr;
     2060//                                      while(f2Copy!=NULL)
     2061//                                      {
     2062//                                              if(sl2Act==NULL)
     2063//                                              {
     2064//                                                      sl2Act = new facet(2);
     2065//                                                      slAct->codim2Ptr = sl2Act;                                     
     2066//                                              }
     2067//                                              else
     2068//                                              {
     2069//                                                      facet *marker;
     2070//                                                      marker = sl2Act;
     2071//                                                      sl2Act->next = new facet(2);
     2072//                                                      sl2Act = sl2Act->next;
     2073//                                                      sl2Act->prev = marker;
     2074//                                              }
     2075//                                              sl2Act->setFacetNormal(f2Copy->getFacetNormal());
     2076//                                              sl2Act->setUCN(f2Copy->getUCN());
     2077//                                              f2Copy = f2Copy->next;
     2078//                                      }
    20732079                                        fCopy = fCopy->next;
    20742080                                }
     
    20922098                                slNormal->show(1,1);
    20932099                                cout << ")" << endl;
    2094 #endif
    2095                                 if(!isParallel(fNormal, slNormal))
     2100#endif                         
     2101                                if(areEqual(fAct,slAct))
    20962102                                {
    2097                                         notParallelCtr++;
    2098                                 }
    2099                                 else    //fN and slN are parallel
    2100                                 {
    2101                                         //We check whether the codim-2-facets coincide
    2102                                         codim2Act = fAct->codim2Ptr;
    2103                                         ctr=0;
    2104                                         while(codim2Act!=NULL)
     2103                                        if(slAct==slHead)
    21052104                                        {
    2106                                                 f2Normal = codim2Act->getFacetNormal();
    2107                                                                 //sl2Act = f.codim2Ptr;
    2108                                                 sl2Act = slAct->codim2Ptr;
    2109                                                 while(sl2Act!=NULL)
    2110                                                 {
    2111                                                         sl2Normal = sl2Act->getFacetNormal();
    2112                                                         if(areEqual(f2Normal, sl2Normal))
    2113                                                                 ctr++;
    2114                                                         sl2Act = sl2Act->next;
    2115                                                 }//while(sl2Act!=NULL)
    2116                                                 codim2Act = codim2Act->next;
    2117                                         }//while(codim2Act!=NULL)
    2118                                         if(ctr==fAct->numCodim2Facets)  //facets ARE equal
     2105                                                deleteMarker = slAct;                           
     2106                                                slHead = slAct->next;                                           
     2107                                                if(slHead!=NULL)
     2108                                                        slHead->prev = NULL;
     2109                                        }
     2110                                        else if (slAct==slEnd)
    21192111                                        {
    2120 #ifdef gfan_DEBUG
    2121                                                 cout << "Removing facet (";
    2122                                                 slNormal->show(1,0);
    2123                                                 cout << ") from SLA:" << endl;
    2124                                                 fAct->fDebugPrint();
    2125                                                 slAct->fDebugPrint();
    2126 #endif
    2127                                                 removalOccured=TRUE;
    2128                                                 slAct->isFlippable=FALSE;
    2129                                                 doNotAdd=TRUE;
    2130                                                 maybe=FALSE;                                                           
    2131                                                 if(slAct==slHead)       //We want to delete the first element of SearchList
    2132                                                 {
    2133                                                         deleteMarker = slAct;                           
    2134                                                         slHead = slAct->next;                                           
    2135                                                         if(slHead!=NULL)
    2136                                                                 slHead->prev = NULL;
    2137 //                                                      delete deleteMarker; deleteMarker=NULL;
    2138                                                         //set a bool flag to mark slAct as to be deleted
    2139                                                 }//NOTE find a way to delete without affecting slAct = slAct->next
    2140                                                 else if(slAct==slEndStatic)
    2141                                                 {
    2142                                                         deleteMarker = slAct;                                   
    2143                                                         if(slEndStatic->next==NULL)
    2144                                                         {                                                       
    2145                                                                 slEndStatic = slEndStatic->prev;
    2146                                                                 slEndStatic->next = NULL;
    2147                                                                 slEnd = slEndStatic;
    2148                                                         }
    2149                                                         else    //we already added a facet after slEndStatic
    2150                                                         {
    2151                                                                 slEndStatic->prev->next = slEndStatic->next;
    2152                                                                 slEndStatic->next->prev = slEndStatic->prev;
    2153                                                                 slEndStatic = slEndStatic->prev;
    2154                                                                 //slEnd = slEndStatic;
    2155                                                         }
    2156                                                 }                                                               
    2157                                                 else
    2158                                                 {
    2159                                                         deleteMarker = slAct;
    2160                                                         slAct->prev->next = slAct->next;
    2161                                                         slAct->next->prev = slAct->prev;
    2162                                                 }                                                               
    2163                                                 //update lengthOfSearchList                                     
    2164                                                 lengthOfSearchList--;                                           
    2165                                                 break;
    2166                                         }//if(ctr==fAct->numCodim2Facets)
    2167                                         else    //facets are parallel but NOT equal. But this does not imply that there
    2168                                                 //is no other facet later in SLA that might be equal.
     2112                                                deleteMarker = slAct;
     2113                                                slEnd=slEnd->prev;
     2114                                                slEnd->next = NULL;
     2115                                        }                                                               
     2116                                        else
    21692117                                        {
    2170                                                 maybe=TRUE;//                                                                   
    2171                                         }                                                       
    2172                                 }//if(!isParallel(fNormal, slNormal))
    2173                                 if( (slAct->next==NULL) && (maybe==TRUE) )
    2174                                 {
    2175                                         doNotAdd=FALSE;
    2176                                         break;
    2177                                 }
     2118                                                deleteMarker = slAct;
     2119                                                slAct->prev->next = slAct->next;
     2120                                                slAct->next->prev = slAct->prev;
     2121                                        }
     2122                                        removalOccured=TRUE;
     2123                                        break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
     2124                                }               
     2125                               
    21782126                                slAct = slAct->next;
    21792127                                /* NOTE The following lines must not be here but rather called inside the if-block above.
     
    21812129                                (not nice!) but since they are in seperate branches of the if-statement there should not
    21822130                                be a way it gets called twice thus ommiting one facet:
    2183                                 slAct = slAct->next;*/                                         
    2184 //                                              delete deleteMarker;
    2185 //                                              deleteMarker=NULL;
     2131                                slAct = slAct->next;*/
     2132                                if(deleteMarker!=NULL)
     2133                                {                                               
     2134//                                      delete deleteMarker;
     2135//                                      deleteMarker=NULL;
     2136                                }
    21862137                                                //if slAct was marked as to be deleted, delete it here!
    2187                         }//while(slAct!=NULL)                                                                   
    2188                         if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) || (doNotAdd==FALSE) )
     2138                        }//while(slAct!=NULL)
     2139                        if(removalOccured==FALSE)
     2140//                      if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) || (doNotAdd==FALSE) )
    21892141                                        //if( (notParallelCtr==lengthOfSearchList ) || doNotAdd==FALSE )
    21902142                        {
  • kernel/gfan.h

    r38f763 rf5a3167  
    7979                               
    8080                /** \brief Comparison of facets*/
    81                 bool areEqual(facet &f, facet &g);
     81                bool areEqual(facet *f, facet *g);
    8282                /** Stores the facet normal \param intvec*/
    8383                void setFacetNormal(intvec *iv);
     
    173173                bool isParallel(intvec const &a, intvec const &b);
    174174                bool areEqual(intvec const &a, intvec const &b);
     175                bool areEqual(facet *f, facet *g);
    175176                int intgcd(int a, int b);
    176177                void writeConeToFile(gcone const &gc, bool usingIntPoints=FALSE);
Note: See TracChangeset for help on using the changeset viewer.