Changeset 78dac6 for molecuilder/src/tesselation.cpp
- Timestamp:
- Aug 19, 2009, 2:31:29 PM (16 years ago)
- Children:
- 84b811
- Parents:
- daf5d6
- File:
-
- 1 edited
-
molecuilder/src/tesselation.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
rdaf5d6 r78dac6 16 16 LinesCount = 0; 17 17 Nr = -1; 18 value = 0.; 18 19 }; 19 20 … … 26 27 LinesCount = 0; 27 28 Nr = Walker->nr; 29 value = 0.; 28 30 }; 29 31 … … 148 150 void BoundaryLineSet::AddTriangle(class BoundaryTriangleSet *triangle) 149 151 { 150 cout << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." 151 << endl; 152 cout << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." << endl; 152 153 triangles.insert(TrianglePair(triangle->Nr, triangle)); 153 154 }; … … 177 178 if (triangles.size() != 2) { 178 179 *out << Verbose(1) << "ERROR: Baseline " << *this << " is connect to less than two triangles, Tesselation incomplete!" << endl; 179 return false;180 return true; 180 181 } 181 182 // check normal vectors 182 183 // have a normal vector on the base line pointing outwards 183 *out << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;184 //*out << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl; 184 185 BaseLineCenter.CopyVector(endpoints[0]->node->node); 185 186 BaseLineCenter.AddVector(endpoints[1]->node->node); … … 187 188 BaseLine.CopyVector(endpoints[0]->node->node); 188 189 BaseLine.SubtractVector(endpoints[1]->node->node); 189 *out << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;190 //*out << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl; 190 191 191 192 BaseLineNormal.Zero(); … … 195 196 class BoundaryPointSet *node = NULL; 196 197 for(TriangleMap::iterator runner = triangles.begin(); runner != triangles.end(); runner++) { 197 *out << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;198 //*out << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl; 198 199 NormalCheck.AddVector(&runner->second->NormalVector); 199 200 NormalCheck.Scale(sign); … … 202 203 node = runner->second->GetThirdEndpoint(this); 203 204 if (node != NULL) { 204 *out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;205 //*out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl; 205 206 helper[i].CopyVector(node->node->node); 206 207 helper[i].SubtractVector(&BaseLineCenter); 207 208 helper[i].MakeNormalVector(&BaseLine); // we want to compare the triangle's heights' angles! 208 *out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;209 //*out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl; 209 210 i++; 210 211 } else { 211 *out << Verbose(2) << "WARNING: I cannot find third node in triangle, something's wrong." << endl;212 //*out << Verbose(2) << "WARNING: I cannot find third node in triangle, something's wrong." << endl; 212 213 return true; 213 214 } 214 215 } 215 *out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;216 //*out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl; 216 217 if (NormalCheck.NormSquared() < MYEPSILON) { 217 *out << Verbose( 3) << "Normalvectors of both triangles are the same: convex." << endl;218 *out << Verbose(2) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl; 218 219 return true; 219 220 } 220 221 double angle = getAngle(helper[0], helper[1], BaseLineNormal); 221 if ((angle - M_PI) > -MYEPSILON) 222 if ((angle - M_PI) > -MYEPSILON) { 223 *out << Verbose(2) << "ACCEPT: Angle is greater than pi: convex." << endl; 222 224 return true; 223 else 225 } else { 226 *out << Verbose(2) << "REJECT: Angle is less than pi: concave." << endl; 224 227 return false; 228 } 225 229 } 226 230 … … 1767 1771 1768 1772 // delete the temporary other base line 1769 delete(ClosestPoint);1770 1773 delete(OtherBase); 1771 1774 … … 1780 1783 distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]); 1781 1784 } 1782 if ((distance[0] * distance[1]) > MYEPSILON) { // have same sign? 1783 *out << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << " is concave." << endl; 1785 delete(ClosestPoint); 1786 if ((distance[0] * distance[1]) > 0) { // have same sign? 1787 *out << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl; 1784 1788 if (distance[0] < distance[1]) { 1785 1789 Spot = Base->endpoints[0]; … … 1903 1907 Vector NewOffset; 1904 1908 NewOffset.CopyVector(OtherBase->endpoints[0]->node->node); 1909 NewOffset.SubtractVector(Base->endpoints[0]->node->node); 1905 1910 NewOffset.ProjectOntoPlane(&Normal); 1906 1911 NewOffset.AddVector(Base->endpoints[0]->node->node); 1912 Vector NewDirection; 1913 NewDirection.CopyVector(&NewOffset); 1914 NewDirection.AddVector(&OtherBaseline); 1907 1915 1908 1916 // calculate the intersection between this projected baseline and Base 1909 1917 Vector *Intersection = new Vector; 1910 Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, & OtherBaseline, &Normal);1918 Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &NewDirection, &Normal); 1911 1919 Normal.CopyVector(Intersection); 1912 1920 Normal.SubtractVector(Base->endpoints[0]->node->node); … … 2622 2630 int i; 2623 2631 2632 if (point == NULL) { 2633 *out << Verbose(1) << "ERROR: Cannot remove the point " << point << ", it's NULL!" << endl; 2634 return 0.; 2635 } else 2636 *out << Verbose(2) << "Removing point " << *point << " from tesselated boundary ..." << endl; 2637 2624 2638 // copy old location for the volume 2625 2639 OldPoint.CopyVector(point->node->node); … … 2636 2650 count+=LineRunner->second->triangles.size(); 2637 2651 numbers = new int[count]; 2652 class BoundaryTriangleSet **Candidates = new BoundaryTriangleSet*[count]; 2638 2653 i=0; 2639 2654 for (LineMap::iterator LineRunner = point->lines.begin(); (point != NULL) && (LineRunner != point->lines.end()); LineRunner++) { … … 2641 2656 for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) { 2642 2657 triangle = TriangleRunner->second; 2643 *out << Verbose(2) << "Erasing triangle " << *triangle << "." << endl;2658 Candidates[i] = triangle; 2644 2659 numbers[i++] = triangle->Nr; 2645 RemoveTesselationTriangle(triangle); 2646 triangle = NULL; 2647 } 2648 } 2660 } 2661 } 2662 for (int j=0;j<i;j++) { 2663 RemoveTesselationTriangle(Candidates[j]); 2664 } 2665 delete[](Candidates); 2649 2666 *out << Verbose(1) << i << " triangles were removed." << endl; 2650 2667
Note:
See TracChangeset
for help on using the changeset viewer.
