OUCH
This commit is contained in:
parent
a6067ce949
commit
13a582b20b
29
src/main.cc
29
src/main.cc
@ -4,11 +4,14 @@
|
||||
#include "external_points_filter.h"
|
||||
|
||||
#include "mesh_fit_filter.h"
|
||||
#include "point_tris_dist.h"
|
||||
|
||||
#include <vtkCellData.h>
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
#include <vtkUnstructuredGridReader.h>
|
||||
#include <vtkUnstructuredGridWriter.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkCellArrayIterator.h>
|
||||
|
||||
#ifdef USE_VIEWER
|
||||
#include <vtkNamedColors.h>
|
||||
@ -103,6 +106,32 @@ int main(int argc, char **argv) {
|
||||
writer->Write();
|
||||
|
||||
|
||||
vtkNew<vtkPoints> points;
|
||||
points->InsertPoint(0, 0., 0., 0.);
|
||||
points->InsertPoint(1, 1., 0., 0.);
|
||||
points->InsertPoint(2, 1., 1., 0.);
|
||||
|
||||
vtkNew<vtkCellArray> strips;
|
||||
strips->InsertNextCell(3);
|
||||
strips->InsertCellPoint(0);
|
||||
strips->InsertCellPoint(1);
|
||||
strips->InsertCellPoint(2);
|
||||
|
||||
vtkNew<vtkPolyData> profile;
|
||||
profile->SetPoints(points);
|
||||
profile->SetStrips(strips);
|
||||
|
||||
vtkTriangle *cell = vtkTriangle::SafeDownCast(profile->GetCell(0));
|
||||
|
||||
double direction[3] = {0, 0, 0};
|
||||
double point[3] = {0, 1, 0};
|
||||
|
||||
double d = pointTriangleDistance(point, cell, direction);
|
||||
//double d = 5;
|
||||
|
||||
std::cout << "[" << point[0] << ", " << point[1] << ", " << point[2] << "] (" << d << ")"
|
||||
<< "[" << direction[0] << ", " << direction[1] << ", " << direction[2] << "]\n";
|
||||
|
||||
#ifdef USE_VIEWER
|
||||
/* Volume rendering properties */
|
||||
vtkNew<vtkOpenGLProjectedTetrahedraMapper> volumeMapper;
|
||||
|
@ -31,8 +31,8 @@ double pointSegmentDistance(double *p, double *a, double *b, double* normal) {
|
||||
|
||||
double pointTriangleDistance(double *p, vtkTriangle *triangle, double *normal) {
|
||||
double a[3]; triangle->GetPoints()->GetPoint(0, a);
|
||||
double b[3]; triangle->GetPoints()->GetPoint(0, b);
|
||||
double c[3]; triangle->GetPoints()->GetPoint(0, c);
|
||||
double b[3]; triangle->GetPoints()->GetPoint(1, b);
|
||||
double c[3]; triangle->GetPoints()->GetPoint(2, c);
|
||||
|
||||
double ab[3]; vtkMath::Subtract(b, a, ab);
|
||||
double bc[3]; vtkMath::Subtract(c, b, bc);
|
||||
@ -73,9 +73,9 @@ double pointTriangleDistance(double *p, vtkTriangle *triangle, double *normal) {
|
||||
};
|
||||
|
||||
|
||||
normal[0] = np[0];
|
||||
normal[1] = np[1];
|
||||
normal[2] = np[2];
|
||||
normal[0] = nt[0];
|
||||
normal[1] = nt[1];
|
||||
normal[2] = nt[2];
|
||||
vtkMath::Normalize(normal);
|
||||
return vtkMath::Norm(nt);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user