Bjornmose's fixes for making booleans compile on MSVC 6.
authorAlexander Ewering <blender@instinctive.de>
Fri, 11 Nov 2005 23:10:10 +0000 (23:10 +0000)
committerAlexander Ewering <blender@instinctive.de>
Fri, 11 Nov 2005 23:10:10 +0000 (23:10 +0000)
Thanks!

intern/boolop/intern/BOP_BSPNode.cpp
intern/boolop/intern/BOP_Face2Face.cpp
intern/boolop/intern/BOP_MaterialContainer.cpp
intern/boolop/intern/BOP_MathUtils.cpp
intern/boolop/intern/BOP_Merge.cpp
intern/boolop/intern/BOP_Mesh.cpp

index afe48586d335ed3b6550d0951860c51bd666588d..af5c40baad99fc2bc3156c8b147bd06462395390 100644 (file)
@@ -81,10 +81,10 @@ unsigned int BOP_BSPNode::addFace(const MT_Point3& p1,
        
        if ((tag & OUT_OUT_OUT) != 0){
                if (m_outChild != NULL)
-                       newDeep = max(newDeep, m_outChild->addFace(p1, p2, p3, plane) + 1);
+                       newDeep = MT_max(newDeep, m_outChild->addFace(p1, p2, p3, plane) + 1);
                else {
                        m_outChild = new BOP_BSPNode(plane);
-                       newDeep = max(newDeep,(unsigned int)2);
+                       newDeep = MT_max(newDeep,(unsigned int)2);
                }      
        }
        
index 6d7c671870d34981d6153f61573685e9129b5da2..08928935f33da85c5869a70a4687746dc3c4ad26 100644 (file)
@@ -502,8 +502,8 @@ void BOP_getPoints(BOP_Mesh*    mesh,
  */
 void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bool &invertA, bool &invertB) {
   MT_Point3 sortedPoints[4];
-  unsigned int sortedFaces[4];
-  unsigned int position[4];
+  unsigned int sortedFaces[4], position[4];
+  unsigned int i;
   if (size == 2) {
 
     // Trivial case, only test the merge ...
@@ -516,7 +516,7 @@ void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bo
     // size is 3 or 4
     // Get segment extreme points
     MT_Scalar maxDistance = -1;
-    for(unsigned int i=0;i<size-1;i++){
+    for(i=0;i<size-1;i++){
       for(unsigned int j=i+1;j<size;j++){
         MT_Scalar distance = points[i].distance(points[j]);
         if (distance > maxDistance){
@@ -529,7 +529,7 @@ void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bo
 
     // Get segment inner points
     position[1] = position[2] = size;
-    for(unsigned int i=0;i<size;i++){
+    for(i=0;i<size;i++){
       if ((i != position[0]) && (i != position[size-1])){
         if (position[1] == size) position[1] = i;
         else position[2] = i;
@@ -548,7 +548,7 @@ void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bo
     }
 
     // Sort data
-    for(unsigned int i=0;i<size;i++) {
+    for(i=0;i<size;i++) {
       sortedPoints[i] = points[position[i]];
       sortedFaces[i] = face[position[i]];
     }
@@ -558,7 +558,7 @@ void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bo
     invertB = false;
     if (face[1] == 1) {
       // invertA┬┐?
-      for(unsigned int i=0;i<size;i++) {
+      for(i=0;i<size;i++) {
         if (position[i] == 1) {
           invertA = true;
           break;
@@ -661,7 +661,7 @@ void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bo
     }
     
     // Merge initial points ...
-    for(unsigned int i=0;i<size;i++) {
+    for(i=0;i<size;i++) {
       points[i] = sortedPoints[i];
       face[i] = sortedFaces[i];
     }
@@ -680,16 +680,16 @@ void BOP_mergeSort(MT_Point3 *points, unsigned int *face, unsigned int &size, bo
  * @param invert indicates if faceA has priority over faceB
  * @param segmemts array of the output x-segments
  */
-void BOP_createXS(BOP_Mesh*    mesh, 
-                                 BOP_Face*    faceA, 
-                                 BOP_Face*    faceB, 
-                                 BOP_Segment  sA, 
-                                 BOP_Segment  sB, 
-                                 bool         invert, 
-                                 BOP_Segment* segments) {    
-       return BOP_createXS(mesh, faceA, faceB, faceA->getPlane(), faceB->getPlane(),
-                                               sA, sB, invert, segments);
-}
+ void BOP_createXS(BOP_Mesh*    mesh, 
+        BOP_Face*    faceA, 
+        BOP_Face*    faceB, 
+        BOP_Segment  sA, 
+        BOP_Segment  sB, 
+        bool         invert, 
+        BOP_Segment* segments) {    
+        BOP_createXS(mesh, faceA, faceB, faceA->getPlane(), faceB->getPlane(),
+                sA, sB, invert, segments);
+ }
 
 /**
  * Computes the x-segment of two segments (the shared interval). The segments needs to have sA.m_cfg1 > 0 && sB.m_cfg1 > 0 .
index b8f38b356516de10e2ac5605c4d6d631c04cbd67..6ade5b0649ffecef510702d5b3beae2b1291e4d9 100644 (file)
@@ -114,6 +114,8 @@ char* BOP_MaterialContainer::getFaceVertexMaterial(BOP_Mesh *mesh,
                                                                                                   MT_Point3 point, 
                                                                                                   char* faceVertexMaterial)
 {
+       unsigned int i;
+
        if (originalFaceIndex>=m_materialList.size()) return NULL;
 
        BOP_Material& material = m_materialList[originalFaceIndex];
@@ -126,12 +128,12 @@ char* BOP_MaterialContainer::getFaceVertexMaterial(BOP_Mesh *mesh,
                if (!face1 || !face2) return NULL;
                
                // Search original point
-               for (unsigned int i=0;i<face1->size();i++) {
+               for (i=0;i<face1->size();i++) {
                        if (point == mesh->getVertex(face1->getVertex(i))->getPoint()) {
                                return material.getOriginalFaceVertexMaterial(face1->getVertex(i));
                        }
                }
-               for (unsigned int i=0;i<face2->size();i++) {
+               for (i=0;i<face2->size();i++) {
                        if (point == mesh->getVertex(face2->getVertex(i))->getPoint()) {
                                return material.getOriginalFaceVertexMaterial(face2->getVertex(i));
                        }
@@ -158,7 +160,7 @@ char* BOP_MaterialContainer::getFaceVertexMaterial(BOP_Mesh *mesh,
                if (!face1) return NULL;
                
                // Search original point
-               for (unsigned int i=0;i<face1->size();i++) {
+               for (i=0;i<face1->size();i++) {
                        if (point == mesh->getVertex(face1->getVertex(i))->getPoint())
                                return material.getOriginalFaceVertexMaterial(face1->getVertex(i));
                }
index 00c9515a4863baa4cee40147e12836add86ce589..7a0210247eb114501a6a6c50a0d4afd9d347e1c6 100644 (file)
@@ -338,7 +338,7 @@ MT_Point3 BOP_intersectPlane(const MT_Plane3& plane, const MT_Point3& p1, const
        //
        //       coefA*((p2.x - p1.y)*lambda + p1.x) + ... + coefD = 0
        
-    MT_Point3 intersection;
+    MT_Point3 intersection = MT_Point3(0,0,0); //never ever return anything undefined! 
     MT_Scalar den = plane.x()*(p2.x()-p1.x()) + 
                                        plane.y()*(p2.y()-p1.y()) + 
                                        plane.z()*(p2.z()-p1.z());
index 1165ac10a8fb2ee2febd0ff418f56a94eba67fb0..fb5bfbc0e7b0c13b9f81734652429ef50047338d 100644 (file)
  
 #include "BOP_Merge.h"
 
+
+#ifdef _MSC_VER
+#if _MSC_VER < 1300
+#include <list>
+#endif
+#endif
+
 /**
  * SINGLETON (use method BOP_Merge.getInstance).
  */
index d8193f9c4b059fc0cfba7fc0ece53cec9cc2d78b..24d5b3fb6a90b64df4cadd8865750a8ab36d99b8 100644 (file)
 BOP_Mesh::~BOP_Mesh()
 {
        const BOP_IT_Vertexs vertexsEnd = m_vertexs.end();
-       for(BOP_IT_Vertexs it=m_vertexs.begin();it!=vertexsEnd;it++){
-               delete *it;
+       for(BOP_IT_Vertexs itv=m_vertexs.begin();itv!=vertexsEnd;itv++){
+               delete *itv;
        }
        m_vertexs.clear();
   
        const BOP_IT_Edges edgesEnd = m_edges.end();
-       for(BOP_IT_Edges it=m_edges.begin();it!=edgesEnd;it++){
-               delete *it;
+       for(BOP_IT_Edges ite=m_edges.begin();ite!=edgesEnd;ite++){
+               delete *ite;
        }
        m_edges.clear();
   
        const BOP_IT_Faces facesEnd = m_faces.end();
-       for(BOP_IT_Faces it=m_faces.begin();it!=facesEnd;it++){
-               delete *it;
+       for(BOP_IT_Faces itf=m_faces.begin();itf!=facesEnd;itf++){
+               delete *itf;
        }
        m_faces.clear();
 }
@@ -482,6 +482,7 @@ unsigned int BOP_Mesh::getNumFaces(BOP_TAG tag)
  */
 BOP_Index BOP_Mesh::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex) 
 {
+       BOP_IT_Indexs oldEdgeIndex;
        if (oldIndex==newIndex) return newIndex;
   
        // Update faces, edges and vertices  
@@ -494,7 +495,7 @@ BOP_Index BOP_Mesh::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex)
 
        // Update faces to the newIndex
        BOP_IT_Indexs oldEdgesEnd = oldEdges.end();
-       for(BOP_IT_Indexs oldEdgeIndex=oldEdges.begin();oldEdgeIndex!=oldEdgesEnd;
+       for(oldEdgeIndex=oldEdges.begin();oldEdgeIndex!=oldEdgesEnd;
                   oldEdgeIndex++) {
                BOP_Edge *edge = m_edges[*oldEdgeIndex];
                if ((edge->getVertex1()==oldIndex && edge->getVertex2()==newIndex) ||
@@ -524,7 +525,7 @@ BOP_Index BOP_Mesh::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex)
        }
 
        oldEdgesEnd = oldEdges.end();
-       for(BOP_IT_Indexs oldEdgeIndex=oldEdges.begin();oldEdgeIndex!=oldEdgesEnd;
+       for(oldEdgeIndex=oldEdges.begin();oldEdgeIndex!=oldEdgesEnd;
                   oldEdgeIndex++) {
                BOP_Edge * edge = m_edges[*oldEdgeIndex];
                BOP_Edge * edge2;
@@ -564,13 +565,14 @@ BOP_Index BOP_Mesh::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex)
  */
 void BOP_Mesh::print() 
 {
+       unsigned int i;
        cout << "--Faces--" << endl;
-       for(unsigned int i=0;i<m_faces.size();i++){
+       for(i=0;i<m_faces.size();i++){
                cout << "Face " << i << ": " << m_faces[i] << endl;
        }
 
        cout << "--Vertices--" << endl;
-       for(unsigned int i=0;i<m_vertexs.size();i++){
+       for(i=0;i<m_vertexs.size();i++){
                cout << "Point " << i << ": " << m_vertexs[i]->getPoint() << endl;
        }
 }
@@ -677,8 +679,8 @@ void BOP_Mesh::testMesh()
 {
 
        BOP_Face* cares[10];
-       unsigned int nedges=0;
-       for(unsigned int i=0;i<m_edges.size();i++) {
+       unsigned int nedges=0,i;
+       for(i=0;i<m_edges.size();i++) {
                BOP_Edge *edge = m_edges[i];
                BOP_Indexs faces = edge->getFaces();
                unsigned int count = 0;
@@ -700,7 +702,7 @@ void BOP_Mesh::testMesh()
 
        unsigned int duplFaces = 0;
        unsigned int wrongFaces = 0;
-       for(unsigned int i=0;i<m_faces.size();i++){
+       for(i=0;i<m_faces.size();i++){
          BOP_Face *faceI = m_faces[i];
          if (faceI->getTAG()==BROKEN)
            continue;