IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
-//HYDROData_QuadtreeNode* HYDROData_Bathymetry::myQuadtree = 0;
-int HYDROData_Bathymetry::myQuadTreeNumber = 0;
+//int HYDROData_Bathymetry::myQuadTreeNumber = 0;
std::map<int, HYDROData_QuadtreeNode*> HYDROData_Bathymetry::myQuadtrees;
#ifndef LIGHT_MODE
-int HYDROData_Bathymetry::myDelaunayNumber = 0;
+//int HYDROData_Bathymetry::myDelaunayNumber = 0;
std::map<int, vtkPolyData*> HYDROData_Bathymetry::myDelaunay2D;
#endif
if (aLabel.IsNull())
return 0;
- Handle(TDataStd_RealArray) aCoordsArray;
- if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), aCoordsArray))
- return 0;
-
- myQuadTreeNumber++;
- TDataStd_Integer::Set( myLab.FindChild( DataTag_Quadtree ), myQuadTreeNumber );
- DEBTRACE("GetQuadtreeNodes init " << this << " " << myQuadTreeNumber);
- HYDROData_QuadtreeNode* aQuadtree = new HYDROData_QuadtreeNode(0, 30, 5, 0.);
- myQuadtrees[myQuadTreeNumber] = aQuadtree;
-
- Nodes_3D* aListOfNodes = new Nodes_3D();
-
- int index =0;
- for (int i = aCoordsArray->Lower(), n = aCoordsArray->Upper(); i <= n;)
+ int aQuadTreeNumber = 0;
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( ! aDocument.IsNull() )
{
- if (i + 3 > n + 1)
- break;
-
- double x = aCoordsArray->Value(i++);
- double y = aCoordsArray->Value(i++);
- double z = aCoordsArray->Value(i++);
- gpi_XYZ* aPoint = new gpi_XYZ(x, y, z, index);
- index++;
- aListOfNodes->push_back(aPoint);
+ aQuadTreeNumber = aDocument->GetCountQuadtree();
+ DEBTRACE("aQuadTreeNumber " << aQuadTreeNumber);
+ aQuadTreeNumber++;
+ aDocument->SetCountQuadtree(aQuadTreeNumber);
}
- DEBTRACE(" GetQuadtreeNodes call setNodesAndCompute");
- aQuadtree->setNodesAndCompute(aListOfNodes);
+ else
+ DEBTRACE("document.IsNull()");
+ DEBTRACE("compute Quadtree "<< aQuadTreeNumber);
+ HYDROData_QuadtreeNode* aQuadtree = ComputeQuadtreeNodes(aQuadTreeNumber);
return aQuadtree;
}
else
{
if (myQuadtrees.find(aQuadtreeNum->Get()) != myQuadtrees.end())
return myQuadtrees[aQuadtreeNum->Get()];
- else DEBTRACE("myQuadtrees["<<aQuadtreeNum->Get()<<"] does not exists!");
+ else
+ {
+ DEBTRACE("recompute Quadtree "<< aQuadtreeNum->Get());
+ HYDROData_QuadtreeNode* aQuadtree = ComputeQuadtreeNodes(aQuadtreeNum->Get());
+ return aQuadtree;
+ }
}
else DEBTRACE("no attribute TDataStd_Integer");
}
return 0;
}
+HYDROData_QuadtreeNode* HYDROData_Bathymetry::ComputeQuadtreeNodes( int key) const
+{
+ TDF_Label aLabel = myLab.FindChild(DataTag_AltitudePoints, false);
+ if (aLabel.IsNull())
+ return 0;
+
+ Handle(TDataStd_RealArray) aCoordsArray;
+ if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), aCoordsArray))
+ return 0;
+
+ TDataStd_Integer::Set( myLab.FindChild( DataTag_Quadtree ), key );
+ DEBTRACE("GetQuadtreeNodes init " << this << " " << key);
+ HYDROData_QuadtreeNode* aQuadtree = new HYDROData_QuadtreeNode(0, 30, 5, 0.);
+ myQuadtrees[key] = aQuadtree;
+
+ Nodes_3D* aListOfNodes = new Nodes_3D();
+
+ int index =0;
+ for (int i = aCoordsArray->Lower(), n = aCoordsArray->Upper(); i <= n;)
+ {
+ if (i + 3 > n + 1)
+ break;
+
+ double x = aCoordsArray->Value(i++);
+ double y = aCoordsArray->Value(i++);
+ double z = aCoordsArray->Value(i++);
+ gpi_XYZ* aPoint = new gpi_XYZ(x, y, z, index);
+ index++;
+ aListOfNodes->push_back(aPoint);
+ }
+ DEBTRACE(" GetQuadtreeNodes call setNodesAndCompute");
+ aQuadtree->setNodesAndCompute(aListOfNodes);
+ return aQuadtree;
+}
+
#ifndef LIGHT_MODE
vtkPolyData* HYDROData_Bathymetry::GetVtkDelaunay2D() const
{
if (aLabel.IsNull())
return 0;
- Handle(TDataStd_RealArray) aCoordsArray;
- if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), aCoordsArray))
- return 0;
-
- myDelaunayNumber++;
- TDataStd_Integer::Set( myLab.FindChild( DataTag_Delaunay ), myDelaunayNumber );
- DEBTRACE("GetVtkDelaunay2D init " << this << " " << myDelaunayNumber);
- vtkPoints *points = vtkPoints::New();
- points->Allocate(aCoordsArray->Upper() +1);
- for (int i = aCoordsArray->Lower(), n = aCoordsArray->Upper(); i <= n;)
+ int aDelaunayNumber = 0;
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( ! aDocument.IsNull() )
{
- if (i + 3 > n + 1)
- break;
- double x = aCoordsArray->Value(i++);
- double y = aCoordsArray->Value(i++);
- double z = aCoordsArray->Value(i++);
- vtkIdType index = points->InsertNextPoint(x, y, z); // same index than in GetQuadtreeNodes
- //DEBTRACE(" " << index);
+ aDelaunayNumber = aDocument->GetCountDelaunay();
+ DEBTRACE("aDelaunayNumber " << aDelaunayNumber);
+ aDelaunayNumber++;
+ aDocument->SetCountDelaunay(aDelaunayNumber);
}
- vtkPolyData* profile = vtkPolyData::New();
- profile->SetPoints(points);
- DEBTRACE("Number of Points: "<< points->GetNumberOfPoints());
-
- vtkDelaunay2D* delaunay2D = vtkDelaunay2D::New();
- delaunay2D->SetInputData(profile);
- delaunay2D->Update();
- vtkPolyData* data = delaunay2D->GetOutput();
- data->BuildLinks();
- myDelaunay2D[myDelaunayNumber] = data;
+ else
+ DEBTRACE("document.IsNull()");
+ DEBTRACE("compute Delaunay "<< aDelaunayNumber);
+ vtkPolyData* data = ComputeVtkDelaunay2D(aDelaunayNumber);
return data;
}
else
{
if (myDelaunay2D.find(aDelaunayNum->Get()) != myDelaunay2D.end())
return myDelaunay2D[aDelaunayNum->Get()];
- else DEBTRACE("myDelaunay2D["<<aDelaunayNum->Get()<<"] does not exists!");
+ else
+ {
+ DEBTRACE("recompute Delaunay "<< aDelaunayNum->Get());
+ vtkPolyData* data = ComputeVtkDelaunay2D(aDelaunayNum->Get());
+ return data;
+ }
}
else DEBTRACE("no attribute TDataStd_Integer");
}
return 0;
}
+
+vtkPolyData* HYDROData_Bathymetry::ComputeVtkDelaunay2D(int key) const
+{
+ TDF_Label aLabel = myLab.FindChild(DataTag_AltitudePoints, false);
+ if (aLabel.IsNull())
+ return 0;
+
+ Handle(TDataStd_RealArray) aCoordsArray;
+ if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), aCoordsArray))
+ return 0;
+
+ TDataStd_Integer::Set( myLab.FindChild( DataTag_Delaunay ), key );
+ DEBTRACE("GetVtkDelaunay2D init " << this << " " << key);
+ vtkPoints *points = vtkPoints::New();
+ points->Allocate(aCoordsArray->Upper() +1);
+ for (int i = aCoordsArray->Lower(), n = aCoordsArray->Upper(); i <= n;)
+ {
+ if (i + 3 > n + 1)
+ break;
+ double x = aCoordsArray->Value(i++);
+ double y = aCoordsArray->Value(i++);
+ double z = aCoordsArray->Value(i++);
+ vtkIdType index = points->InsertNextPoint(x, y, z); // same index than in GetQuadtreeNodes
+ //DEBTRACE(" " << index);
+ }
+ vtkPolyData* profile = vtkPolyData::New();
+ profile->SetPoints(points);
+ DEBTRACE("Number of Points: "<< points->GetNumberOfPoints());
+
+ vtkDelaunay2D* delaunay2D = vtkDelaunay2D::New();
+ delaunay2D->SetInputData(profile);
+ delaunay2D->Update();
+ vtkPolyData* data = delaunay2D->GetOutput();
+ data->BuildLinks();
+ myDelaunay2D[key] = data;
+ return data;
+}
+
#endif
+
+
void HYDROData_Bathymetry::RemoveAltitudePoints()
{
TDF_Label aLabel = myLab.FindChild( DataTag_AltitudePoints, false );
static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for History)
static const int TAG_LOCAL_CS = 4; // tag of local coordinate system information
static const int TAG_DEF_STRICKLER_COEFF = 5; // tag of default strickler coefficient
+static const int TAG_COUNT_QUADTREE = 6; // tag of number of quadtrees created so far
+static const int TAG_COUNT_DELAUNAY = 7; // tag of number of Delaunay triangulations created so far
static const gp_Pnt2d DEFAULT_LOCAL_CS( 0, 0 );
using namespace std;
}
}
+int HYDROData_Document::GetCountQuadtree() const
+{
+ int nbQuad = 0;
+ TDF_Label aLabel = myDoc->Main().FindChild(TAG_COUNT_QUADTREE, Standard_False);
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) anAttr;
+ if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+ nbQuad = anAttr->Get();
+ }
+ return nbQuad;
+}
+
+void HYDROData_Document::SetCountQuadtree( int nbQuad) const
+{
+ TDF_Label aLabel = myDoc->Main().FindChild(TAG_COUNT_QUADTREE);
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) anAttr;
+ if ( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+ aLabel.AddAttribute( anAttr = new TDataStd_Integer() );
+ anAttr->Set( nbQuad );
+ }
+}
+
+int HYDROData_Document::GetCountDelaunay() const
+{
+ int nbDelaunay = 0;
+ TDF_Label aLabel = myDoc->Main().FindChild(TAG_COUNT_DELAUNAY, Standard_False);
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) anAttr;
+ if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+ nbDelaunay = anAttr->Get();
+ }
+ return nbDelaunay;
+}
+
+void HYDROData_Document::SetCountDelaunay( int nbDelaunay) const
+{
+ TDF_Label aLabel = myDoc->Main().FindChild(TAG_COUNT_DELAUNAY);
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Integer) anAttr;
+ if ( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+ aLabel.AddAttribute( anAttr = new TDataStd_Integer() );
+ anAttr->Set( nbDelaunay );
+ }
+}
+
bool HYDROData_Document::DumpToPython( const QString& thePyScriptPath,
const bool theIsMultiFile ) const
{