#include <OSGDVRClipGeometry.h>
Inheritance diagram for osg::DVRClipGeometry:

Clipping | |
| *void | buildContours (Real32 dist2RefPlane, bool positiveWinding, const Vec3f &sliceNormal) |
| Identifies all contours and links them. | |
| void | linkContour (DVRTriangle *startTriangle, Real32 dist2RefPlane, const Vec3f &viewDir, bool positiveWinding) |
| Identifies and links a contour starting with the given triangle. | |
| void | updateActiveTriangles (Real32 dist2RefPlane, const Vec3f &sliceNormal) |
| updates the active triangle list | |
| void | addActiveTriangle (DVRTriangle *tri) |
| Identifies all contours and links them. | |
| void | addNewActiveTriangles (DVRVertex *vertex, Real32 dist2RefPlane) |
| Identifies all contours and links them. | |
| Pnt3f | interpolate (DVRTriangle *tri, Int32 v1, Int32 v2, Real32 dist2RefPlane) |
| Identifies all contours and links them. | |
| void | operator= (const DVRClipGeometry &source) |
| Identifies all contours and links them. | |
| static void | initMethod (void) |
| Identifies all contours and links them. | |
| class | FieldContainer |
| Identifies all contours and links them. | |
| class | DVRClipGeometryBase |
| Identifies all contours and links them. | |
Public Types | |
| typedef DVRClipGeometryPtr | Ptr |
| enum | { GeometryNodeFieldId = Inherited::NextFieldId, BeaconFieldId = GeometryNodeFieldId + 1, NextFieldId = BeaconFieldId + 1 } |
Public Member Functions | |
Sync | |
| *virtual void | changed (BitVector whichField, UInt32 origin) |
Output | |
| *virtual void | dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const |
Clipping | |
| *void | initialize (const Matrix &volumeToWorld) |
| void | resetLocalData (void) |
| Reset local data of vertices and triangles. | |
| void | setReferencePlane (const Plane &referencePlane) |
| Set the reference plane used in the clipping algorithm. | |
| bool | setNumAddPerVertexAttr (UInt32 additionalPerVertexAttributes) |
| set the number of additional per vertex attributes | |
| void | computeSeedVertices (void) |
| Compute the seed vertex set. | |
| const DVRTriangleList & | getContours (float dist2RefPlane, bool positiveWinding, const Vec3f &sliceNormal) |
| find contour made up by triangles which are cut by the current slice | |
FieldContainer Get | |
| *virtual FieldContainerType & | getType (void) |
| virtual const FieldContainerType & | getType (void) const |
| virtual UInt32 | getContainerSize (void) const |
Field Get | |
| *SFNodePtr * | getSFGeometryNode (void) |
| Get the DVRClipGeometry::_sfGeometryNode field. | |
| SFNodePtr * | getSFBeacon (void) |
| Get the DVRClipGeometry::_sfBeacon field. | |
| NodePtr & | getGeometryNode (void) |
| Get the value of the DVRClipGeometry::_sfGeometryNode field. | |
| const NodePtr & | getGeometryNode (void) const |
| Get the value of the DVRClipGeometry::_sfGeometryNode field. | |
| NodePtr & | getBeacon (void) |
| Get the value of the DVRClipGeometry::_sfBeacon field. | |
| const NodePtr & | getBeacon (void) const |
| Get the value of the DVRClipGeometry::_sfBeacon field. | |
Field Set | |
| *void | setGeometryNode (const NodePtr &value) |
| Set the value of the DVRClipGeometry::_sfGeometryNode field. | |
| void | setBeacon (const NodePtr &value) |
| Set the value of the DVRClipGeometry::_sfBeacon field. | |
Binary Access | |
| *virtual UInt32 | getBinSize (const BitVector &whichField) |
| virtual void | copyToBin (BinaryDataHandler &pMem, const BitVector &whichField) |
| virtual void | copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField) |
Copy | |
| *virtual FieldContainerPtr | shallowCopy (void) const |
Static Public Member Functions | |
Class Get | |
| *static FieldContainerType & | getClassType (void) |
| access the type of the class | |
| static UInt32 | getClassTypeId (void) |
| access the numerical type of the class | |
Construction | |
| *static DVRClipGeometryPtr | create (void) |
| create a new instance of the class | |
| static DVRClipGeometryPtr | createEmpty (void) |
| create an empty new instance of the class, do not copy the prototype | |
Static Public Attributes | |
| static const osg::BitVector | GeometryNodeFieldMask |
| static const osg::BitVector | BeaconFieldMask |
| static const osg::BitVector | MTInfluenceMask |
| static const BitVector | NextFieldMask |
Protected Member Functions | |
Constructors | |
| * | DVRClipGeometry (void) |
| DVRClipGeometry (const DVRClipGeometry &source) | |
Destructors | |
| *virtual | ~DVRClipGeometry (void) |
Vertices | |
| *Int32 | insertVertex (Int32 idx) |
| Insert a vertex in the vertex list. | |
| bool | isLocalMinimum (DVRVertex &vertex) |
Triangles | |
| *bool | isCut (DVRTriangle *tri, Real32 dist2RefPlane, DVRVertex *switchedVertices[3]) |
| bool | isBehindPlane (DVRTriangle &tri, Real32 dist2RefPlane) |
| void | renderTriangle (const DVRTriangle &tri) const |
| Use OpenGL to render the triangle. | |
Triangle Geometry Setup | |
| *bool | buildTriangledGeometry (void) |
| create the triangled geometry data structure | |
Sync | |
| *void | executeSyncImpl (DVRClipGeometryBase *pOther, const BitVector &whichField) |
| virtual void | executeSync (FieldContainer &other, const BitVector &whichField) |
Protected Attributes | |
Locals | |
| *bool | initialized |
| is the clip geometry initialized? | |
| GeometryPtr | geometry |
| the core of the geometry node | |
| std::vector< DVRVertex > | _mfVertices |
| list of vertices in the triangulated clip geometry | |
| std::vector< DVRTriangle > | _mfTriangles |
| list of triangles in the triangulated clip geometry | |
| Matrix | toVolumeSpace |
| DVRTriangle ** | activeTriangles |
| the triangles which are cut by the current slice | |
| UInt32 | activeTrianglesCount |
| is the clip geometry initialized? | |
| UInt32 | maxActiveTrianglesCount |
| is the clip geometry initialized? | |
| DVRVertex ** | seedVertices |
| the vertices which are closest to the reference plane | |
| UInt32 | seedVerticesCount |
| is the clip geometry initialized? | |
| UInt32 | maxSeedVerticesCount |
| is the clip geometry initialized? | |
| DVRTriangleList | contours |
Fields | |
| *SFNodePtr | _sfGeometryNode |
| SFNodePtr | _sfBeacon |
Private Types | |
| typedef DVRClipGeometryBase | Inherited |
Definition at line 58 of file OSGDVRClipGeometry.h.
|
|
Reimplemented from osg::DVRClipGeometryBase. Definition at line 62 of file OSGDVRClipGeometry.h. |
|
|
Definition at line 91 of file OSGDVRClipGeometryBase.h. |
|
|
Reimplemented from osg::FieldContainer. Definition at line 93 of file OSGDVRClipGeometryBase.h. 00094 { 00095 GeometryNodeFieldId = Inherited::NextFieldId, 00096 BeaconFieldId = GeometryNodeFieldId + 1, 00097 NextFieldId = BeaconFieldId + 1 00098 };
|
|
|
Definition at line 65 of file OSGDVRClipGeometry.cpp. References activeTriangles, activeTrianglesCount, initialized, maxActiveTrianglesCount, maxSeedVerticesCount, seedVertices, and seedVerticesCount. 00065 : 00066 Inherited() 00067 { 00068 initialized = false; 00069 maxActiveTrianglesCount = 4; 00070 activeTrianglesCount = 0; 00071 maxSeedVerticesCount = 4; 00072 seedVerticesCount = 0; 00073 00074 activeTriangles = 00075 (DVRTriangle **) malloc(maxActiveTrianglesCount * 00076 sizeof(DVRTriangle *) ); 00077 00078 seedVertices = 00079 (DVRVertex **) malloc(maxSeedVerticesCount * 00080 sizeof(DVRVertex *) ); 00081 }
|
|
|
Definition at line 84 of file OSGDVRClipGeometry.cpp. References activeTriangles, activeTrianglesCount, initialized, maxActiveTrianglesCount, maxSeedVerticesCount, seedVertices, and seedVerticesCount. 00084 : 00085 Inherited(source) 00086 { 00087 initialized = false; 00088 maxActiveTrianglesCount = 4; 00089 activeTrianglesCount = 0; 00090 maxSeedVerticesCount = 4; 00091 seedVerticesCount = 0; 00092 00093 activeTriangles = 00094 (DVRTriangle **) malloc(maxActiveTrianglesCount * 00095 sizeof(DVRTriangle *) ); 00096 00097 seedVertices = 00098 (DVRVertex **) malloc(maxSeedVerticesCount * 00099 sizeof(DVRVertex *) ); 00100 }
|
|
|
Definition at line 103 of file OSGDVRClipGeometry.cpp. References activeTriangles, and seedVertices. 00104 { 00105 if(activeTriangles) 00106 free(activeTriangles); // allocation with malloc/realloc!! 00107 00108 if(seedVertices) 00109 free(seedVertices); // allocation with malloc/realloc!! 00110 }
|
|
||||||||||||
|
Reimplemented from osg::FieldContainer. Definition at line 120 of file OSGDVRClipGeometry.cpp. References osg::FieldContainer::changed(), osg::DVRClipGeometryBase::GeometryNodeFieldMask, and initialized. 00121 { 00122 Inherited::changed(whichField, origin); 00123 00124 if ((whichField & GeometryNodeFieldMask)) 00125 { 00126 initialized = false; 00127 } 00128 }
|
|
||||||||||||
|
Implements osg::FieldContainer. Definition at line 131 of file OSGDVRClipGeometry.cpp. References SLOG. 00133 { 00134 // _sfGeometry.dump(); 00135 // _sfBeacon.dump(); 00136 SLOG << "Dump DVRClipGeometry NI" << std::endl; 00137 }
|
|
|
Prepare the object for clipping a volume's slices (transform it to volume's space) Definition at line 314 of file OSGDVRClipGeometry.cpp. References _mfTriangles, _mfVertices, buildTriangledGeometry(), osg::AttachmentContainerPtr::dcast(), geometry, osg::DVRClipGeometryBase::getBeacon(), osg::NodePtr::getCore(), osg::DVRClipGeometryBase::getGeometryNode(), initialized, osg::TransformationMatrix< ValueTypeT >::inverse(), osg::TransformationMatrix< ValueTypeT >::invert(), osg::TransformationMatrix< ValueTypeT >::mult(), osg::TransformationMatrix< ValueTypeT >::multMatrixPnt(), osg::TransformationMatrix< ValueTypeT >::multMatrixVec(), osg::NullFC, toVolumeSpace, and osg::TransformationMatrix< ValueTypeT >::transpose(). 00315 { 00316 if(!initialized) 00317 { 00318 _mfVertices.clear (); 00319 _mfTriangles.clear(); 00320 00321 if(getGeometryNode() != NullFC) 00322 { 00323 if(getGeometryNode()->getCore() != NullFC) 00324 { 00325 geometry = GeometryPtr::dcast(getGeometryNode()->getCore()); 00326 00327 if(geometry != NullFC) 00328 initialized = buildTriangledGeometry(); 00329 } 00330 } 00331 } 00332 00333 if(!initialized) 00334 return; 00335 00336 Matrix old = toVolumeSpace; 00337 00338 toVolumeSpace = volumeToWorld; 00339 toVolumeSpace.invert(); 00340 00341 NodePtr beacon = getBeacon(); 00342 00343 if(beacon != NullFC) 00344 { 00345 toVolumeSpace.mult(beacon->getToWorld()); 00346 } 00347 else if(getGeometryNode() != NullFC) 00348 { 00349 toVolumeSpace.mult(getGeometryNode()->getToWorld()); 00350 } 00351 00352 Matrix toVolumeSpaceInvT; 00353 00354 toVolumeSpace .inverse(toVolumeSpaceInvT); 00355 toVolumeSpaceInvT.transpose(); 00356 00357 UInt32 numVertices = _mfVertices.size(); 00358 00359 // transform vertices to volume's space 00360 for(UInt32 i = 0; i < numVertices; i++) 00361 { 00362 toVolumeSpace.multMatrixPnt(_mfVertices[i].pos, 00363 _mfVertices[i].transformedPos); 00364 } 00365 00366 UInt32 numTriangles = _mfTriangles.size(); 00367 00368 // transform triangle normals to volume's space 00369 for(UInt32 i = 0; i < numTriangles; i++) 00370 { 00371 toVolumeSpaceInvT.multMatrixVec(_mfTriangles[i].normal, 00372 _mfTriangles[i].transformedNormal); 00373 00374 _mfTriangles[i].transformedNormal.normalize(); 00375 } 00376 }
|
|
|
Definition at line 379 of file OSGDVRClipGeometry.cpp. References _mfTriangles, _mfVertices, and osg::DVRVertex::behindPlane. 00380 { 00381 UInt32 numVertices = _mfVertices.size(); 00382 00383 for(UInt32 i = 0; i < numVertices; i++) 00384 { 00385 DVRVertex &vertex = _mfVertices[i]; 00386 00387 vertex.behindPlane = false; 00388 } 00389 00390 UInt32 numTriangles = _mfTriangles.size(); 00391 00392 // initialize the triangles local data 00393 for(UInt32 i = 0; i < numTriangles; i++) 00394 { 00395 _mfTriangles[i].visited = false; 00396 _mfTriangles[i].inContour = false; 00397 00398 for (UInt32 j = 0; j < 3; j++) 00399 _mfTriangles[i].edgeCut[j] = false; 00400 } 00401 }
|
|
|
Definition at line 403 of file OSGDVRClipGeometry.cpp. References _mfVertices. 00404 { 00405 UInt32 numVertices = _mfVertices.size(); 00406 00407 for(UInt32 i = 0; i < numVertices; i++) 00408 _mfVertices[i].calculatePlaneDistanceTransformed(referencePlane); 00409 }
|
|
|
basically there are two attributes available, the vertex position and a 3D texture coordinate. If one needs additional attributes, e.g. color, texture coordinates,.., the number of (double) values needed has to be set with this function. Definition at line 776 of file OSGDVRClipGeometry.cpp. References _mfTriangles. 00778 { 00779 UInt32 numTriangles = _mfTriangles.size(); 00780 00781 // update triangles 00782 for(UInt32 i = 0; i < numTriangles; i++) 00783 { 00784 if(!_mfTriangles[i].setNumAddPerVertexAttr( 00785 additionalPerVertexAttributes)) 00786 { 00787 return false; 00788 } 00789 } 00790 00791 return true; 00792 }
|
|
|
Definition at line 411 of file OSGDVRClipGeometry.cpp. References _mfVertices, activeTrianglesCount, initialized, isLocalMinimum(), maxSeedVerticesCount, seedVertices, and seedVerticesCount. 00412 { 00413 if(!initialized) 00414 return; 00415 00416 // clear seed vertex list and active triangle list 00417 seedVerticesCount = 0; 00418 activeTrianglesCount = 0; 00419 00420 UInt32 numVertices = _mfVertices.size(); 00421 00422 // compute initial seed vertex set 00423 for(UInt32 i = 0; i < numVertices; i++) 00424 { 00425 if(isLocalMinimum(_mfVertices[i])) 00426 { 00427 if(maxSeedVerticesCount <= seedVerticesCount) 00428 { 00429 maxSeedVerticesCount *= 2; 00430 00431 seedVertices = 00432 (DVRVertex **)realloc(seedVertices, 00433 maxSeedVerticesCount * 00434 sizeof(DVRVertex *) ); 00435 } 00436 00437 seedVertices[seedVerticesCount++] = &_mfVertices[i]; 00438 } 00439 } 00440 }
|
|
||||||||||||||||
|
Definition at line 637 of file OSGDVRClipGeometry.cpp. References buildContours(), contours, initialized, and updateActiveTriangles(). 00641 { 00642 if(!initialized) 00643 return contours; 00644 00645 // compute new active triangle set and for this slice 00646 // and update seed vertex set 00647 updateActiveTriangles(dist2RefPlane, sliceNormal); 00648 00649 // build contours from active triangle set 00650 buildContours(dist2RefPlane, positiveWinding, sliceNormal); 00651 00652 return contours; 00653 }
|
|
|
if there already exists a vertex at the position of the new vertex they get unified, i.e. the index of the already existent vertex is returned, else a new one is inserted Definition at line 140 of file OSGDVRClipGeometry.cpp. References _mfVertices, geometry, and osg::DVRVertex::pos. Referenced by buildTriangledGeometry(). 00141 { 00142 for(UInt32 i = 0; i < _mfVertices.size(); i++) 00143 { 00144 if(_mfVertices[i].pos == geometry->getPositions()->getValue(idx)) 00145 return i; 00146 } 00147 00148 DVRVertex newVertex; 00149 00150 newVertex.pos = geometry->getPositions()->getValue(idx); 00151 00152 _mfVertices.push_back(newVertex); 00153 00154 return _mfVertices.size() - 1; 00155 }
|
|
|
returns true, iff this vertex is a local minimum with respect to refPlaneDistance. Definition at line 48 of file OSGDVRClipGeometry.inl. References _mfTriangles, _mfVertices, osg::DVRVertex::adjacentTriangles, and osg::DVRVertex::refPlaneDistance. Referenced by computeSeedVertices(). 00049 { 00050 for(MFInt32::const_iterator triIdx = vertex.adjacentTriangles.begin(); 00051 triIdx != vertex.adjacentTriangles.end (); 00052 triIdx++) 00053 { 00054 const Int32 *vertIndices = _mfTriangles[*triIdx].vertices; 00055 00056 for(unsigned int j = 0; j < 3; j++) 00057 { 00058 if (&_mfVertices[vertIndices[j]] != &vertex) 00059 { 00060 if(_mfVertices[vertIndices[j]].isCloser( 00061 vertex.refPlaneDistance)) 00062 { 00063 return false; 00064 } 00065 } 00066 } 00067 } 00068 00069 return true; 00070 }
|
|
||||||||||||||||
|
returns true, iff the plane with distance dist2RefPlane to the ref plane cuts the triangle. Definition at line 262 of file OSGDVRClipGeometry.cpp. References _mfVertices, osg::DVRTriangle::edgeCut, and osg::DVRTriangle::vertices. Referenced by addNewActiveTriangles(), and updateActiveTriangles(). 00265 { 00266 bool v[3] = {false, false, false}; 00267 00268 bool vertexSwitched; 00269 int countSwitchedVertices = 0; 00270 00271 switchedVertices[0] = NULL; 00272 switchedVertices[1] = NULL; 00273 switchedVertices[2] = NULL; 00274 00275 // for every vertex, check if it is in front of or behind the current 00276 // reference plane and if it has moved behind the plane 00277 00278 for(UInt32 i = 0; i < 3; i++) 00279 { 00280 v[i] = _mfVertices[tri->vertices[i]].isBehindPlane(dist2RefPlane, 00281 vertexSwitched); 00282 if(vertexSwitched) 00283 { 00284 vertexSwitched = false; 00285 00286 switchedVertices[countSwitchedVertices] = 00287 &_mfVertices[tri->vertices[i]]; 00288 00289 countSwitchedVertices++; 00290 } 00291 } 00292 00293 bool cut = false; 00294 00295 // remember the cut edges for faster (and correct ;-) contour tracing... 00296 for(UInt32 i = 0; i < 3; i++) 00297 { 00298 if(v[i] ^ v[(i + 1) % 3]) 00299 { 00300 tri->edgeCut[i] = true; 00301 cut = true; 00302 } 00303 else 00304 { 00305 tri->edgeCut[i] = false; 00306 } 00307 } 00308 00309 return cut; 00310 }
|
|
||||||||||||
|
returns true, iff dist2RefPlane is bigger than the distance to the reference plane of all vertices within the triangle. Definition at line 85 of file OSGDVRClipGeometry.inl. References _mfVertices, and osg::DVRTriangle::vertices. 00087 { 00088 bool switched; 00089 bool v[3]; 00090 00091 for(unsigned int i = 0; i < 3; i++) 00092 { 00093 v[i] = 00094 _mfVertices[tri.vertices[i]].isBehindPlane(dist2RefPlane,switched); 00095 } 00096 00097 return (v[0] && v[1] && v[2]); 00098 }
|
|
|
Definition at line 73 of file OSGDVRClipGeometry.inl. References _mfVertices, and osg::DVRTriangle::vertices. 00074 { 00075 glBegin(GL_TRIANGLES); 00076 { 00077 for(unsigned int i = 0; i < 3; i++) 00078 glVertex3fv( 00079 _mfVertices[tri.vertices[i]].transformedPos.getValues()); 00080 } 00081 glEnd(); 00082 }
|
|
|
Definition at line 158 of file OSGDVRClipGeometry.cpp. References _mfTriangles, _mfVertices, osg::DVRVertex::adjacentTriangles, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::cross(), osg::DVRTriangle::cutPnt, osg::DVRTriangle::cutPoint, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), geometry, osg::TriangleIterator::getNormal(), osg::TriangleIterator::getPositionIndex(), insertVertex(), osg::PointInterface< ValueTypeT, StorageInterfaceT >::negate(), osg::DVRTriangle::normal, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), SLOG, and osg::DVRTriangle::vertices. Referenced by initialize(). 00159 { 00160 // create triangles 00161 for(TriangleIterator triangleIt = geometry->beginTriangles(); 00162 triangleIt != geometry->endTriangles (); 00163 ++triangleIt) 00164 { 00165 DVRTriangle newTriangle; 00166 00167 for(UInt32 i = 0; i < 3; i++) 00168 { 00169 Int32 vertexIndex = triangleIt.getPositionIndex(i); 00170 00171 vertexIndex = insertVertex(vertexIndex); 00172 00173 newTriangle.vertices[i] = vertexIndex; 00174 00175 _mfVertices[vertexIndex].adjacentTriangles.push_back( 00176 _mfTriangles.size()); 00177 00178 newTriangle.cutPnt [i] = 0.0; 00179 newTriangle.cutPoint[i] = 0.0; 00180 } 00181 00182 // compute normal and check orientation 00183 newTriangle.normal = 00184 (_mfVertices[newTriangle.vertices[0]].pos - 00185 _mfVertices[newTriangle.vertices[1]].pos).cross( 00186 _mfVertices[newTriangle.vertices[0]].pos - 00187 _mfVertices[newTriangle.vertices[2]].pos); 00188 00189 newTriangle.normal.normalize(); 00190 00191 if(newTriangle.normal.dot(triangleIt.getNormal(0)) < 0.0) 00192 newTriangle.normal.negate(); 00193 00194 _mfTriangles.push_back(newTriangle); 00195 } 00196 00197 // find neighbouring triangles 00198 for(UInt32 i = 0; i < _mfTriangles.size(); i++) 00199 { 00200 Int32 *vertices = _mfTriangles[i].vertices; 00201 00202 for(UInt32 l = 0; l < 3; l++) 00203 { 00204 const DVRVertex &v0 = _mfVertices[vertices[l]]; 00205 const DVRVertex &v1 = _mfVertices[vertices[(l + 1) % 3]]; 00206 00207 for(UInt32 j = 0; j < v0.adjacentTriangles.size(); j++) 00208 { 00209 for(UInt32 k = 0; k < v1.adjacentTriangles.size(); k++) 00210 { 00211 if(v0.adjacentTriangles[j] == v1.adjacentTriangles[k] && 00212 v0.adjacentTriangles[j] != i && 00213 v1.adjacentTriangles[k] != i ) 00214 { 00215 if(_mfTriangles[i].neighbours[l] != -1) 00216 { 00217 SLOG << "Error: Could not build clip geometry" 00218 << std::endl 00219 << " one triangle edge shared by more " 00220 << "than two triangles" 00221 << std::endl; 00222 00223 return false; 00224 } 00225 00226 _mfTriangles[i].neighbours[l] = 00227 v1.adjacentTriangles[k]; 00228 } 00229 } 00230 } 00231 } 00232 } 00233 00234 // check for non-closed geometry 00235 UInt32 checkCount = 0; 00236 00237 for(UInt32 i = 0; i < _mfTriangles.size(); i++) 00238 { 00239 for(UInt32 j = 0; j < 3; j++) 00240 { 00241 if(_mfTriangles[i].neighbours[j] == -1) 00242 { 00243 checkCount++; 00244 } 00245 } 00246 } 00247 00248 if(checkCount > 0) 00249 { 00250 SLOG << "Error: Could not build clip geometry" 00251 << std::endl 00252 << checkCount 00253 << "open edges found!" 00254 << std::endl; 00255 00256 return false; 00257 } 00258 00259 return true; 00260 }
|
|
||||||||||||||||
|
Definition at line 614 of file OSGDVRClipGeometry.cpp. References activeTriangles, activeTrianglesCount, contours, osg::DVRTriangle::inContour, and linkContour(). Referenced by getContours(). 00617 { 00618 contours.clear(); 00619 00620 for(UInt32 i = 0; i < activeTrianglesCount; i++) 00621 { 00622 DVRTriangle* currentTriangle = activeTriangles[i]; 00623 00624 // if the triangle is already in a contour we can skip it 00625 if(!currentTriangle->inContour) 00626 { 00627 contours.push_back(currentTriangle); 00628 00629 linkContour(currentTriangle, 00630 dist2RefPlane, 00631 sliceNormal, 00632 positiveWinding); 00633 } 00634 } 00635 }
|
|
||||||||||||||||||||
|
Definition at line 442 of file OSGDVRClipGeometry.cpp. References _mfTriangles, osg::DVRTriangle::contourNeighbour, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::cross(), osg::DVRTriangle::cutPnt, osg::DVRTriangle::cutPoint, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::DVRTriangle::edgeCut, FDEBUG, osg::DVRTriangle::inContour, interpolate(), osg::DVRTriangle::neighbours, and osg::DVRTriangle::transformedNormal. Referenced by buildContours(). 00446 { 00447 FDEBUG(("DVRClipGeometry - linkcontour dist = %f\n", dist2RefPlane)); 00448 00449 bool closed = false; 00450 00451 // first, we have to check for the correct winding direction. 00452 00453 Pnt3f vertex[2]; 00454 bool firstEdge; 00455 int first = 0, second = 0; 00456 00457 if(startTriangle->edgeCut[0] && startTriangle->edgeCut[1]) 00458 { 00459 vertex[0] = interpolate(startTriangle, 1, 0, dist2RefPlane); 00460 vertex[1] = interpolate(startTriangle, 1, 2, dist2RefPlane); 00461 00462 first = 0; second = 1; 00463 } 00464 else if (startTriangle->edgeCut[1] && startTriangle->edgeCut[2]) 00465 { 00466 vertex[0] = interpolate(startTriangle, 2, 1, dist2RefPlane); 00467 vertex[1] = interpolate(startTriangle, 2, 0, dist2RefPlane); 00468 00469 first = 1; second = 2; 00470 } 00471 else if (startTriangle->edgeCut[0] && startTriangle->edgeCut[2]) 00472 { 00473 vertex[0] = interpolate(startTriangle, 0, 1, dist2RefPlane); 00474 vertex[1] = interpolate(startTriangle, 0, 2, dist2RefPlane); 00475 00476 first = 0; second = 2; 00477 } 00478 00479 // Now we should have both cut points on our edges. 00480 00481 // If the cross product of the normal of this triangle with the 00482 // vector between the two cut points (cutPoint[1] - cutPoint[0]) 00483 // has a positive dot product with the viewing direction, then 00484 // the edge with cutPoint[0] on it is the right direction, otherwise 00485 // we would have to choose the other direction. 00486 00487 Vec3f tmp = vertex[1] - vertex[0]; 00488 00489 tmp = tmp.cross(startTriangle->transformedNormal); 00490 00491 if(tmp.dot(viewDir) <= 0.0) 00492 { 00493 firstEdge = false; 00494 }else 00495 { 00496 firstEdge = true; 00497 } 00498 00499 if(!positiveWinding) 00500 firstEdge = !firstEdge; 00501 00502 DVRTriangle *current = startTriangle; 00503 00504 current->inContour = true; 00505 00506 if(firstEdge) 00507 { 00508 current->cutPnt = vertex[0]; 00509 current->cutPoint[0] = vertex[0][0]; 00510 current->cutPoint[1] = vertex[0][1]; 00511 current->cutPoint[2] = vertex[0][2]; 00512 00513 current->contourNeighbour = &_mfTriangles[current->neighbours[first]]; 00514 00515 // // debugging -> remove 00516 // if(!current->contourNeighbour){ 00517 // std::cerr<<"contour neighbour is NULL\n"; 00518 // exit(0); 00519 // } 00520 00521 current = current->contourNeighbour; |