00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef NVBLASTEXTAUTHORINGBOOLEANTOOL_H
00030 #define NVBLASTEXTAUTHORINGBOOLEANTOOL_H
00031
00032 #include "NvBlastExtAuthoringTypes.h"
00033 #include "NvBlastExtAuthoringInternalCommon.h"
00034 #include <vector>
00035 #include "NvBlastTypes.h"
00036
00037
00038 namespace Nv
00039 {
00040 namespace Blast
00041 {
00042
00043 class Mesh;
00044
00048 struct BooleanConf
00049 {
00050 int32_t ca, cb, ci;
00051 BooleanConf(int32_t a, int32_t b, int32_t c) : ca(a), cb(b), ci(c)
00052 {
00053 }
00054 };
00055
00056
00057 namespace BooleanConfigurations
00058 {
00062 inline BooleanConf BOOLEAN_INTERSECION()
00063 {
00064 return BooleanConf(0, 0, 1);
00065 }
00066
00070 inline BooleanConf BOOLEAN_UNION()
00071 {
00072 return BooleanConf(1, 1, -1);
00073 }
00077 inline BooleanConf BOOLEAN_DIFFERENCE()
00078 {
00079 return BooleanConf(1, 0, -1);
00080 }
00081 }
00082
00086 struct EdgeFacetIntersectionData
00087 {
00088 int32_t edId;
00089 int32_t intersectionType;
00090 Vertex intersectionPoint;
00091 EdgeFacetIntersectionData(int32_t edId, int32_t intersType, Vertex& inters) : edId(edId), intersectionType(intersType), intersectionPoint(inters)
00092 { }
00093 EdgeFacetIntersectionData(int32_t edId) : edId(edId)
00094 { }
00095 bool operator<(const EdgeFacetIntersectionData& b) const
00096 {
00097 return edId < b.edId;
00098 }
00099 };
00100
00101
00102 class SpatialAccelerator;
00103
00108 class BooleanEvaluator
00109 {
00110
00111 public:
00112 BooleanEvaluator();
00113 ~BooleanEvaluator();
00114
00123 void performBoolean(const Mesh* meshA, const Mesh* meshB, SpatialAccelerator* spAccelA, SpatialAccelerator* spAccelB, BooleanConf mode);
00124
00131 void performBoolean(const Mesh* meshA, const Mesh* meshB, BooleanConf mode);
00132
00142 void performFastCutting(const Mesh* meshA, const Mesh* meshB, SpatialAccelerator* spAccelA, SpatialAccelerator* spAccelB, BooleanConf mode);
00143
00151 void performFastCutting(const Mesh* meshA, const Mesh* meshB, BooleanConf mode);
00152
00159 int32_t isPointContainedInMesh(const Mesh* mesh, const NvcVec3& point);
00167 int32_t isPointContainedInMesh(const Mesh* mesh, SpatialAccelerator* spAccel, const NvcVec3& point);
00168
00169
00174 Mesh* createNewMesh();
00175
00179 void reset();
00180
00181 private:
00182
00183 void buildFaceFaceIntersections(BooleanConf);
00184 void buildFastFaceFaceIntersection(BooleanConf);
00185 void collectRetainedPartsFromA(BooleanConf mode);
00186 void collectRetainedPartsFromB(BooleanConf mode);
00187
00188 int32_t addIfNotExist(Vertex& p);
00189 void addEdgeIfValid(EdgeWithParent& ed);
00190 private:
00191
00192 int32_t vertexMeshStatus03(const NvcVec3& p, const Mesh* mesh);
00193 int32_t vertexMeshStatus30(const NvcVec3& p, const Mesh* mesh);
00194
00195 const Mesh* mMeshA;
00196 const Mesh* mMeshB;
00197
00198 SpatialAccelerator* mAcceleratorA;
00199 SpatialAccelerator* mAcceleratorB;
00200
00201 std::vector<EdgeWithParent> mEdgeAggregate;
00202 std::vector<Vertex> mVerticesAggregate;
00203
00204 std::vector<std::vector<EdgeFacetIntersectionData> > mEdgeFacetIntersectionData12;
00205 std::vector<std::vector<EdgeFacetIntersectionData> > mEdgeFacetIntersectionData21;
00206 };
00207
00208 }
00209 }
00210
00211
00212 #endif // ifndef NVBLASTEXTAUTHORINGBOOLEANTOOL_H