markraz / carve

Automatically exported from code.google.com/p/carve
Other
0 stars 0 forks source link

Issue performing CSG on Triangulated cubes #51

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. carve::mesh::MeshSet<3>* DBProCarve::makeCube(const carve::math::Matrix 
&transform) 
{
  carve::input::PolyhedronData data;

  data.addVertex(transform * carve::geom::VECTOR(+20.0, +20.0, +20.0));
  data.addVertex(transform * carve::geom::VECTOR(-20.0, +20.0, +20.0));
  data.addVertex(transform * carve::geom::VECTOR(-20.0, -20.0, +20.0));
  data.addVertex(transform * carve::geom::VECTOR(+20.0, -20.0, +20.0));

  data.addVertex(transform * carve::geom::VECTOR(+20.0, +20.0, -20.0));
  data.addVertex(transform * carve::geom::VECTOR(-20.0, +20.0, -20.0));
  data.addVertex(transform * carve::geom::VECTOR(-20.0, -20.0, -20.0));
  data.addVertex(transform * carve::geom::VECTOR(+20.0, -20.0, -20.0));
  data.addFace(0, 1, 2);
  data.addFace(0, 2, 3);

  data.addFace(7, 6, 5);
  data.addFace(7, 5, 4);

  data.addFace(0, 4, 5);
  data.addFace(0, 5, 1);

  data.addFace(1, 5, 6);
  data.addFace(1, 6, 2);

  data.addFace(2, 6, 7);
  data.addFace(2, 7, 3);

  data.addFace(3, 7, 4);
  data.addFace(3, 4, 0);

  return new carve::mesh::MeshSet<3>(data.points, data.getFaceCount(), data.faceIndices);
}

2. Use the code above to create two cubes and perform CSG intersect
carve::csg::CSG csg;

csg.hooks.registerHook(new carve::csg::CarveTriangulatorWithImprovement, 
carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
    csg.hooks.registerHook(new carve::csg::CarveHoleResolver, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);

carve::mesh::MeshSet<3>* result = csg.compute(meshSetA, meshSetB, 
carve::csg::CSG::INTERSECTION,NULL, carve::csg::CSG::CLASSIFY_EDGE);

3.

What is the expected output? What do you see instead?
I should get
1 mesh
12 faces
8 vertices

Instead I get
11 meshes
65faces
30 vertices

What version of the product are you using? On what operating system?
(e82d852e4fb0) Windows Visual Studio 2010

Please provide any additional information below.
I am assuming that because data.addface can take 3 indices CARVE should be able 
CSG on two triangulated meshes. 

Original issue reported on code.google.com by gonefishing@stabinthedarksoftware.com on 9 Mar 2014 at 7:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I get it to crash in triangulator.cpp on line 899

    if (attachment_point == result.size()) 
    {
      CARVE_FAIL("didn't manage to link up hole!");
}

Original comment by stabinth...@pages.plusgoogle.com on 11 Mar 2014 at 3:56

GoogleCodeExporter commented 9 years ago
I also got the same error in triangulator.cpp:899 when process two other 
triangulated meshes.

Original comment by tanglaoy...@gmail.com on 18 Apr 2014 at 2:50