Changeset f5a3167 in git for kernel/gfan.cc
- Timestamp:
- Nov 24, 2009, 3:47:08 PM (14 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 6d0c34789bdabdaacd82a5c41c3c7fca1d2eb99e
- Parents:
- 38f763ebc0e6bb2edf001bab9337f25e3968589e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r38f763 rf5a3167 123 123 124 124 /** \brief The copy constructor 125 * By default only copies the fNormal, f2Normals and UCN 125 126 */ 126 127 facet::facet(const facet& f) 127 128 { 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 } 148 155 } 149 156 … … 173 180 174 181 /** \brief Comparison of facets*/ 175 bool facet::areEqual(facet &f, facet &g)182 bool gcone::areEqual(facet *f, facet *s) 176 183 { 177 184 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) 193 206 { 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; 211 218 else 212 { 213 res = FALSE; 214 } 219 res=FALSE; 215 220 return res; 216 } 221 } 217 222 218 223 /** Stores the facet normal \param intvec*/ … … 2038 2043 if(slAct==NULL) 2039 2044 { 2040 slAct = new facet( );2045 slAct = new facet(*fCopy); 2041 2046 slHead = slAct; 2042 2047 } 2043 2048 else 2044 2049 { 2045 slAct->next = new facet( );2050 slAct->next = new facet(*fCopy); 2046 2051 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 else2062 {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;2072 2052 } 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 // } 2073 2079 fCopy = fCopy->next; 2074 2080 } … … 2092 2098 slNormal->show(1,1); 2093 2099 cout << ")" << endl; 2094 #endif 2095 if(!isParallel(fNormal, slNormal))2100 #endif 2101 if(areEqual(fAct,slAct)) 2096 2102 { 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) 2105 2104 { 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) 2119 2111 { 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 2169 2117 { 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 2178 2126 slAct = slAct->next; 2179 2127 /* NOTE The following lines must not be here but rather called inside the if-block above. … … 2181 2129 (not nice!) but since they are in seperate branches of the if-statement there should not 2182 2130 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 } 2186 2137 //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) ) 2189 2141 //if( (notParallelCtr==lengthOfSearchList ) || doNotAdd==FALSE ) 2190 2142 {
Note: See TracChangeset
for help on using the changeset viewer.