#include "vtkCleanPolyData.h"
#include "vtkTriangleFilter.h"
+#include "vtkFillHolesFilter.h"
+
namespace bbcreaVtk
{
if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
{
-
- vtkPoints *points1 = bbGetInputIn1()->GetPoints();
- vtkPoints *points2 = bbGetInputIn2()->GetPoints();
- printf("EED BooleanOperationPolyDataFilter::Process Number of points 1 %ld\n", points1->GetNumberOfPoints() );
- printf("EED BooleanOperationPolyDataFilter::Process Number of points 2 %ld\n", points2->GetNumberOfPoints() );
-
printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
- vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
+
+ vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
clean1->SetInputData( bbGetInputIn1() );
clean2->SetInputData( bbGetInputIn2() );
triangle1->Update();
triangle2->Update();
+// vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter )
+// https://github.com/zippy84/vtkbool
+ // vtkPolyDataBooleanFilter is a local code creaVtk lib
vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
+
booleanOperation->SetInputData(0, triangle1->GetOutput() );
booleanOperation->SetInputData(1, triangle2->GetOutput() );
+
+// booleanOperation->SetInputData(0, bbGetInputIn1() );
+// booleanOperation->SetInputData(1, bbGetInputIn2() );
+
if (bbGetInputOperation()==0 )
{
booleanOperation->SetOperModeToUnion();
*/
booleanOperation->Update();
+
vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
if (points!=NULL)
{
- bbSetOutputOut( booleanOperation->GetOutput() );
+ vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New();
+ fillHolesFilter->SetInputData( booleanOperation->GetOutput() );
+ fillHolesFilter->SetHoleSize(100000.0);
+ fillHolesFilter->Update();
+ bbSetOutputOut( fillHolesFilter->GetOutput() );
+// bbSetOutputOut( booleanOperation->GetOutput() );
} else {
bbSetOutputOut( NULL );
} // if points!=NULL
+
} else {
bbSetOutputOut( NULL );
printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
} // if In1 In2 != NULL
-
- printf("EED BooleanOperationPolyDataFilter::Process End \n" );
}
//=====
// See example in:
// https://kitware.github.io/vtk-examples/site/Cxx/VisualizationAlgorithms/Cutter/
- printf("EED Cutter::Process start this=%p ImFu=%p In=%p\n", this, bbGetInputImplicitFunction() , bbGetInputIn() );
if ( (bbGetInputActive()==true) && (bbGetInputIn()!=NULL) )
{
vtkCutter *cutter;
//=====
#include "bbcreaVtkLinearExtrusionFilter.h"
#include "bbcreaVtkPackage.h"
-
+#include <vtkReverseSense.h>
namespace bbcreaVtk
{
//=====
void LinearExtrusionFilter::Process()
{
-
// THE MAIN PROCESSING METHOD BODY
// Here we simply set the input 'In' value to the output 'Out'
// And print out the output value
// (the one provided in the attribute 'type' of the tag 'input')
// bbSetOutputOut( bbGetInputIn() );
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
-
- if (bbGetInputIn()!=NULL)
+
+ printf("EED LinearExtrusionFilter::Process In=%p \n",bbGetInputIn() );
+
+ if (extrude!=NULL)
{
- if (extrude!=NULL)
- {
- extrude->Delete();
- }
- if (triangleFilter!=NULL)
- {
- triangleFilter->Delete();
- }
+ extrude->Delete();
+ extrude=NULL;
+ }
+ if (triangleFilter!=NULL)
+ {
+ triangleFilter->Delete();
+ triangleFilter=NULL;
+ }
- extrude = vtkLinearExtrusionFilter::New();
- triangleFilter = vtkTriangleFilter::New();
+ if (bbGetInputIn()!=NULL)
+ {
+ std::vector<double> dir = bbGetInputDirection();
+ extrude = vtkLinearExtrusionFilter::New();
+ triangleFilter = vtkTriangleFilter::New();
extrude->SetInputData( bbGetInputIn() );
extrude->SetExtrusionTypeToNormalExtrusion();
- std::vector<double> dir = bbGetInputDirection();
if (dir.size()==3)
{
extrude->SetVector( dir[0],dir[1],dir[2] );
triangleFilter->SetInputData( extrude->GetOutput() );
triangleFilter->Update( );
bbSetOutputOut( triangleFilter->GetOutput() );
- } // if bbGetInputIn
+ } else {
+ bbSetOutputOut( NULL );
+ }// if bbGetInputIn
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void LinearExtrusionFilter::bbUserSetDefaultValues()
{
-
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
-
extrude = NULL;
triangleFilter = NULL;
bbSetInputIn(NULL);
-
std::vector<double> dir;
dir.push_back(1);
dir.push_back(0);
dir.push_back(0);
bbSetInputDirection( dir );
bbSetInputScalarFactor(0);
-
+ bbSetOutputOut( NULL );
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void LinearExtrusionFilter::bbUserInitializeProcessing()
{
-
// THE INITIALIZATION METHOD BODY :
// Here does nothing
// but this is where you should allocate the internal/output pointers
-// if any
-
-
+// if any
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void LinearExtrusionFilter::bbUserFinalizeProcessing()
{
-
// THE FINALIZATION METHOD BODY :
// Here does nothing
// but this is where you should desallocate the internal/output pointers
// if any
-
-}
}
-// EO namespace bbcreaVtk
+
+} // EO namespace bbcreaVtk
BBTK_END_DESCRIBE_BLACK_BOX(LinearExtrusionFilter);
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
-//=====
-}
-// EO namespace bbcreaVtk
+//=====
+
+} // EO namespace bbcreaVtk
#endif // __bbcreaVtkLinearExtrusionFilter_h_INCLUDED__
// * TYPE is the C++ type of the input/output
// (the one provided in the attribute 'type' of the tag 'input')
+ printf("EED MeshReduction_DecimatePro::Process In=%p \n",bbGetInputIn() );
+
if (firsttime==true)
{
firsttime = false;
decimatepro = vtkDecimatePro::New();
}
- decimatepro->SetInputData( bbGetInputIn() );
- decimatepro->SetTargetReduction( bbGetInputTargetReduction() );
- decimatepro->PreserveTopologyOn();
- decimatepro->Update();
- bbSetOutputOut(decimatepro->GetOutput() );
+
+ if (bbGetInputIn()!=NULL)
+ {
+ decimatepro->SetInputData( bbGetInputIn() );
+ decimatepro->SetTargetReduction( bbGetInputTargetReduction() );
+ decimatepro->PreserveTopologyOn();
+ decimatepro->Update();
+ bbSetOutputOut(decimatepro->GetOutput() );
+ } else {
+ bbSetOutputOut( NULL );
+ } // if In
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
decimatepro = NULL;
bbSetInputIn(NULL);
bbSetInputTargetReduction(0.5);
+ bbSetOutputOut( NULL );
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
firsttime =false;
quadricdecimation = vtkQuadricDecimation::New();
}
- quadricdecimation->SetInputData( bbGetInputIn() );
+ if (bbGetInputIn()!=NULL)
+ {
+ quadricdecimation->SetInputData( bbGetInputIn() );
+ quadricdecimation->SetTargetReduction( bbGetInputTargetReduction() );
+ quadricdecimation->Update();
+ bbSetOutputOut(quadricdecimation->GetOutput() );
+ } else {
+ bbSetOutputOut( NULL );
+ } // if In
- quadricdecimation->SetTargetReduction( bbGetInputTargetReduction() );
-
- quadricdecimation->Update();
- bbSetOutputOut(quadricdecimation->GetOutput() );
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
#include "bbcreaVtkPackage.h"
#include <vtkPolyDataNormals.h>
+//#include <vtkTriangleMeshPointNormals.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
// (the one provided in the attribute 'type' of the tag 'input')
// bbSetOutputOut( bbGetInputIn() );
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
+ printf("EED PolyDataNormals::Process In=%p \n", bbGetInputIn() );
+
if (bbGetInputIn()!=NULL)
{
+
vtkPolyDataNormals* normal = vtkPolyDataNormals::New();
normal->SetInputData( bbGetInputIn() );
if (bbGetInputComputeType()==0)
} else {
normal->ComputePointNormalsOn();
}
- // normal->SetFeatureAngle(60.0);
+ normal->SetFeatureAngle(360);
+ normal->Update();
+
+ /*
+ vtkTriangleMeshPointNormals* normal = vtkTriangleMeshPointNormals::New();
+ normal->SetInputData( bbGetInputIn() );
normal->Update();
+ */
// >>>>>>>>>>>>>>>>>>>> Calculate the MeanNormal
vtkPolyData *polydata = normal->GetOutput();
*/
dataarray = pointdata->GetNormals();
std::vector<double> meanNormal;
- meanNormal.push_back(1);
+ meanNormal.push_back(0);
meanNormal.push_back(0);
meanNormal.push_back(0);
if (dataarray!=NULL)
{
- meanNormal[0]=0;
int i , size=dataarray->GetNumberOfTuples();
for (i=0; i<size; i++)
{
meanNormal[0] = meanNormal[0] + pValue[0];
meanNormal[1] = meanNormal[1] + pValue[1];
meanNormal[2] = meanNormal[2] + pValue[2];
- }
+ } // for i
if (size!=0)
{
meanNormal[0] = meanNormal[0] / size;
meanNormal[1] = meanNormal[1] / size;
meanNormal[2] = meanNormal[2] / size;
+ double magnitude = sqrt( meanNormal[0]*meanNormal[0] + meanNormal[1]*meanNormal[1] + meanNormal[2]*meanNormal[2] );
+ meanNormal[0] = meanNormal[0] / magnitude;
+ meanNormal[1] = meanNormal[1] / magnitude;
+ meanNormal[2] = meanNormal[2] / magnitude;
} else {
meanNormal[0] = 1;
meanNormal[1] = 0;
meanNormal[2] = 0;
- }
+ } // if size
} // if dataarray
// <<<<<<<<<<<<<<<<<<<<< Calculate the MeanNormal
meanN[0] = meanNormal[0];
meanN[1] = meanNormal[1];
meanN[2] = meanNormal[2];
+ double magnitude;
int i , size=dataarray->GetNumberOfTuples();
for (i=0; i<size; i++)
{
pValue = dataarray->GetTuple3( i );
ang = vtkMath::AngleBetweenVectors( pValue, meanN );
-
vtkMath::Cross(meanN,pValue,crossResult);
wxyz[0] = ang * bbGetInputParam();
wxyz[1] = crossResult[0];
wxyz[2] = crossResult[1];
wxyz[3] = crossResult[2];
vtkMath::RotateVectorByWXYZ(meanN, wxyz ,meanNormalresult);
+ magnitude = sqrt( meanNormalresult[0]*meanNormalresult[0] + meanNormalresult[1]*meanNormalresult[1] + meanNormalresult[2]* meanNormalresult[2] );
+ meanNormalresult[0] = meanNormalresult[0] / magnitude;
+ meanNormalresult[1] = meanNormalresult[1] / magnitude;
+ meanNormalresult[2] = meanNormalresult[2] / magnitude;
dataarray->SetTuple3( i , meanNormalresult[0], meanNormalresult[1], meanNormalresult[2] );
} // for
-
} // if Type==1 && dataarray
bbSetOutputMeanNormal( meanNormal );
bbSetOutputOut( normal->GetOutput() );
- } // if In
+ } else {
+ bbSetOutputOut( NULL );
+ }// if In
}
//=====
{
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
- bbSetInputIn(NULL);
+ bbSetInputIn(NULL);
+ bbSetOutputOut( NULL );
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
// bbSetOutputOut( bbGetInputIn() );
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
-
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
- printf("EED Warning!!! TrimmedExtrusionFilter::Process Box not tested....... \n");
-
-
-
-/* ------ Not exist in windows old VTK 8.1 version ---------
-
if ( (bbGetInputIn()!=NULL) && (bbGetInputIn2()!=NULL) )
{
if (extrusion!=NULL)
} else {
printf("EED Warning!!! TrimmedExtrusionFilter::Process Either In or In2 is missing \n");
} // if bbGetInputIn
-*/
-
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void TrimmedExtrusionFilter::bbUserSetDefaultValues()
{
-
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
// ------ Not exist in windows old VTK 8.1 version ---------
-// extrusion=NULL;
-
+ extrusion=NULL;
bbSetInputIn(NULL);
bbSetInputIn2(NULL);
bbSetInputType(0);
-
std::vector<double> dir;
dir.push_back(1);
dir.push_back(0);
dir.push_back(0);
bbSetInputDirection( dir );
-
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void TrimmedExtrusionFilter::bbUserInitializeProcessing()
{
-
// THE INITIALIZATION METHOD BODY :
// Here does nothing
// but this is where you should allocate the internal/output pointers
-// if any
-
-
+// if any
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void TrimmedExtrusionFilter::bbUserFinalizeProcessing()
{
-
// THE FINALIZATION METHOD BODY :
// Here does nothing
// but this is where you should desallocate the internal/output pointers
// if any
-
}
} // EO namespace bbcreaVtk
#include "iostream"
#include <vtkPolyData.h>
-
-// ------ Not exist in windows old VTK version ---------
-//#include <vtkTrimmedExtrusionFilter.h>
-
+#include <vtkTrimmedExtrusionFilter.h>
namespace bbcreaVtk
{
BBTK_PROCESS(Process);
void Process();
-// ------ Not exist in windows old VTK version ---------
-// vtkTrimmedExtrusionFilter *extrusion;
+ vtkTrimmedExtrusionFilter *extrusion;
//=====
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
-}
-// EO namespace bbcreaVtk
+}// EO namespace bbcreaVtk
#endif // __bbcreaVtkTrimmedExtrusionFilter_h_INCLUDED__