if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
{
-
+/*
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");
printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
-
+*/
+
+/*
vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
clean1->SetInputData( bbGetInputIn1() );
triangle2->SetInputData( clean2->GetOutput() );
triangle1->Update();
triangle2->Update();
+*/
+ //TRIANGLE FILTER NOT NEEDED, this can handle non triangle meshes.
+
// 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, triangle1->GetOutput() );
+// booleanOperation->SetInputData(1, triangle2->GetOutput() );
-// booleanOperation->SetInputData(0, bbGetInputIn1() );
-// booleanOperation->SetInputData(1, bbGetInputIn2() );
+ booleanOperation->SetInputData(0, bbGetInputIn1() );
+ booleanOperation->SetInputData(1, bbGetInputIn2() );
if (bbGetInputOperation()==0 )
{
// fillHolesFilter->SetHoleSize(100000.0);
// fillHolesFilter->Update();
// bbSetOutputOut( fillHolesFilter->GetOutput() );
+
+ /*
+ *
+ *Added boxes(triangleFilter and CleanPolyData) to handle this outside the box
+ *
+
+ //vtkTriangleFilter *triangleEnd = vtkTriangleFilter::New();
+ //triangleEnd->SetInputData( booleanOperation->GetOutput() );
+ //triangleEnd->Update();
+
+ vtkCleanPolyData *cleanEnd = vtkCleanPolyData::New();
+ cleanEnd->SetInputData( booleanOperation->GetOutput() );
+ cleanEnd->Update();
+ bbSetOutputOut( cleanEnd->GetOutput() );
+ */
+
bbSetOutputOut( booleanOperation->GetOutput() );
} else {
bbSetOutputOut( NULL );
--- /dev/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)
+//=====
+#include "bbcreaVtkCleanPolyData.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,CleanPolyData)
+BBTK_BLACK_BOX_IMPLEMENTATION(CleanPolyData,bbtk::AtomicBlackBox);
+//=====
+// 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 CleanPolyData::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+ if( bbGetInputIn() != NULL )
+ {
+ cleanPolyData->SetInputData( bbGetInputIn() );
+ cleanPolyData->Update();
+ bbSetOutputOut( cleanPolyData->GetOutput() );
+ }else{
+ 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 CleanPolyData::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputIn(NULL);
+ cleanPolyData = 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 CleanPolyData::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+ cleanPolyData = vtkCleanPolyData::New();
+
+}
+//=====
+// 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 CleanPolyData::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+ cleanPolyData->Delete();
+ cleanPolyData = NULL;
+}
+}
+// EO namespace bbcreaVtk
+
+
--- /dev/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)
+//=====
+#ifndef __bbcreaVtkCleanPolyData_h_INCLUDED__
+#define __bbcreaVtkCleanPolyData_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkCleanPolyData.h"
+#include "vtkPolyData.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT CleanPolyData
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(CleanPolyData,bbtk::AtomicBlackBox);
+//=====
+// 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)
+//=====
+ BBTK_DECLARE_INPUT(In,vtkPolyData*);
+ BBTK_DECLARE_OUTPUT(Out,vtkPolyData*);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ vtkCleanPolyData *cleanPolyData;
+//=====
+// 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)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(CleanPolyData,bbtk::AtomicBlackBox);
+BBTK_NAME("CleanPolyData");
+BBTK_AUTHOR("InfoDev");
+BBTK_DESCRIPTION("No Description.");
+BBTK_CATEGORY("empty");
+BBTK_INPUT(CleanPolyData,In,"Input PolyData",vtkPolyData*,"");
+BBTK_OUTPUT(CleanPolyData,Out,"Output PolyData",vtkPolyData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(CleanPolyData);
+//=====
+// 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
+
+#endif // __bbcreaVtkCleanPolyData_h_INCLUDED__
+
{
bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId);
centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]);
+ //vtkSmartPointer<vtkTriangleStrip> triangleStrip = vtkSmartPointer<vtkTriangleStrip>::New();
+ //triangleStrip->GetPointIds()->SetNumberOfIds(numPointsFace*2 + (!isClosedCont?2:0));
+ //int triangleIndex = 0;
if( normalOrder )
{
int initial = firstIndex;
triangle->GetPointIds()->SetId(2, centroidId);
cells->InsertNextCell(triangle);
}
+ /*
+ triangleStrip->GetPointIds()->SetId(triangleIndex,index);
+ triangleStrip->GetPointIds()->SetId(triangleIndex+1,centroidId);//1
+ if(index+increment >= end && !isClosedCont){
+ triangleStrip->GetPointIds()->SetId(triangleIndex+2,initial);//2
+ triangleStrip->GetPointIds()->SetId(triangleIndex+3,centroidId);//3
+ }
+ triangleIndex+=2;
+ */
}
+ //cells->InsertNextCell(triangleStrip);
} else {
int initial = firstIndex-1;
int triangleStripStart = end-1;
- for(int index = triangleStripStart; index > initial; index-=increment){
+ for(int index = triangleStripStart; index > initial; index-=increment){
if(index-increment <= initial && !isClosedCont){
vtkNew<vtkTriangle> triangle;
triangle->GetPointIds()->SetId(0, index);
triangle->GetPointIds()->SetId(2, centroidId);
cells->InsertNextCell(triangle);
}
+ /**triangleStrip->GetPointIds()->SetId(triangleIndex,index);
+ triangleStrip->GetPointIds()->SetId(triangleIndex+1,centroidId);
+ if(index-increment <= initial && !isClosedCont){
+ triangleStrip->GetPointIds()->SetId(triangleIndex+2,triangleStripStart);
+ triangleStrip->GetPointIds()->SetId(triangleIndex+3,centroidId);
+ }
+ triangleIndex+=2;
+ */
}
- }
+ //cells->InsertNextCell(triangleStrip);
+ }//if normalOrder
}//if validCentroid
}//if numPointsFace
}//for facesIdx
}
/**
-* Checks if points on each side of the shapes represent a curve.
+* Checks if the order of the points represent a curved spline (U shape) or the points resemble a straight spline.
+* Now it checks the angle between each point and the vector that goes from the last point to the first.
+*
+* Previous version checked the curvature between 3 points in the spline, but this created problems when the straight lines
+* had curves in the middle, increasing the curvature although they are not in the U shape.
*/
bool CreateMeshFromPoints::CheckLinePointOrder(){
int sizePoints = bbGetInputLstX().size();
std::vector<int> lstIndexs = bbGetInputLstIndexs();
double point1[3], point2[3], point3[3];
double center[3];
- double firstRadiusSum = 0;
- double secondRadiusSum = 0;
- for(int i = 0; i < lstIndexs[0] && lstIndexs[0] > 9; i+=5){
- if(i+10 < lstIndexs[0]){
- points->GetPoint(i, point1);
- points->GetPoint(i+5, point2);
- points->GetPoint(i+10, point3);
- firstRadiusSum += vtkMath::Solve3PointCircle(point1, point2, point3, center);
- }
+ double firstAngleSum = 0;
+ double secondAngleSum = 0;
+
+ points->GetPoint(0, point1);
+ points->GetPoint((lstIndexs[0]-1), point3);
+ double firstVect[3];
+ double secVect[3];
+ vtkMath::Subtract(point3, point1, firstVect);
+ for(int i = 0; i < lstIndexs[0]; i++){
+ points->GetPoint(i, point2);
+ vtkMath::Subtract(point2, point1, secVect);
+ firstAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect);
}
-
- for(int i = 0; i < sizePoints && lstIndexs.size() > 9; i+=(lstIndexs.size()*5)){
- if(i+(10*lstIndexs.size()) < sizePoints){
- points->GetPoint(i, point1);
- points->GetPoint(i+(5*lstIndexs.size()), point2);
- points->GetPoint(i+(10*lstIndexs.size()), point3);
- secondRadiusSum += vtkMath::Solve3PointCircle(point1, point2, point3, center);
- }
+ points->GetPoint((sizePoints-lstIndexs[0]), point3);
+ vtkMath::Subtract(point3, point1, firstVect);
+ for(int i = 0; i < sizePoints; i+=lstIndexs.size()){
+ points->GetPoint(i, point2);
+ vtkMath::Subtract(point2, point1, secVect);
+ secondAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect);
}
- return firstRadiusSum > secondRadiusSum;
+ return firstAngleSum < secondAngleSum;
}
/**
{
}
-void MeshManagerModel_Box::RefreshOutputs( )
+void MeshManagerModel_Box::RefreshOutputs(bool signalBox)
{
mBox->bbSetOutputMeshBase( GetMeshBase() );
mBox->bbSetOutputMeshTemp( GetMeshTemp() );
- mBox->bbSignalOutputModification();
+ mBox->bbSetOutputMeshNames( GetMeshNames() );
+ if(signalBox==true){
+ mBox->bbSignalOutputModification();
+ }
}
if (meshManagerModel_Box==NULL)
{
meshManagerModel_Box = new MeshManagerModel_Box(this);
- meshManagerModel_Box->SetMeshBase( bbGetInputMesh() );
- meshManagerModel_Box->RefreshOutputs();
+
+ meshManagerModel_Box->AddMeshes_( bbGetInputMeshVector() );
+
+ meshManagerModel_Box->AddMesh_( bbGetInputMesh() );
+ //meshManagerModel_Box->SetMeshBase( bbGetInputMesh() );
+ meshManagerModel_Box->RefreshOutputs(false);
bbSetOutputMeshManagerModel( meshManagerModel_Box );
} // if meshManagerModel_Box
}
// 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)
//=====
BBTK_DECLARE_INPUT(Mesh,vtkPolyData*);
+ BBTK_DECLARE_INPUT(MeshVector, std::vector<vtkPolyData*>);
BBTK_DECLARE_OUTPUT(MeshBase,vtkPolyData*);
BBTK_DECLARE_OUTPUT(MeshTemp,vtkPolyData*);
+ BBTK_DECLARE_OUTPUT(MeshNames,std::vector<std::string>);
BBTK_DECLARE_OUTPUT(MeshManagerModel,MeshManagerModel*);
BBTK_PROCESS(Process);
void Process();
public :
MeshManagerModel_Box(MeshManager *box);
~MeshManagerModel_Box();
- virtual void RefreshOutputs();
+ virtual void RefreshOutputs(bool signalBox);
protected:
private:
MeshManager *mBox;
BBTK_CATEGORY("empty");
BBTK_INPUT(MeshManager,Mesh,"Mesh",vtkPolyData*,"");
+ BBTK_INPUT(MeshManager,MeshVector,"Vector of Meshes",std::vector<vtkPolyData*>,"");
BBTK_OUTPUT(MeshManager,MeshBase,"Mesh Base",vtkPolyData*,"");
BBTK_OUTPUT(MeshManager,MeshTemp,"Mesh Temp",vtkPolyData*,"");
+ BBTK_OUTPUT(MeshManager,MeshNames,"Mesh Names",std::vector<std::string>,"");
BBTK_OUTPUT(MeshManager,MeshManagerModel,"Mesh manager model",MeshManagerModel*,"");
BBTK_END_DESCRIBE_BLACK_BOX(MeshManager);
bbGetInputMeshManagerModel()->ResetMeshTemp();
} // if Tool 40 Reset
+ if(bbGetInputTool() == 50) // Set Array of Meshes
+ {
+ if(bbGetInputMeshes().size() > 1)
+ {
+ if(bbGetInputMeshManagerModel()->GetNumberOfMeshes() == 1){
+ bbGetInputMeshManagerModel()->DeleteAll();
+ }
+ if(bbGetInputMeshManagerModel()->GetNumberOfMeshes() > 1)
+ {
+ bbGetInputMeshManagerModel()->DeleteCurrentMesh();
+ }
+ bbGetInputMeshManagerModel()->InsertMeshesAtCurrent(bbGetInputMeshes());
+ }
+ }
+ if(bbGetInputTool() == 60) // Select Mesh by Name
+ {
+ if(!bbGetInputStringParam().empty())
+ {
+ bbGetInputMeshManagerModel()->SelectMeshByName(bbGetInputStringParam());
+ }
+ }
+ if(bbGetInputTool() == 70) // Delete Current Mesh
+ {
+ bbGetInputMeshManagerModel()->DeleteCurrentMesh();
+ }
} else {
printf("EED Warning! MeshManager_tool : MeshManagerModel not defined. \n");
}// if MeshManagerModel != NULL
BBTK_DECLARE_INPUT(Tool,int);
BBTK_DECLARE_INPUT(Mesh,vtkPolyData*);
BBTK_DECLARE_INPUT(MeshManagerModel,MeshManagerModel*);
+ BBTK_DECLARE_INPUT(Meshes,std::vector<vtkPolyData*>);
+ BBTK_DECLARE_INPUT(StringParam, std::string);
// BBTK_DECLARE_OUTPUT(Out,double);
BBTK_PROCESS(Process);
void Process();
BBTK_DESCRIPTION("No Description.");
BBTK_CATEGORY("empty");
- BBTK_INPUT(MeshManager_tool,Tool,"(default 0) 0:Nothing 10:Undo 20:ReDo 30:Set 32:Copy and Set 35:Set memory mode 40:ResetMeshTemp",int,"");
+ BBTK_INPUT(MeshManager_tool,Tool,"(default 0) 0:Nothing 10:Undo 20:ReDo 30:Set 32:Copy and Set 35:Set memory mode 40:ResetMeshTemp 50: Set Array of meshes 60:Select mesh by name 70:Delete current mesh",int,"");
BBTK_INPUT(MeshManager_tool,Mesh,"Mesh",vtkPolyData*,"");
+ BBTK_INPUT(MeshManager_tool,Meshes,"Input meshes, required for tool 50",std::vector<vtkPolyData*>,"");
+ BBTK_INPUT(MeshManager_tool,StringParam,"String input",std::string,"");
BBTK_INPUT(MeshManager_tool,MeshManagerModel,"Mesh Manager Model",MeshManagerModel*,"");
// BBTK_OUTPUT(MeshManager_tool,Out,"First output",double,"");
--- /dev/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)
+//=====
+#include "bbcreaVtkPolyDataConnectivityFilter.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PolyDataConnectivityFilter)
+BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataConnectivityFilter,bbtk::AtomicBlackBox);
+//=====
+// 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 PolyDataConnectivityFilter::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+
+ //Get all connected components in a polydata vector
+ if(bbGetInputIn() == NULL){
+ printf("PG PolyDataConnectivityFilter::Process Input polydata is null \n");
+ return;
+ }
+
+ if(bbGetInputType() == 1){
+ std::vector<vtkPolyData*> output;
+ connFilter->SetInputData( bbGetInputIn() );
+ connFilter->SetExtractionModeToSpecifiedRegions();
+ connFilter->Update();
+ vtkPolyData *component;
+ int numRegions = connFilter->GetNumberOfExtractedRegions();
+
+ for(int i = 0; i < numRegions; i++){
+ connFilter->AddSpecifiedRegion(i);
+ connFilter->Update();
+ component = vtkPolyData::New();
+ component->DeepCopy(connFilter->GetOutput());
+ output.push_back(component);
+ connFilter->DeleteSpecifiedRegion(i);
+ }
+
+ bbSetOutputOut(output);
+ }
+}
+//=====
+// 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 PolyDataConnectivityFilter::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ connFilter = 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 PolyDataConnectivityFilter::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+ connFilter = vtkPolyDataConnectivityFilter::New();
+
+}
+//=====
+// 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 PolyDataConnectivityFilter::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+
+}
+}
+// EO namespace bbcreaVtk
+
+
--- /dev/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)
+//=====
+#ifndef __bbcreaVtkPolyDataConnectivityFilter_h_INCLUDED__
+#define __bbcreaVtkPolyDataConnectivityFilter_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+#include <vtkPolyData.h>
+#include <vtkPolyDataConnectivityFilter.h>
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT PolyDataConnectivityFilter
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(PolyDataConnectivityFilter,bbtk::AtomicBlackBox);
+//=====
+// 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)
+//=====
+ BBTK_DECLARE_INPUT(In,vtkPolyData*);
+ BBTK_DECLARE_INPUT(Type,int);
+ BBTK_DECLARE_OUTPUT(Out,std::vector<vtkPolyData*>);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ vtkPolyDataConnectivityFilter *connFilter;
+//=====
+// 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)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataConnectivityFilter,bbtk::AtomicBlackBox);
+BBTK_NAME("PolyDataConnectivityFilter");
+BBTK_AUTHOR("InfoDev");
+BBTK_DESCRIPTION("No Description.");
+BBTK_CATEGORY("empty");
+BBTK_INPUT(PolyDataConnectivityFilter,In,"Input polydata",vtkPolyData*,"");
+BBTK_INPUT(PolyDataConnectivityFilter,Type,"0: nothing, 1: Extract all connected regions",int,"");
+BBTK_OUTPUT(PolyDataConnectivityFilter,Out,"output polydatas",std::vector<vtkPolyData*>,"");
+BBTK_END_DESCRIBE_BLACK_BOX(PolyDataConnectivityFilter);
+//=====
+// 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
+
+#endif // __bbcreaVtkPolyDataConnectivityFilter_h_INCLUDED__
+
--- /dev/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)
+//=====
+#include "bbcreaVtkTriangleFilter.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,TriangleFilter)
+BBTK_BLACK_BOX_IMPLEMENTATION(TriangleFilter,bbtk::AtomicBlackBox);
+//=====
+// 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 TriangleFilter::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+ if( bbGetInputIn() != NULL )
+ {
+ triangleFilter->SetInputData( bbGetInputIn() );
+ triangleFilter->Update();
+ bbSetOutputOut( triangleFilter->GetOutput() );
+ }else{
+ 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 TriangleFilter::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputIn(NULL);
+ triangleFilter = 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 TriangleFilter::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+ triangleFilter = vtkTriangleFilter::New();
+
+}
+//=====
+// 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 TriangleFilter::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+ triangleFilter->Delete();
+ triangleFilter = NULL;
+}
+}
+// EO namespace bbcreaVtk
+
+
--- /dev/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)
+//=====
+#ifndef __bbcreaVtkTriangleFilter_h_INCLUDED__
+#define __bbcreaVtkTriangleFilter_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkPolyData.h"
+#include "vtkTriangleFilter.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT TriangleFilter
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(TriangleFilter,bbtk::AtomicBlackBox);
+//=====
+// 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)
+//=====
+ BBTK_DECLARE_INPUT(In,vtkPolyData*);
+ BBTK_DECLARE_OUTPUT(Out,vtkPolyData*);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ vtkTriangleFilter *triangleFilter;
+//=====
+// 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)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(TriangleFilter,bbtk::AtomicBlackBox);
+BBTK_NAME("TriangleFilter");
+BBTK_AUTHOR("InfoDev");
+BBTK_DESCRIPTION("No Description.");
+BBTK_CATEGORY("empty");
+BBTK_INPUT(TriangleFilter,In,"Input PolyData", vtkPolyData*,"");
+BBTK_OUTPUT(TriangleFilter,Out,"Output PolyData", vtkPolyData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(TriangleFilter);
+//=====
+// 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
+
+#endif // __bbcreaVtkTriangleFilter_h_INCLUDED__
+
#include "MeshManagerModel.h"
-MeshManagerModel::MeshManagerModel()
+////////////////////
+/////////////////////// MESH MODEL
+////////////////////
+
+MeshModel::MeshModel(int id)
{
- _meshBase = NULL;
+ _meshBase = NULL;
_meshTemp = NULL;
+ _meshId = id;
+ _name = "mesh-" + std::to_string(id);
}
-MeshManagerModel::~MeshManagerModel()
+MeshModel::MeshModel(vtkPolyData* mesh, int id)
{
+ if(mesh != NULL){
+ _meshBase = mesh;
+ _meshTemp = vtkPolyData::New();
+ _meshTemp->DeepCopy(_meshBase);
+ _meshId = id;
+ _name = "mesh-" + std::to_string(id);
+ }
}
-void MeshManagerModel::ResetMeshTemp_()
+MeshModel::~MeshModel(){
+ if(_meshBase != NULL){
+ _meshBase->Delete();
+ }
+ if(_meshTemp != NULL){
+ _meshTemp->Delete();
+ }
+}
+
+void MeshModel::ResetMeshTemp_()
{
if (_meshBase!=NULL)
{
}
}
-void MeshManagerModel::SetMeshBase(vtkPolyData* mesh)
+void MeshModel::SetMeshBase(vtkPolyData* mesh)
{
if (mesh!=NULL)
{
_meshBase = mesh;
ResetMeshTemp_();
- RefreshOutputs();
} // if mesh
}
-void MeshManagerModel::SetMeshMemoryMode(vtkPolyData* mesh)
+void MeshModel::SetMeshMemoryMode(vtkPolyData* mesh)
{
_meshBase = mesh;
- RefreshOutputs();
}
-void MeshManagerModel::ResetMeshTemp()
+void MeshModel::ResetMeshTemp()
{
ResetMeshTemp_();
- RefreshOutputs();
}
-void MeshManagerModel::CopySetMeshBase(vtkPolyData* mesh)
+void MeshModel::CopySetMeshBase(vtkPolyData* mesh)
{
if (mesh!=NULL)
{
}
-vtkPolyData* MeshManagerModel::GetMeshBase()
+vtkPolyData* MeshModel::GetMeshBase()
{
return _meshBase;
}
-vtkPolyData* MeshManagerModel::GetMeshTemp()
+vtkPolyData* MeshModel::GetMeshTemp()
{
return _meshTemp;
}
-void MeshManagerModel::RefreshOutputs() // virtula
+int MeshModel::GetId()
+{
+ return _meshId;
+}
+
+std::string MeshModel::GetName()
+{
+ return _name;
+}
+
+////////////////////
+/////////////////////// MESH MANAGER
+////////////////////
+
+MeshManagerModel::MeshManagerModel()
+{
+ //MeshModel* firstMesh = new MeshModel();
+ //_meshes.push_back(firstMesh);
+ currentMesh = 0;
+ meshId = 0;
+}
+
+MeshManagerModel::~MeshManagerModel()
+{
+ DeleteAll();
+}
+
+void MeshManagerModel::RefreshOutputs(bool signalBox) // virtual
+{
+}
+
+int MeshManagerModel::GetNumberOfMeshes(){
+ return _meshes.size();
+}
+
+void MeshManagerModel::AddMesh_(vtkPolyData* mesh){
+ if(mesh != NULL){
+ MeshModel *meshModel = new MeshModel(mesh, meshId);
+ _meshes.push_back(meshModel);
+ meshId++;
+ }
+ else{
+ printf("PG MeshManagerModel::AddMesh Mesh is null \n");
+ }
+}
+
+void MeshManagerModel::AddMesh(vtkPolyData* mesh){
+ AddMesh_(mesh);
+ RefreshOutputs(true);
+}
+
+void MeshManagerModel::AddMeshes_(std::vector<vtkPolyData*> meshList){
+ if(!meshList.empty())
+ {
+ MeshModel *meshModel;
+ for(int i = 0; i < meshList.size(); i++){
+ meshModel = new MeshModel(meshList[i], meshId);
+ _meshes.push_back(meshModel);
+ meshId++;
+ }
+ }else{
+ printf("PG MeshManagerModel::AddMeshes Empty list of meshes \n");
+ }
+}
+
+void MeshManagerModel::AddMeshes(std::vector<vtkPolyData*> meshList){
+ AddMeshes_(meshList);
+ RefreshOutputs(true);
+}
+
+void MeshManagerModel::AddEmptyMesh_(){
+ MeshModel *meshModel = new MeshModel(meshId);
+ _meshes.push_back(meshModel);
+ meshId++;
+}
+
+void MeshManagerModel::AddEmptyMesh(){
+ AddEmptyMesh_();
+ RefreshOutputs(true);
+}
+
+void MeshManagerModel::InsertMeshesAtCurrent_(std::vector<vtkPolyData*> meshList)
+{
+ if(!meshList.empty())
+ {
+ std::vector<MeshModel*> tmpVect;
+ MeshModel *meshModel;
+ for(int i = 0; i < meshList.size(); i++){
+ meshModel = new MeshModel(meshList[i], meshId);
+ tmpVect.push_back(meshModel);
+ meshId++;
+ }
+ _meshes.insert(_meshes.begin() + currentMesh, tmpVect.begin(), tmpVect.end());
+ }else{
+ printf("PG MeshManagerModel::AddMeshes Empty list of meshes \n");
+ }
+}
+
+void MeshManagerModel::InsertMeshesAtCurrent(std::vector<vtkPolyData*> meshList)
+{
+ InsertMeshesAtCurrent_(meshList);
+ RefreshOutputs(true);
+}
+
+void MeshManagerModel::SelectMesh(int i) {
+ if(i >= 0 && i < _meshes.size()){
+ int prevCurrent = currentMesh;
+ currentMesh = i;
+ if(prevCurrent != i){
+ RefreshOutputs(true);
+ }
+ }
+ else{
+ printf("PG MeshManagerModel::SelectMesh index out of bounds \n");
+ }
+}
+
+void MeshManagerModel::SelectMeshByName(std::string meshName) {
+ if(!_meshes.empty()){
+ bool found = false;
+ for(int i = 0; i < _meshes.size() && !found; i++){
+ if(_meshes.at(i)->GetName() == meshName){
+ found = true;
+ SelectMesh(i);
+ }
+ }
+ }
+}
+
+void MeshManagerModel::DeleteMesh(int position){
+ if(position >= 0 && position < _meshes.size()){
+ delete _meshes.at(position);
+ _meshes.erase(_meshes.begin() + position);
+ currentMesh = currentMesh + (position <= currentMesh?-1:0);
+ if(currentMesh < 0){
+ currentMesh = 0;
+ }
+ RefreshOutputs(true);
+ }
+}
+
+void MeshManagerModel::DeleteMeshByName(std::string meshName){
+ if(!_meshes.empty()){
+ bool found = false;
+ for(int i = 0; i < _meshes.size() && !found; i++){
+ if(_meshes.at(i)->GetName() == meshName){
+ found = true;
+ delete _meshes.at(i);
+ _meshes.erase(_meshes.begin() + i);
+ currentMesh = currentMesh + (i <= currentMesh?-1:0);
+ if(currentMesh < 0){
+ currentMesh = 0;
+ }
+ RefreshOutputs(true);
+ }
+ }
+ }
+}
+
+void MeshManagerModel::DeleteCurrentMesh(){
+ if(!_meshes.empty()){
+ delete _meshes.at(currentMesh);
+ _meshes.erase(_meshes.begin() + currentMesh);
+ currentMesh--;
+ if(currentMesh < 0){
+ currentMesh = 0;
+ }
+ RefreshOutputs(true);
+ }
+}
+
+void MeshManagerModel::DeleteAll(){
+ if(!_meshes.empty()){
+ for (MeshModel* element : _meshes)
+ {
+ delete element;
+ }
+ _meshes.clear();
+ RefreshOutputs(true);
+ }
+}
+
+void MeshManagerModel::NextMesh(){
+ currentMesh++;
+ if(currentMesh >= _meshes.size()){
+ currentMesh = _meshes.size()-1;
+ }
+ RefreshOutputs(true);
+}
+
+void MeshManagerModel::PreviousMesh(){
+ currentMesh--;
+ if(currentMesh < 0){
+ currentMesh = 0;
+ }
+ RefreshOutputs(true);
+}
+
+MeshModel* MeshManagerModel::GetMeshModel(){
+ return _meshes.at(currentMesh);
+}
+
+vtkPolyData* MeshManagerModel::GetMeshBase()
+{
+ if(!_meshes.empty()){
+ return _meshes.at(currentMesh)->GetMeshBase();
+ }
+ else{
+ return NULL;
+ }
+}
+
+vtkPolyData* MeshManagerModel::GetMeshTemp()
+{
+ if(!_meshes.empty()){
+ return _meshes.at(currentMesh)->GetMeshTemp();
+ }
+ else{
+ return NULL;
+ }
+}
+
+void MeshManagerModel::SetMeshBase(vtkPolyData* mesh)
+{
+ if(!_meshes.empty()){
+ _meshes.at(currentMesh)->SetMeshBase(mesh);
+ RefreshOutputs(true);
+ }else{
+ printf("PG MeshManagerModel::SetMeshMemoryMode Mesh vector is empty \n");
+ }
+}
+
+void MeshManagerModel::SetMeshMemoryMode(vtkPolyData* mesh)
+{
+ //if(!_meshes.empty()){
+ if(_meshes.size() > 1){
+ DeleteAll();
+ }
+ if(_meshes.size() == 0){
+ AddEmptyMesh_();
+ }
+ _meshes.at(currentMesh)->SetMeshMemoryMode(mesh);
+ RefreshOutputs(true);
+ //}else{
+ // printf("PG MeshManagerModel::SetMeshMemoryMode Mesh vector is empty \n");
+ //}
+}
+
+void MeshManagerModel::ResetMeshTemp()
+{
+ if(!_meshes.empty()){
+ _meshes.at(currentMesh)->ResetMeshTemp();
+ RefreshOutputs(true);
+ }else{
+ printf("PG MeshManagerModel::ResetMeshTemp Mesh vector is empty \n");
+ }
+
+}
+
+void MeshManagerModel::CopySetMeshBase(vtkPolyData* mesh)
+{
+ if(!_meshes.empty()){
+ _meshes.at(currentMesh)->CopySetMeshBase(mesh);
+ RefreshOutputs(true);
+ }
+ else{
+ printf("PG MeshManagerModel::CopySetMeshBase Mesh vector is empty \n");
+ }
+}
+
+std::vector<std::string> MeshManagerModel::GetMeshNames()
{
+ std::vector<std::string> names;
+ for(int i = 0; i < _meshes.size(); i++){
+ names.push_back(_meshes.at(i)->GetName());
+ }
+ return names;
}
# knowledge of the CeCILL-B license and that you accept its terms.
# ------------------------------------------------------------------------
*/
+#include <vtkPolyData.h>
+
+class MeshModel{
+
+public:
+ MeshModel(int id);
+ MeshModel(vtkPolyData* mesh, int id);
+ ~MeshModel();
+
+ void SetMeshBase(vtkPolyData* mesh);
+ void SetMeshMemoryMode(vtkPolyData* mesh);
+ void CopySetMeshBase(vtkPolyData* mesh);
+ void ResetMeshTemp();
+ void ResetMeshTemp_();
+ vtkPolyData* GetMeshBase();
+ vtkPolyData* GetMeshTemp();
+ int GetId();
+ std::string GetName();
+
+protected:
+
+private:
+ vtkPolyData *_meshBase;
+ vtkPolyData *_meshTemp;
+ int _meshId;
+ std::string _name;
+};
#ifndef _MESHMANAGERMODEL_H_
#define _MESHMANAGERMODEL_H_
// [classdescription]
//---------------------------------------------
-#include <vtkPolyData.h>
-
class MeshManagerModel
{
void SetMeshMemoryMode(vtkPolyData* mesh);
void CopySetMeshBase(vtkPolyData* mesh);
void ResetMeshTemp();
- void ResetMeshTemp_();
+ //void ResetMeshTemp_();
vtkPolyData* GetMeshBase();
vtkPolyData* GetMeshTemp();
- virtual void RefreshOutputs();
+
+ virtual void RefreshOutputs(bool signalBox);
+
+ MeshModel* GetMeshModel();
+ int GetNumberOfMeshes();
+
+ void AddMesh_(vtkPolyData* mesh);
+ void AddMesh(vtkPolyData* mesh);
+
+ void AddEmptyMesh_();
+ void AddEmptyMesh();
+
+ void AddMeshes(std::vector<vtkPolyData*> meshList);
+ void AddMeshes_(std::vector<vtkPolyData*> meshList);
+
+ void InsertMeshesAtCurrent_(std::vector<vtkPolyData*> meshList);
+ void InsertMeshesAtCurrent(std::vector<vtkPolyData*> meshList);
+
+ void SelectMesh(int i);
+ void SelectMeshByName(std::string meshName);
+ void DeleteMesh(int position);
+ void DeleteMeshByName(std::string meshName);
+ void DeleteCurrentMesh();
+ void DeleteAll();
+ void NextMesh();
+ void PreviousMesh();
+ std::vector<std::string> GetMeshNames();
//--Method template----------------------------
// void FunctionName(int& parameterA);
//Methods and attributes only visible by this class
//---------------------------------------------
private:
- vtkPolyData *_meshBase;
- vtkPolyData *_meshTemp;
+
+ std::vector<MeshModel*> _meshes;
+ int currentMesh;
+ int meshId;
};
//-end of _MESHMANAGERMODEL_H_------------------------------------------------------