[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43643] trunk/blender/intern/boolop/intern /BOP_CarveInterface.cpp: Carve booleans: code and style cleanup

Sergey Sharybin sergey.vfx at gmail.com
Mon Jan 23 18:44:06 CET 2012


Revision: 43643
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43643
Author:   nazgul
Date:     2012-01-23 17:44:05 +0000 (Mon, 23 Jan 2012)
Log Message:
-----------
Carve booleans: code and style cleanup

Modified Paths:
--------------
    trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp

Modified: trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp
===================================================================
--- trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp	2012-01-23 17:43:41 UTC (rev 43642)
+++ trunk/blender/intern/boolop/intern/BOP_CarveInterface.cpp	2012-01-23 17:44:05 UTC (rev 43643)
@@ -38,6 +38,7 @@
 
 #include <iostream>
 
+using namespace carve::mesh;
 typedef unsigned int uint;
 
 #define MAX(x,y) ((x)>(y)?(x):(y))
@@ -63,38 +64,38 @@
 	return 1;
 }
 
-static carve::mesh::MeshSet<3> *Carve_meshSetFromMeshes(std::vector<carve::mesh::MeshSet<3>::mesh_t*> &meshes)
+static MeshSet<3> *Carve_meshSetFromMeshes(std::vector<MeshSet<3>::mesh_t*> &meshes)
 {
-	std::vector<carve::mesh::MeshSet<3>::mesh_t*> new_meshes;
+	std::vector<MeshSet<3>::mesh_t*> new_meshes;
 
-	std::vector<carve::mesh::MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
+	std::vector<MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
 	for(; it!=meshes.end(); it++) {
-		carve::mesh::MeshSet<3>::mesh_t *mesh = *it;
-		carve::mesh::MeshSet<3>::mesh_t *new_mesh = new carve::mesh::MeshSet<3>::mesh_t(mesh->faces);
+		MeshSet<3>::mesh_t *mesh = *it;
+		MeshSet<3>::mesh_t *new_mesh = new MeshSet<3>::mesh_t(mesh->faces);
 
 		new_meshes.push_back(new_mesh);
 	}
 
-	return new carve::mesh::MeshSet<3>(new_meshes);
+	return new MeshSet<3>(new_meshes);
 }
 
