00001 00002 #include <OSGVector.h> 00003 00004 #include "OSGDVRVertex.h" 00005 00006 OSG_USING_NAMESPACE 00007 00008 DVRVertex::DVRVertex(void) 00009 { 00010 pos = Pnt3f(0.0, 0.0, 0.0); 00011 transformedPos = pos; 00012 behindPlane = false; 00013 refPlaneDistance = 0.0; 00014 } 00015 00016 DVRVertex::DVRVertex(const DVRVertex &vertex) 00017 { 00018 pos = vertex.pos; 00019 transformedPos = vertex.transformedPos; 00020 adjacentTriangles = vertex.adjacentTriangles; 00021 behindPlane = vertex.behindPlane; 00022 refPlaneDistance = vertex.refPlaneDistance; 00023 } 00024 00025 DVRVertex::~DVRVertex(void) 00026 { 00027 } 00028 00029 void DVRVertex::calculatePlaneDistance(const Plane &plane) 00030 { 00031 // calculate distance to the reference plane 00032 refPlaneDistance = plane.distance(pos); 00033 } 00034 00035 void DVRVertex::calculatePlaneDistanceTransformed(const Plane &plane) 00036 { 00037 // calculate distance to the reference plane 00038 refPlaneDistance = plane.distance(transformedPos); 00039 } 00040 00041 void DVRVertex::calculatePlaneDistance(const Plane &plane, 00042 const Matrix &transform) 00043 { 00044 Pnt3f transPos; 00045 transform.multPntFullMatrix(pos, transPos); 00046 00047 // calculate distance to the reference plane 00048 refPlaneDistance = plane.distance(transPos); 00049 } 00050 00051 bool DVRVertex::isBehindPlane(float dist2RefPlane, bool &switched) 00052 { 00053 switched = false; 00054 00055 if(dist2RefPlane > refPlaneDistance) 00056 { 00057 if(!behindPlane) 00058 switched = true; 00059 00060 behindPlane = true; 00061 00062 return true; 00063 } 00064 00065 return false; 00066 } 00067 00068 bool DVRVertex::isBehindPlane(float dist2RefPlane) 00069 { 00070 return (dist2RefPlane > refPlaneDistance); 00071 } 00072 00073 00074 bool DVRVertex::isCloser(float distance) 00075 { 00076 if(distance < refPlaneDistance) 00077 { 00078 return false; 00079 } 00080 00081 if(distance == refPlaneDistance) 00082 return false; 00083 00084 return true; 00085 } 00086 00087 00088 void DVRVertex::dump() const 00089 { 00090 std::cerr << "Pos=(" 00091 << pos 00092 << ") transformedPos=(" 00093 << transformedPos 00094 << ") Adj. Tris: "; 00095 00096 for(UInt32 i = 0; i < adjacentTriangles.size(); i++) 00097 { 00098 std::cerr << adjacentTriangles[i] << " "; 00099 } 00100 std::cerr << std::endl; 00101 } 00102
1.5.5