Loading files
f2929057eThis file is pinned to the selected release. Download the original to open it in your design tool.
// Created on: 1995-12-08
// Created by: Jean Yves LEBEY
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <TopOpeBRepDS_DataStructure.hxx>
#include <TopOpeBRepDS_Point.hxx>
#include <TopOpeBRepDS_PointExplorer.hxx>
#define MYDS (*((TopOpeBRepDS_DataStructure*)myDS))
namespace
{
//=================================================================================================
const TopOpeBRepDS_Point& EmptyPoint()
{
static const TopOpeBRepDS_Point anEmptyPoint;
return anEmptyPoint;
}
} // namespace
//=================================================================================================
TopOpeBRepDS_PointExplorer::TopOpeBRepDS_PointExplorer()
: myIndex(1),
myMax(0),
myDS(nullptr),
myFound(false),
myFindKeep(false)
{
}
//=================================================================================================
TopOpeBRepDS_PointExplorer::TopOpeBRepDS_PointExplorer(const TopOpeBRepDS_DataStructure& DS,
const bool FindKeep)
{
Init(DS, FindKeep);
}
//=================================================================================================
void TopOpeBRepDS_PointExplorer::Init(const TopOpeBRepDS_DataStructure& DS, const bool FindKeep)
{
myIndex = 1;
myMax = DS.NbPoints();
myDS = (TopOpeBRepDS_DataStructure*)&DS;
myFindKeep = FindKeep;
Find();
}
//=================================================================================================
void TopOpeBRepDS_PointExplorer::Find()
{
myFound = false;
while (myIndex <= myMax)
{
if (myFindKeep)
{
myFound = IsPointKeep(myIndex);
}
else
{
myFound = IsPoint(myIndex);
}
if (myFound)
{
break;
}
else
{
myIndex++;
}
}
}
//=================================================================================================
bool TopOpeBRepDS_PointExplorer::More() const
{
return myFound;
}
//=================================================================================================
void TopOpeBRepDS_PointExplorer::Next()
{
myIndex++;
Find();
}
//=================================================================================================
const TopOpeBRepDS_Point& TopOpeBRepDS_PointExplorer::Point() const
{
if (myFound)
{
return MYDS.Point(myIndex);
}
else
{
return EmptyPoint();
}
}
//=================================================================================================
bool TopOpeBRepDS_PointExplorer::IsPoint(const int I) const
{
bool b = MYDS.myPoints.IsBound(I);
return b;
}
//=================================================================================================
bool TopOpeBRepDS_PointExplorer::IsPointKeep(const int I) const
{
bool b = MYDS.myPoints.IsBound(I);
if (b)
{
b = MYDS.Point(I).Keep();
}
return b;
}
//=================================================================================================
const TopOpeBRepDS_Point& TopOpeBRepDS_PointExplorer::Point(const int I) const
{
if (IsPoint(I))
{
return MYDS.Point(I);
}
else
{
return EmptyPoint();
}
}
//=================================================================================================
int TopOpeBRepDS_PointExplorer::NbPoint()
{
myIndex = 1;
myMax = MYDS.NbPoints();
Find();
int n = 0;
for (; More(); Next())
{
n++;
}
return n;
}
//=================================================================================================
int TopOpeBRepDS_PointExplorer::Index() const
{
return myIndex;
}