-static void Carve_getIntersectedOperandMeshes(std::vector<carve::mesh::MeshSet<3>::mesh_t*> &meshes,
-                                              std::vector<carve::mesh::MeshSet<3>::aabb_t> &precomputedAABB,
-                                              carve::mesh::MeshSet<3>::aabb_t &otherAABB,
-                                              std::vector<carve::mesh::MeshSet<3>::mesh_t*> &operandMeshes)
+static void Carve_getIntersectedOperandMeshes(std::vector<MeshSet<3>::mesh_t*> &meshes,
+                                              std::vector<MeshSet<3>::aabb_t> &precomputedAABB,
+                                              MeshSet<3>::aabb_t &otherAABB,
+                                              std::vector<MeshSet<3>::mesh_t*> &operandMeshes)
 {
-	std::vector<carve::mesh::MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
-	std::vector<carve::mesh::MeshSet<3>::aabb_t>::iterator aabb_it = precomputedAABB.begin();
-	std::vector<carve::mesh::MeshSet<3>::aabb_t> usedAABB;
+	std::vector<MeshSet<3>::mesh_t*>::iterator it = meshes.begin();
+	std::vector<MeshSet<3>::aabb_t>::iterator aabb_it = precomputedAABB.begin();
+	std::vector<MeshSet<3>::aabb_t> usedAABB;
 
 	while(it != meshes.end()) {
-		carve::mesh::MeshSet<3>::mesh_t *mesh = *it;
-		carve::mesh::MeshSet<3>::aabb_t aabb = mesh->getAABB();
+		MeshSet<3>::mesh_t *mesh = *it;
+		MeshSet<3>::aabb_t aabb = mesh->getAABB();
 		bool isIntersect = false;
 
-		std::vector<carve::mesh::MeshSet<3>::aabb_t>::iterator used_it = usedAABB.begin();
+		std::vector<MeshSet<3>::aabb_t>::iterator used_it = usedAABB.begin();
 		for(; used_it!=usedAABB.end(); used_it++) {
-			carve::mesh::MeshSet<3>::aabb_t usedAABB = *used_it;
+			MeshSet<3>::aabb_t usedAABB = *used_it;
 
 			if(usedAABB.intersects(aabb) && usedAABB.intersects(otherAABB)) {
 				isIntersect = true;
@@ -116,20 +117,20 @@
 	}
 }
 
-static carve::mesh::MeshSet<3> *Carve_getIntersectedOperand(std::vector<carve::mesh::MeshSet<3>::mesh_t*> &meshes,
-                                                            std::vector<carve::mesh::MeshSet<3>::aabb_t> &precomputedAABB,
-                                                            carve::mesh::MeshSet<3>::aabb_t &otherAABB)
+static MeshSet<3> *Carve_getIntersectedOperand(std::vector<MeshSet<3>::mesh_t*> &meshes,
+                                               std::vector<MeshSet<3>::aabb_t> &precomputedAABB,
+                                               MeshSet<3>::aabb_t &otherAABB)
 {
-	std::vector<carve::mesh::MeshSet<3>::mesh_t*> operandMeshes;
+	std::vector<MeshSet<3>::mesh_t*> operandMeshes;
 	Carve_getIntersectedOperandMeshes(meshes, precomputedAABB, otherAABB, operandMeshes);
 
 	return Carve_meshSetFromMeshes(operandMeshes);
 }
 
-static carve::mesh::MeshSet<3> *Carve_unionIntersectingMeshes(carve::mesh::MeshSet<3> *poly,
-                                                              std::vector<carve::mesh::MeshSet<3>::aabb_t> &precomputedAABB,
-                                                              carve::mesh::MeshSet<3>::aabb_t &otherAABB,
-                                                              carve::interpolate::FaceAttr<uint> &oface_num)
+static MeshSet<3> *Carve_unionIntersectingMeshes(MeshSet<3> *poly,
+                                                 std::vector<MeshSet<3>::aabb_t> &precomputedAABB,
+                                                 MeshSet<3>::aabb_t &otherAABB,
+                                                 carve::interpolate::FaceAttr<uint> &oface_num)
 {
 	if(poly->meshes.size()<=1)
 		return poly;
@@ -139,15 +140,17 @@
 	oface_num.installHooks(csg);
 	csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
 
-	std::vector<carve::mesh::MeshSet<3>::mesh_t*> orig_meshes = std::vector<carve::mesh::MeshSet<3>::mesh_t*>(poly->meshes.begin(), poly->meshes.end());
+	std::vector<MeshSet<3>::mesh_t*> orig_meshes =
+			std::vector<MeshSet<3>::mesh_t*>(poly->meshes.begin(), poly->meshes.end());
 
-	carve::mesh::MeshSet<3> *left = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
+	MeshSet<3> *left = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
 
 	while(orig_meshes.size()) {
-		carve::mesh::MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
+		MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB);
 
 		try {
-			carve::mesh::MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
+			MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
+
 			delete left;
 			delete right;
 
@@ -169,15 +172,15 @@
 	return left;
 }
 
-static carve::mesh::MeshSet<3>::aabb_t Carve_computeAABB(carve::mesh::MeshSet<3> *poly,
-                                                         std::vector<carve::mesh::MeshSet<3>::aabb_t> &precomputedAABB)
+static MeshSet<3>::aabb_t Carve_computeAABB(MeshSet<3> *poly,
+                                            std::vector<MeshSet<3>::aabb_t> &precomputedAABB)
 {
-	carve::mesh::MeshSet<3>::aabb_t overallAABB;
-	std::vector<carve::mesh::MeshSet<3>::mesh_t*>::iterator it = poly->meshes.begin();
+	MeshSet<3>::aabb_t overallAABB;
+	std::vector<MeshSet<3>::mesh_t*>::iterator it = poly->meshes.begin();
 
 	for(; it!=poly->meshes.end(); it++) {
-		carve::mesh::MeshSet<3>::aabb_t aabb;
-		carve::mesh::MeshSet<3>::mesh_t *mesh = *it;
+		MeshSet<3>::aabb_t aabb;
+		MeshSet<3>::mesh_t *mesh = *it;
 
 		aabb = mesh->getAABB();
 		precomputedAABB.push_back(aabb);
@@ -188,16 +191,16 @@
 	return overallAABB;
 }
 
-static void Carve_prepareOperands(carve::mesh::MeshSet<3> **left_r, carve::mesh::MeshSet<3> **right_r,
+static void Carve_prepareOperands(MeshSet<3> **left_r, MeshSet<3> **right_r,
                                   carve::interpolate::FaceAttr<uint> &oface_num)
 {
-	carve::mesh::MeshSet<3> *left, *right;
+	MeshSet<3> *left, *right;
 
-	std::vector<carve::mesh::MeshSet<3>::aabb_t> left_precomputedAABB;
-	std::vector<carve::mesh::MeshSet<3>::aabb_t> right_precomputedAABB;
+	std::vector<MeshSet<3>::aabb_t> left_precomputedAABB;
+	std::vector<MeshSet<3>::aabb_t> right_precomputedAABB;
 
-	carve::mesh::MeshSet<3>::aabb_t leftAABB = Carve_computeAABB(*left_r, left_precomputedAABB);
-	carve::mesh::MeshSet<3>::aabb_t rightAABB = Carve_computeAABB(*right_r, right_precomputedAABB);
+	MeshSet<3>::aabb_t leftAABB = Carve_computeAABB(*left_r, left_precomputedAABB);
+	MeshSet<3>::aabb_t rightAABB = Carve_computeAABB(*right_r, right_precomputedAABB);
 
 	left = Carve_unionIntersectingMeshes(*left_r, left_precomputedAABB, rightAABB, oface_num);
 	right = Carve_unionIntersectingMeshes(*right_r, right_precomputedAABB, leftAABB, oface_num);
@@ -212,10 +215,10 @@
 	*right_r = right;
 }
 
-static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_it,
-                                              CSG_VertexIteratorDescriptor& vertex_it,
-                                              carve::interpolate::FaceAttr<uint> &oface_num,
-                                              uint &num_origfaces)
+static MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor &face_it,
+                                 CSG_VertexIteratorDescriptor &vertex_it,
+                                 carve::interpolate::FaceAttr<uint> &oface_num,
+                                 uint &num_origfaces)
 {
 	CSG_IVertex vertex;
 	std::vector<carve::geom3d::Vector> vertices;
@@ -277,12 +280,12 @@
 		}
 	}
 
-	carve::mesh::MeshSet<3> *poly = new carve::mesh::MeshSet<3> (vertices, numfaces, f);
+	MeshSet<3> *poly = new MeshSet<3> (vertices, numfaces, f);
 
 	uint i;
-	carve::mesh::MeshSet<3>::face_iter face_iter = poly->faceBegin();
+	MeshSet<3>::face_iter face_iter = poly->faceBegin();
 	for (i = 0; face_iter != poly->faceEnd(); ++face_iter, ++i) {
-		carve::mesh::MeshSet<3>::face_t *face = *face_iter;
+		MeshSet<3>::face_t *face = *face_iter;
 		oface_num.setAttribute(face, forig[i]);
 	}
 
@@ -290,8 +293,8 @@
 }
 
 // check whether two faces share an edge, and if so merge them
-static uint quadMerge(std::map<carve::mesh::MeshSet<3>::vertex_t*, uint> *vertexToIndex_map,
-                      carve::mesh::MeshSet<3>::face_t *f1, carve::mesh::MeshSet<3>::face_t *f2,
+static uint quadMerge(std::map<MeshSet<3>::vertex_t*, uint> *vertexToIndex_map,
+                      MeshSet<3>::face_t *f1, MeshSet<3>::face_t *f2,
                       uint v, uint quad[4])
 {
 	uint current, n1, p1, n2, p2;
@@ -339,23 +342,23 @@
 	return 0;
 }
 
-static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::interpolate::FaceAttr<uint> &oface_num,
+static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::FaceAttr<uint> &oface_num,
                                      uint num_origfaces)
 {
 	uint i;
-	BSP_CSGMesh* outputMesh = BSP_CSGMesh::New();
+	BSP_CSGMesh *outputMesh = BSP_CSGMesh::New();
 
 	if (outputMesh == NULL)

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list