Hi Robert,

Thank you for your answer. Unfortunately, I cannot share the model ...
However, I can share the code.

Here it is:

// Building a osgUtil::PolytopeIntersector from a CONCAVE planar polygon

        /* 1) split the concave polygon in its convex rings */
        /* 2) iterate over each convex ring to build a convex osg::Polyope
*/

        // Begin loop over convex rings
        osg::Polytope currentBuildingPolytope;
        for(int j=0;j<ring.getNumPoints()-1;++j)
        {
        osg::Vec3d A( ring.getX(j),   ring.getY(j),   ring.getZ(j)   );
        osg::Vec3d B( ring.getX(j+1), ring.getY(j+1), ring.getZ(j+1) );
        osg::Vec3d C( ring.getX(j+1), ring.getY(j+1), ring.getZ(j+1)+delta
); // delta > 0.

        osg::Vec3d AB = B-A; AB.normalize();
        osg::Vec3d BC = C-B; BC.normalize();
        osg::Vec3d n = BC^AB; n.normalize();

            osg::Plane p(n,A);
            currentBuildingPolytope.add(p);
        }
        osg::ref_ptr<osgUtil::PolytopeIntersector>
currentPolytopeIntersector = new
osgUtil::PolytopeIntersector(currentBuildingPolytope);

currentPolytopeIntersector->setDimensionMask(osgUtil::PolytopeIntersector::DimTwo);
        // End loop over convex rings

        /* 3) add the convex osg::Polytope to a vector<
ref_ptr<osgUtil::PolytopeIntersector> > */
        _polytopeIntersectors.push_back(currentPolytopeIntersector);

        /* 4) Find intersections of the model with the previously build
osgUtil::PolytopeIntersectors */
        bool hasIntersections = false;
        for(unsigned int i=0;i<_polytopeIntersectors.size();++i)
        {
            osgUtil::IntersectionVisitor
visitor(_polytopeIntersectors[i].get());
            osg::ref_ptr<osgSim::DatabaseCacheReadCallback> _readCallback =
new osgSim::DatabaseCacheReadCallback;
            visitor.setReadCallback(_readCallback);
            model->accept(visitor); // model contains one triangle per
Drawable

            if(_polytopeIntersectors[i]->containsIntersections())
            {
                hasIntersections = true;
                _numIntersections +=
_polytopeIntersectors[i]->getIntersections().size();
                // ...
            }
        // ...
        }

If you see anything wrong, please let me know.

As I tols in my first post, the reader callback works quite well (my DB
model contains around 150 files). Debugging my application, the method
IntersectionVisitor::apply(osg::PagedLOD& plod) exits on the first line
only if _intersectorStack.back()->enter(node); returns false. This happen
in LineSegmentIntersector::intersects(const osg::BoundingSphere& bs),
because of this line:
 if (d<0.0) return false;
which seems to mean that the bounding sphere of the current PagedLOD is not
intersected by the line.

Hope this give you more :)

Regards,

Olivier


2013/11/21 Robert Osfield <robert.osfi...@gmail.com>

> Hi Oliver,
>
> I have looked at the OSG code and can't see a specific cause, but then I
> don't have your code or models so it's all just guessing.
>
> Does LineOfSight work fine for you?  If so I'd recommend stepping through
> to see what happening and then compare it with your own usage.
>
> Robert.
>
>
> On 19 November 2013 19:58, Olivier Tournaire <olit...@gmail.com> wrote:
>
>> Hi all,
>>
>> Sorry for the noise, but, as I did not receive any answer, I am
>> interested if someone has an idea on the topic.
>>
>> Regards,
>>
>> Olivier
>>
>>
>> 2013/11/15 Olivier Tournaire <olit...@gmail.com>
>>
>>> Hi,
>>>
>>> I am currently trying to retrieve some specific triangles in a PagedLOD
>>> model. To do so, I use a PolytopeIntersector with an IntersectionVisitor.
>>> As my model is a PagedLOD, I have set up a reader callback, directly taken
>>> from osgSim::LineOfSight.
>>>
>>> The intersector works, but not as expected: it gives me the triangles at
>>> the lowest resolution, whereas I would expect to have them at the finest
>>> LOD. Debugging my program showed me that the void
>>> IntersectionVisitor::apply(osg::PagedLOD& plod) method goes where it has to
>>> (i.e., it traverses correctly all childs until the best resolution).
>>>
>>> As the IntersectionVisitor sets up by default to use
>>> the USE_HIGHEST_LEVEL_OF_DETAIL flag, I am wondering if I am missing
>>> something and if you could give some pointers on how to achieve triangles
>>> extraction at the finest LOD.
>>>
>>> The "header" root file is:
>>>
>>> osg::PagedLOD {
>>>   UniqueID 1
>>>   Name "Tile_+001_+006.osgb"
>>>   CenterMode USER_DEFINED_CENTER
>>>   UserCenter -741.555 904.039 94.1168 213.403
>>>   RangeMode PIXEL_SIZE_ON_SCREEN
>>>   RangeList 2 {
>>>     0 106.702
>>>     106.702 1e+030
>>>   }
>>>   DatabasePath FALSE
>>>   RangeDataList 2 {
>>>     ""
>>>     "Tile_+001_+006_L15_0.osgb"
>>>   }
>>>   PriorityList 2 {
>>>     0 1
>>>     0 1
>>>   }
>>>
>>> The "header" of the child file (Tile_+001_+006_L15_0.osgb) is:
>>>
>>> osg::PagedLOD {
>>>   UniqueID 1
>>>   Name "Tile_+001_+006_L15_0.osgb"
>>>   CenterMode USER_DEFINED_CENTER
>>>   UserCenter -741.869 906.466 94.7166 206.312
>>>   RangeMode PIXEL_SIZE_ON_SCREEN
>>>   RangeList 2 {
>>>     0 206.312
>>>     206.312 1e+030
>>>   }
>>>   DatabasePath FALSE
>>>   RangeDataList 2 {
>>>     ""
>>>     "Tile_+001_+006_L16_00.osgb"
>>>   }
>>>   PriorityList 2 {
>>>     0 1
>>>     0 1
>>>   }
>>>
>>>
>>> Hope you could help
>>>
>>> Regards,
>>>
>>> Olivier
>>>
>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to