Changeset 1206
- Timestamp:
- 05/07/08 18:41:36 (2 weeks ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/System/NodeCores/Drawables/Geometry/Base/WS/OSGGeometry.cpp
r1198 r1206 175 175 void Geometry::adjustVolume(Volume & volume) 176 176 { 177 volume.setValid();178 volume.setEmpty();179 180 177 GeoVectorProperty *pos = getPositions(); 181 178 … … 183 180 return; // Node has no points, no volume 184 181 185 Pnt3f p; 186 187 PrimitiveIterator it,end = this->endPrimitives(); 188 189 for(it = this->beginPrimitives(); it != end; ++it) 190 { 191 for(UInt32 v=0; v < it.getLength(); ++v) 182 volume.setValid(); 183 184 PrimitiveIterator it = this->beginPrimitives(); 185 PrimitiveIterator end = this->endPrimitives (); 186 187 for(; it != end; ++it) 188 { 189 for(UInt32 v = 0; v < it.getLength(); ++v) 192 190 { 193 191 volume.extendBy(it.getPosition(v)); trunk/Source/System/NodeCores/Drawables/Geometry/Base/WS/OSGGeometryTest.cpp
r815 r1206 44 44 #include <OpenSG/OSGFieldContainerFactory.h> 45 45 #include <OpenSG/OSGTypedGeoVectorProperty.h> 46 #include <OpenSG/OSGSimpleGeometry.h> 47 #include <OpenSG/OSGTransform.h> 46 48 47 49 SUITE(GeometryTests) … … 50 52 TEST(CreateGeometry) 51 53 { 52 OSG::Geometry Ptr g = OSG::Geometry::create();53 CHECK(g != OSGNullFC);54 OSG::GeometryUnrecPtr g = OSG::Geometry::create(); 55 CHECK(g != NULL); 54 56 } 55 57 56 58 TEST(TestInitialValues) 57 59 { 58 OSG::Geometry Ptr g = OSG::Geometry::create();59 CHECK(g != OSGNullFC);60 OSG::GeometryUnrecPtr g = OSG::Geometry::create(); 61 CHECK(g != NULL); 60 62 61 63 for(unsigned i=0;i<OSG::Geometry::MaxAttribs;i++) 62 64 { 63 CHECK(g->getProperty(i) == OSGNullFC);64 CHECK(g->getIndex(i) == OSGNullFC);65 CHECK(g->getProperty(i) == NULL); 66 CHECK(g->getIndex(i) == NULL); 65 67 } 66 68 67 CHECK(g->getMaterial() == OSGNullFC);69 CHECK(g->getMaterial() == NULL); 68 70 } 69 71 … … 71 73 TEST(TestGenericInterfaces) 72 74 { 73 OSG::Geometry Ptr g = OSG::Geometry::create();74 CHECK(g != OSGNullFC);75 76 OSG::GeoPnt3fProperty Ptr pnts = OSG::GeoPnt3fProperty ::create();75 OSG::GeometryUnrecPtr g = OSG::Geometry::create(); 76 CHECK(g != NULL); 77 78 OSG::GeoPnt3fPropertyUnrecPtr pnts = OSG::GeoPnt3fProperty ::create(); 77 79 pnts->addValue(OSG::Pnt3f(0,0,0)); 78 80 79 81 g->setPositions(pnts); 80 82 81 OSG::GeoVectorProperty Ptr pnts_g = g->getPositions();83 OSG::GeoVectorPropertyUnrecPtr pnts_g = g->getPositions(); 82 84 pnts_g->setValue(OSG::Pnt3f(1,1,1), 0); 83 85 pnts_g->setValue(OSG::Pnt3s(1,1,1), 0); … … 94 96 { 95 97 // Test setting attributes to all possible value types 96 OSG::Geometry Ptr g = OSG::Geometry::create();97 CHECK(g != OSGNullFC);98 OSG::GeometryUnrecPtr g = OSG::Geometry::create(); 99 CHECK(g != NULL); 98 100 99 101 // Copied-and-macroed from OSGTypedGeoVectorPropertyFields … … 228 230 }; 229 231 230 OSG::GeoVectorProperty Ptr att;232 OSG::GeoVectorPropertyUnrecPtr att; 231 233 232 234 unsigned num_vec_props = sizeof(allowed_vec_prop_types) / sizeof(char*); … … 234 236 for(unsigned i = 0; i < num_vec_props;++i) 235 237 { 236 att = dynamic_cast<OSG::GeoVectorPropertyPtr>(238 att = OSG::dynamic_pointer_cast<OSG::GeoVectorProperty>( 237 239 OSG::FieldContainerFactory::the()->createContainer( 238 240 allowed_vec_prop_types[i])); … … 244 246 } 245 247 248 TEST(GeometryAsInnerNodesBoundingVolume) 249 { 250 // pNGeo0:[Geometry] 251 // | 252 // +-------------------------------------+ 253 // | | 254 // pNTrans1:pTrans1[Transform] pNTran2:pTrans2[Transform] 255 // | | 256 // pNGeo1:[Geometry] pNGeo2:[Geometry] 257 258 OSG::NodeUnrecPtr pNGeo0 = OSG::makeBox(2.0, 2.0, 4.0, 1, 1, 1); 259 OSG::NodeUnrecPtr pNGeo1 = OSG::makeBox(2.0, 2.0, 2.0, 1, 1, 1); 260 OSG::NodeUnrecPtr pNGeo2 = OSG::makeBox(2.0, 2.0, 2.0, 1, 1, 1); 261 262 OSG::NodeUnrecPtr pNTrans1 = OSG::Node::create(); 263 OSG::TransformUnrecPtr pTrans1 = OSG::Transform::create(); 264 OSG::NodeUnrecPtr pNTrans2 = OSG::Node::create(); 265 OSG::TransformUnrecPtr pTrans2 = OSG::Transform::create(); 266 267 pNTrans1->setCore (pTrans1); 268 pNTrans1->addChild(pNGeo1 ); 269 pNTrans2->setCore (pTrans2); 270 pNTrans2->addChild(pNGeo2 ); 271 272 pNGeo0->addChild(pNTrans1); 273 pNGeo0->addChild(pNTrans2); 274 275 OSG::Matrix mat1; 276 OSG::Matrix mat2; 277 278 mat1.setTranslate(OSG::Vec3f( 3.0, 0.0, 0.0)); 279 mat2.setTranslate(OSG::Vec3f(- 3.0, 0.0, 0.0)); 280 281 pTrans1->editSFMatrix()->setValue(mat1); 282 pTrans2->editSFMatrix()->setValue(mat2); 283 284 OSG::commitChanges(); 285 286 OSG::DynamicVolume bbox; 287 OSG::Pnt3f min; 288 OSG::Pnt3f max; 289 290 pNGeo1->getWorldVolume(bbox); 291 bbox.getBounds(min, max); 292 293 CHECK_CLOSE( 2.0, min[0], 1e-6); 294 CHECK_CLOSE(-1.0, min[1], 1e-6); 295 CHECK_CLOSE(-1.0, min[2], 1e-6); 296 297 CHECK_CLOSE( 4.0, max[0], 1e-6); 298 CHECK_CLOSE( 1.0, max[1], 1e-6); 299 CHECK_CLOSE( 1.0, max[2], 1e-6); 300 301 pNGeo2->getWorldVolume(bbox); 302 bbox.getBounds(min, max); 303 304 CHECK_CLOSE(-4.0, min[0], 1e-6); 305 CHECK_CLOSE(-1.0, min[1], 1e-6); 306 CHECK_CLOSE(-1.0, min[2], 1e-6); 307 308 CHECK_CLOSE(-2.0, max[0], 1e-6); 309 CHECK_CLOSE( 1.0, max[1], 1e-6); 310 CHECK_CLOSE( 1.0, max[2], 1e-6); 311 312 pNGeo0->getWorldVolume(bbox); 313 bbox.getBounds(min, max); 314 315 CHECK_CLOSE(-4.0, min[0], 1e-6); 316 CHECK_CLOSE(-1.0, min[1], 1e-6); 317 CHECK_CLOSE(-2.0, min[2], 1e-6); 318 319 CHECK_CLOSE( 4.0, max[0], 1e-6); 320 CHECK_CLOSE( 1.0, max[1], 1e-6); 321 CHECK_CLOSE( 2.0, max[2], 1e-6); 322 } 323 246 324 } // SUITE 247 325
