void setupInitialConditions() { //define side walls InfiniteWall w0; w0.set(Vec3D(-1,0,0), Vec3D(getXMin(), 0, 0)); wallHandler.copyAndAddObject(w0); w0.set(Vec3D( 1,0,0), Vec3D(getXMax(), 0, 0)); wallHandler.copyAndAddObject(w0); IntersectionOfWalls w1; std::vector<Vec3D> Points(3); //left neck wall //define the corners of your prismatic wall in clockwise direction Points[0] = Vec3D(getXMin() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight); Points[1] = Vec3D(getXMin()+ContractionWidth,0.0,(getZMin()+getZMax())/2.0 ); Points[2] = Vec3D(getXMin() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight); w1.createOpenPrism(Points); wallHandler.copyAndAddObject(w1); //right neck wall Points[0] = Vec3D(getXMax() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight); Points[1] = Vec3D(getXMax()-ContractionWidth,0.0,(getZMin()+getZMax())/2.0 ); Points[2] = Vec3D(getXMax() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight); w1.createOpenPrism(Points); wallHandler.copyAndAddObject(w1); // The above wall definition is equivalent to //~ IntersectionOfWalls w1; //~ Vec3D A(getXMin() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight); //~ Vec3D B(getXMin()+ContractionWidth,0.0,(getZMin()+getZMax())/2.0 ); //~ Vec3D C(getXMin() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight); //~ Vec3D D(0,1,0); //Periodic direction of the prism //~ w1.addObject(Vec3D::Cross(A-B,D),A); //~ w1.addObject(Vec3D::Cross(B-C,D),B); //~ wallHandler.copyAndAddObject(w1); w0.set(Vec3D(0,0,-1), Vec3D(0,0,-0.5*(getZMin()+getZMax()))); wallHandler.copyAndAddObject(w0); BaseParticle p0; p0.setVelocity(Vec3D(0.0,0.0,0.0)); //Mdouble Width = getXMax()-getXMin(); for (double z=(getZMin()+getZMax())/2.0+ContractionHeight; particleHandler.getNumberOfObjects()<=N; z+=2.0*MaxParticleRadius) for (double x=MaxParticleRadius; x<getXMax(); x+=1.999*MaxParticleRadius) { p0.setRadius(random.getRandomNumber(MinParticleRadius,MaxParticleRadius)); p0.setPosition(Vec3D(x, 0.0, z+p0.getRadius())); p0.setVelocity(1.0*Vec3D(random.getRandomNumber(-1,1),0.0,random.getRandomNumber(-1,0))); particleHandler.copyAndAddObject(p0); } //write(std::cout,false); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CropImageGeometry::setupFilterParameters() { FilterParameterVector parameters; // parameters.push_back(VolumeDataContainerInfoFilterParameter::New("Geometry Information", "CurrentVolumeDataContainerDimensions", getCurrentVolumeDataContainerDimensions(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("X Min (Column)", "XMin", getXMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Y Min (Row)", "YMin", getYMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Z Min (Plane)", "ZMin", getZMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("X Max (Column) [Inclusive]", "XMax", getXMax(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Y Max (Row) [Inclusive]", "YMax", getYMax(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Z Max (Plane) [Inclusive]", "ZMax", getZMax(), FilterParameter::Parameter)); QStringList linkedProps; linkedProps << "CellFeatureAttributeMatrixPath" << "FeatureIdsArrayPath"; parameters.push_back(LinkedBooleanFilterParameter::New("Renumber Features", "RenumberFeatures", getRenumberFeatures(), linkedProps, FilterParameter::Parameter)); linkedProps.clear(); linkedProps << "NewDataContainerName"; parameters.push_back(BooleanFilterParameter::New("Update Origin", "UpdateOrigin", getUpdateOrigin(), FilterParameter::Parameter)); parameters.push_back(LinkedBooleanFilterParameter::New("Save As New Data Container", "SaveAsNewDataContainer", getSaveAsNewDataContainer(), linkedProps, FilterParameter::Parameter)); parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(DREAM3D::AttributeMatrixType::Cell, DREAM3D::GeometryType::ImageGeometry); parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Cell Attribute Matrix", "CellAttributeMatrixPath", getCellAttributeMatrixPath(), FilterParameter::RequiredArray, req)); } { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(DREAM3D::TypeNames::Int32, 1, DREAM3D::AttributeMatrixType::Cell, DREAM3D::GeometryType::ImageGeometry); parameters.push_back(DataArraySelectionFilterParameter::New("Feature Ids", "FeatureIdsArrayPath", getFeatureIdsArrayPath(), FilterParameter::RequiredArray, req)); } parameters.push_back(SeparatorFilterParameter::New("Cell Feature Data", FilterParameter::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(DREAM3D::AttributeMatrixType::CellFeature, DREAM3D::GeometryType::ImageGeometry); parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Cell Feature Attribute Matrix", "CellFeatureAttributeMatrixPath", getCellFeatureAttributeMatrixPath(), FilterParameter::RequiredArray, req)); } parameters.push_back(StringFilterParameter::New("Data Container", "NewDataContainerName", getNewDataContainerName(), FilterParameter::CreatedArray)); setFilterParameters(parameters); }
void GWindow::drawAxes( const char* axesColor /* = 0 */, bool drawGrid /* = false */, const char* gridColor /* = 0 */ ) { // Af first, draw a grid if (drawGrid) { if (gridColor != 0) setForeground(gridColor); // Vertical grid int xmin = (int) ceil(m_RWinRect.left()); int xmax = (int) floor(m_RWinRect.right()); int i; for (i = xmin; i <= xmax; i++) { if (i == 0) continue; drawLine( R2Point((double) i, m_RWinRect.bottom()), R2Point((double) i, m_RWinRect.top()) ); } int ymin = (int) ceil(m_RWinRect.bottom()); int ymax = (int) floor(m_RWinRect.top()); for (i = ymin; i <= ymax; i++) { if (i == 0) continue; drawLine( R2Point(m_RWinRect.left(), (double) i), R2Point(m_RWinRect.right(), (double) i) ); } } if (axesColor != 0) setForeground(axesColor); drawLine(R2Point(getXMin(), 0.), R2Point(getXMax(), 0.)); drawLine(R2Point(0., getYMin()), R2Point(0., getYMax())); // Scale drawLine(R2Point(1., -0.1), R2Point(1., 0.1)); drawLine(R2Point(-0.1, 1.), R2Point(0.1, 1.)); double w = m_RWinRect.width(); double h = m_RWinRect.height(); drawString(R2Point(getXMin() + w * 0.9, -h*0.06), "x", 1); drawString(R2Point(w * 0.03, getYMin() + h*0.9), "y", 1); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ClearData::writeFilterParameters(AbstractFilterParametersWriter* writer) { writer->writeValue("XMin", getXMin() ); writer->writeValue("YMin", getYMin() ); writer->writeValue("ZMin", getZMin() ); writer->writeValue("XMax", getXMax() ); writer->writeValue("YMax", getYMax() ); writer->writeValue("ZMax", getZMax() ); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setCellAttributeMatrixPath( reader->readDataArrayPath("CellAttributeMatrixPath", getCellAttributeMatrixPath() ) ); setXMin( reader->readValue("XMin", getXMin()) ); setYMin( reader->readValue("YMin", getYMin()) ); setZMin( reader->readValue("ZMin", getZMin()) ); setXMax( reader->readValue("XMax", getXMax()) ); setYMax( reader->readValue("YMax", getYMax()) ); setZMax( reader->readValue("ZMax", getZMax()) ); reader->closeFilterGroup(); }
// // Draw graph of function in a window // void MyWindow::drawGraphic() { R2Point p; double dx = 0.05; double xmax = getXMax(); p.x = getXMin(); p.y = f(p.x); moveTo(p); while (p.x < xmax) { drawLineTo(p); p.x += dx; p.y = f(p.x); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setCellAttributeMatrixPaths( reader->readDataArrayPathVector("CellAttributeMatrixPaths", getCellAttributeMatrixPaths() ) ); setXMin( reader->readValue("XMin", getXMin()) ); setYMin( reader->readValue("YMin", getYMin()) ); setZMin( reader->readValue("ZMin", getZMin()) ); setXMax( reader->readValue("XMax", getXMax()) ); setYMax( reader->readValue("YMax", getYMax()) ); setZMax( reader->readValue("ZMax", getZMax()) ); setInitType(reader->readValue("InitType", getInitType())); setInitValue(reader->readValue("InitValue", getInitValue())); setInitRange(reader->readPairOfDoubles("InitRange", getInitRange())); reader->closeFilterGroup(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::setupFilterParameters() { FilterParameterVector parameters; parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); { AttributeMatrixSelectionFilterParameter::RequirementType req = AttributeMatrixSelectionFilterParameter::CreateRequirement(DREAM3D::AttributeMatrixType::Cell, DREAM3D::GeometryType::ImageGeometry); parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Cell Attribute Matrix", "CellAttributeMatrixPath", getCellAttributeMatrixPath(), FilterParameter::RequiredArray, req)); } parameters.push_back(IntFilterParameter::New("X Min (Column)", "XMin", getXMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Y Min (Row)", "YMin", getYMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Z Min (Plane)", "ZMin", getZMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("X Max (Column)", "XMax", getXMax(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Y Max (Row)", "YMax", getYMax(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Z Max (Plane)", "ZMax", getZMax(), FilterParameter::Parameter)); setFilterParameters(parameters); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CropImageGeometry::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setNewDataContainerName( reader->readString("NewDataContainerName", getNewDataContainerName() ) ); setCellAttributeMatrixPath( reader->readDataArrayPath("CellAttributeMatrixPath", getCellAttributeMatrixPath() ) ); setCellFeatureAttributeMatrixPath( reader->readDataArrayPath("CellFeatureAttributeMatrixPath", getCellFeatureAttributeMatrixPath() ) ); setFeatureIdsArrayPath(reader->readDataArrayPath("FeatureIdsArrayPath", getFeatureIdsArrayPath() ) ); setXMin( reader->readValue("XMin", getXMin()) ); setYMin( reader->readValue("YMin", getYMin()) ); setZMin( reader->readValue("ZMin", getZMin()) ); setXMax( reader->readValue("XMax", getXMax()) ); setYMax( reader->readValue("YMax", getYMax()) ); setZMax( reader->readValue("ZMax", getZMax()) ); setRenumberFeatures( reader->readValue("RenumberFeatures", getRenumberFeatures()) ); setSaveAsNewDataContainer( reader->readValue("SaveAsNewDataContainer", getSaveAsNewDataContainer()) ); setUpdateOrigin( reader->readValue("UpdateOrigin", getUpdateOrigin()) ); reader->closeFilterGroup(); }
/*main written by Josh Cristol and Cody Horton*/ int main(void){ PLL_Init(); Output_Init(); Edge_Init(); while(1){ while(!Switch_Pressed()){wait(1);} wait(0); testBinary(); while(!Switch_Pressed()){wait(1);} wait(0); testDec(); while(!Switch_Pressed()){wait(1);} wait(0); testGraph(); XYplotInit("Graph", getXMin(), getXMax(), getYMin(), getYMax()); int32_t* xBuff = getXData(); int32_t* yBuff = getYData(); XYplot(xBuff, yBuff, getLength()); } }
void setupInitialConditions() { relVelocity_ = 1e-1; setName("AdhesiveForceUnitTest_ParticleWallInteractionWithPlasticForces"); setSystemDimensions(3); setParticleDimensions(3); setGravity(Vec3D(0,0,0)); species->setDensity(2000.0); species->setStiffness(1e2); species->setAdhesionStiffness(1e2); species->setAdhesionForceMax(1e-5*species->getAdhesionStiffness()); Mdouble R = 1e-3; species->setSlidingStiffness(1.2e1); species->setSlidingFrictionCoefficient(0.01); setTimeStep(5e-6 / 2.0); setXMax( 2*R); setYMax( R); setZMax( R); setXMin(0); setYMin(-R); setZMin(-R); particleHandler.clear(); BaseParticle P; P.setRadius(R); P.setPosition(Vec3D(R+species->getInteractionDistance()*1/3,0,0)); P.setVelocity(Vec3D(-relVelocity_/2,0,0)); particleHandler.copyAndAddObject(P); wallHandler.clear(); InfiniteWall w; w.set(Vec3D(-1, 0, 0), Vec3D(getXMin(), 0, 0)); wallHandler.copyAndAddObject(w); setTimeMax(getTimeStep()*250*4); setFileType(FileType::ONE_FILE); setSaveCount(1); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::setupFilterParameters() { FilterParameterVector parameters; parameters.push_back(SeparatorFilterParameter::New("Cell Data", FilterParameter::RequiredArray)); { MultiDataArraySelectionFilterParameter::RequirementType req = MultiDataArraySelectionFilterParameter::CreateRequirement(SIMPL::Defaults::AnyPrimitive, SIMPL::Defaults::AnyComponentSize, SIMPL::AttributeMatrixType::Cell, SIMPL::GeometryType::ImageGeometry); parameters.push_back(MultiDataArraySelectionFilterParameter::New("Cell Arrays", "CellAttributeMatrixPaths", getCellAttributeMatrixPaths(), FilterParameter::RequiredArray, req)); } parameters.push_back(IntFilterParameter::New("X Min (Column)", "XMin", getXMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Y Min (Row)", "YMin", getYMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Z Min (Plane)", "ZMin", getZMin(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("X Max (Column)", "XMax", getXMax(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Y Max (Row)", "YMax", getYMax(), FilterParameter::Parameter)); parameters.push_back(IntFilterParameter::New("Z Max (Plane)", "ZMax", getZMax(), FilterParameter::Parameter)); { LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New(); parameter->setHumanLabel("Initialization Type"); parameter->setPropertyName("InitType"); parameter->setDefaultValue(Manual); QVector<QString> choices; choices.push_back("Manual"); choices.push_back("Random"); choices.push_back("Random With Range"); parameter->setChoices(choices); QStringList linkedProps; linkedProps << "InitValue" << "InitRange"; parameter->setLinkedProperties(linkedProps); parameter->setEditable(false); parameter->setCategory(FilterParameter::Parameter); parameters.push_back(parameter); } parameters.push_back(DoubleFilterParameter::New("Initialization Value", "InitValue", getInitValue(), FilterParameter::Parameter, Manual)); parameters.push_back(RangeFilterParameter::New("Initialization Range", "InitRange", getInitRange(), FilterParameter::Parameter, RandomWithRange)); setFilterParameters(parameters); }
void setupInitialConditions() { BaseParticle p0; p0.setRadius(0.005); p0.setPosition(Vec3D(0.5*getXMax(),0.5*getYMax(),0.0)); p0.setVelocity(Vec3D(1.2,1.3,0.0)); particleHandler.copyAndAddObject(p0); //! [T7:infiniteWalls] InfiniteWall w0; w0.set(Vec3D(1.0,0.0,0.0),Vec3D(getXMax(),0.0,0.0)); wallHandler.copyAndAddObject(w0); w0.set(Vec3D(-1.0,0.0,0.0),Vec3D(getXMin(),0.0,0.0)); wallHandler.copyAndAddObject(w0); w0.set(Vec3D(0.0,1.0,0.0),Vec3D(0.0,getYMax(),0.0)); wallHandler.copyAndAddObject(w0); w0.set(Vec3D(0.0,-1.0,0.0),Vec3D(0.0,getYMin(),0.0)); wallHandler.copyAndAddObject(w0); //! [T7:infiniteWalls] }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::dataCheck() { setErrorCondition(0); if (m_CellAttributeMatrixPaths.size() <= 0) { QString ss = "At least one data array must be selected."; setErrorCondition(-5550); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } DataArrayPath attributeMatrixPath(m_CellAttributeMatrixPaths[0].getDataContainerName(), m_CellAttributeMatrixPaths[0].getAttributeMatrixName(), ""); getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, attributeMatrixPath, -301); ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, attributeMatrixPath.getDataContainerName()); if(NULL == image.get()) { return; } if (getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); setErrorCondition(-5551); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); setErrorCondition(-5552); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); setErrorCondition(-5553); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getXMin() < 0) { QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin()); setErrorCondition(-5554); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getYMin() < 0) { QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin()); setErrorCondition(-5555); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getZMin() < 0) { QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin()); setErrorCondition(-5556); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getXMax() > (static_cast<int64_t>(image->getXPoints()) - 1)) { QString ss = QObject::tr("The X Max you entered of %1 is greater than your Max X Point of %2").arg(getXMax()).arg(static_cast<int64_t>(image->getXPoints()) - 1); setErrorCondition(-5557); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getYMax() > (static_cast<int64_t>(image->getYPoints()) - 1)) { QString ss = QObject::tr("The Y Max you entered of %1 is greater than your Max Y Point of %2").arg(getYMax()).arg(static_cast<int64_t>(image->getYPoints()) - 1); setErrorCondition(-5558); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getZMax() > (static_cast<int64_t>(image->getZPoints()) - 1)) { QString ss = QObject::tr("The Z Max you entered of %1) greater than your Max Z Point of %2").arg(getZMax()).arg(static_cast<int64_t>(image->getZPoints()) - 1); setErrorCondition(-5559); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } DataContainer::Pointer m = getDataContainerArray()->getDataContainer(attributeMatrixPath.getDataContainerName()); size_t udims[3] = { 0, 0, 0 }; m->getGeometryAs<ImageGeom>()->getDimensions(udims); QString attrMatName = attributeMatrixPath.getAttributeMatrixName(); QList<QString> voxelArrayNames = DataArrayPath::GetDataArrayNames(m_CellAttributeMatrixPaths); for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { IDataArray::Pointer p = m->getAttributeMatrix(attrMatName)->getAttributeArray(*iter); QString type = p->getTypeAsString(); if (type == "int8_t") { checkInitialization<int8_t>(p); } else if (type == "int16_t") { checkInitialization<int16_t>(p); } else if (type == "int32_t") { checkInitialization<int32_t>(p); } else if (type == "int64_t") { checkInitialization<int64_t>(p); } else if (type == "uint8_t") { checkInitialization<uint8_t>(p); } else if (type == "uint16_t") { checkInitialization<uint16_t>(p); } else if (type == "uint32_t") { checkInitialization<uint32_t>(p); } else if (type == "uint64_t") { checkInitialization<uint64_t>(p); } else if (type == "float") { checkInitialization<float>(p); } else if (type == "double") { checkInitialization<double>(p); } if (getErrorCondition() < 0) { return; } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void CropImageGeometry::dataCheck() { if(getErrorCondition() < 0) { return; } setErrorCondition(0); // Validate the incoming DataContainer, Geometry, and AttributeMatrix ; bail if any do not exist since we plan on using them later on in the dataCheck // Error messages are handled by the getPrereq functions DataContainer::Pointer srcCellDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName()); ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName()); AttributeMatrix::Pointer srcCellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301); if(getErrorCondition() < 0) { return; } DataContainer::Pointer destCellDataContainer = srcCellDataContainer; AttributeMatrix::Pointer destCellAttrMat; if (m_SaveAsNewDataContainer == true) { float ox = 0.0f, oy = 0.0f, oz = 0.0f, rx = 0.0f, ry = 0.0f, rz = 0.0f; size_t dx = 0, dy = 0, dz = 0; image->getOrigin(ox, oy, oz); image->getResolution(rx, ry, rz); image->getDimensions(dx, dy, dz); destCellDataContainer = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getNewDataContainerName()); if(NULL == destCellDataContainer.get() || getErrorCondition() < 0) { return; } IGeometry::Pointer imageCopy = image->deepCopy(); destCellDataContainer->setGeometry(imageCopy); destCellAttrMat = srcCellAttrMat->deepCopy(); destCellDataContainer->addAttributeMatrix(destCellAttrMat->getName(), destCellAttrMat); } else { destCellAttrMat = srcCellAttrMat; } if(NULL == destCellDataContainer.get() || NULL == destCellAttrMat.get() || getErrorCondition() < 0) { return; } if (getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getXMin() < 0) { QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getYMin() < 0) { QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getZMin() < 0) { QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin()); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getXMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1)) { QString ss = QObject::tr("The X Max (%1) is greater than the Image Geometry X extent (%2)").arg(getXMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getYMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1)) { QString ss = QObject::tr("The Y Max (%1) is greater than the Image Geometry Y extent (%2)").arg(getYMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } if (getZMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1)) { QString ss = QObject::tr("The Z Max (%1) is greater than the Image Geometry Z extent (%2)").arg(getZMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1); notifyErrorMessage(getHumanLabel(), ss, -5550); setErrorCondition(-5550); } QVector<size_t> tDims(3, 0); if (getXMax() - getXMin() < 0) { setXMax(getXMin() + 1); } if (getYMax() - getYMin() < 0) { setYMax(getYMin() + 1); } if (getZMax() - getZMin() < 0) { setZMax(getZMin() + 1); } tDims[0] = (getXMax() - getXMin()) + 1; tDims[1] = (getYMax() - getYMin()) + 1; tDims[2] = (getZMax() - getZMin()) + 1; destCellDataContainer->getGeometryAs<ImageGeom>()->setDimensions(tDims[0], tDims[1], tDims[2]); // If any of the sanity checks fail above then we should NOT attempt to go any further. if (getErrorCondition() < 0) { return; } size_t totalPoints = 1; for(int i = 0; i < 3; i++) { if(tDims[i] != 0) { totalPoints *= tDims[i]; } } AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, destCellAttrMat->getName(), destCellAttrMat->getType()); QList<QString> voxelArrayNames = destCellAttrMat->getAttributeArrayNames(); for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter) { IDataArray::Pointer p = destCellAttrMat->getAttributeArray(*iter); // IDataArray::Pointer data = p->createNewArray(totalPoints, p->getComponentDimensions(), p->getName(), false); destCellAttrMat->removeAttributeArray(*iter); newCellAttrMat->addAttributeArray(*iter, data); } destCellDataContainer->removeAttributeMatrix(destCellAttrMat->getName()); destCellDataContainer->addAttributeMatrix(newCellAttrMat->getName(), newCellAttrMat); if(m_RenumberFeatures == true) { QVector<size_t> cDims(1, 1); m_FeatureIdsPtr = getDataContainerArray()->getPrereqArrayFromPath<DataArray<int32_t>, AbstractFilter>(this, getFeatureIdsArrayPath(), cDims); /* Assigns the shared_ptr<> to an instance variable that is a weak_ptr<> */ if( NULL != m_FeatureIdsPtr.lock().get() ) /* Validate the Weak Pointer wraps a non-NULL pointer to a DataArray<T> object */ { m_FeatureIds = m_FeatureIdsPtr.lock()->getPointer(0); } /* Now assign the raw pointer to data from the DataArray<T> object */ AttributeMatrix::Pointer cellFeatureAttrMat = srcCellDataContainer->getAttributeMatrix(getCellFeatureAttributeMatrixPath().getAttributeMatrixName()); if(NULL == cellFeatureAttrMat.get()) { return; } QVector<bool> activeObjects(cellFeatureAttrMat->getNumTuples(), true); cellFeatureAttrMat->removeInactiveObjects(activeObjects, m_FeatureIdsPtr.lock()); } }
void setupInitialConditions() { if (particleHandler.getNumberOfObjects() != N) { particleHandler.clear(); boundaryHandler.clear(); double VP = constants::pi * 4.0 / 3.0; L = pow(N * VP * DistInt(1, omega) / nu, 1.0 / 3.0); setXMin(0); setYMin(0); setZMin(0); setXMax(L); setYMax(L); setZMax(L); PeriodicBoundary b0; b0.set(Vec3D(1, 0, 0), getXMin(), getXMax()); boundaryHandler.copyAndAddObject(b0); b0.set(Vec3D(0, 1, 0), getYMin(), getYMax()); boundaryHandler.copyAndAddObject(b0); b0.set(Vec3D(0, 0, 1), getZMin(), getZMax()); boundaryHandler.copyAndAddObject(b0); particleHandler.setStorageCapacity(2 * N); BaseParticle p0; p0.setVelocity(Vec3D(0.0, 0.0, 0.0)); double V = 0; //Use at least particles with maximum and minimum size p0.setRadius(1.0); Vec3D position; position.Z = random.getRandomNumber(0, getZMax()); position.Y = random.getRandomNumber(0, getYMax()); position.X = random.getRandomNumber(0, getXMax()); p0.setPosition(position); particleHandler.copyAndAddObject(p0); V += VP * pow(p0.getRadius(), 3); p0.setRadius(omega); position.Z = random.getRandomNumber(0, getZMax()); position.Y = random.getRandomNumber(0, getYMax()); position.X = random.getRandomNumber(0, getXMax()); p0.setPosition(position); particleHandler.copyAndAddObject(p0); V += VP * pow(p0.getRadius(), 3); //For other particles use a random distribution for (unsigned int i = 2; i < N; i++) { p0.setRadius(RandomRadius()); position.Z = random.getRandomNumber(0, getZMax()); position.Y = random.getRandomNumber(0, getYMax()); position.X = random.getRandomNumber(0, getXMax()); p0.setPosition(position); particleHandler.copyAndAddObject(p0); V += VP * pow(p0.getRadius(), 3); } } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void InitializeData::dataCheck() { setErrorCondition(0); getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301); ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName()); if(NULL == image.get()) { return; } if (getXMax() < getXMin()) { QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin()); setErrorCondition(-5551); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getYMax() < getYMin()) { QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin()); setErrorCondition(-5552); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getZMax() < getZMin()) { QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin()); setErrorCondition(-5553); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getXMin() < 0) { QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin()); setErrorCondition(-5554); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getYMin() < 0) { QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin()); setErrorCondition(-5555); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getZMin() < 0) { QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin()); setErrorCondition(-5556); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getXMax() > (static_cast<int64_t>(image->getXPoints()) - 1)) { QString ss = QObject::tr("The X Max you entered of %1 is greater than your Max X Point of %2").arg(getXMax()).arg(static_cast<int64_t>(image->getXPoints()) - 1); setErrorCondition(-5557); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getYMax() > (static_cast<int64_t>(image->getYPoints()) - 1)) { QString ss = QObject::tr("The Y Max you entered of %1 is greater than your Max Y Point of %2").arg(getYMax()).arg(static_cast<int64_t>(image->getYPoints()) - 1); setErrorCondition(-5558); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } if (getZMax() > (static_cast<int64_t>(image->getZPoints()) - 1)) { QString ss = QObject::tr("The Z Max you entered of %1) greater than your Max Z Point of %2").arg(getZMax()).arg(static_cast<int64_t>(image->getZPoints()) - 1); setErrorCondition(-5559); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void ClearData::dataCheck(bool preflight, size_t voxels, size_t fields, size_t ensembles) { setErrorCondition(0); std::stringstream ss; VoxelDataContainer* m = getVoxelDataContainer(); if (getXMax() < getXMin()) { ss.str(""); ss << "X Max (" << getXMax() << ") less than X Min (" << getXMin() << ")"; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getYMax() < getYMin()) { ss.str(""); ss << "Y Max (" << getYMax() << ") less than Y Min (" << getYMin() << ")"; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getZMax() < getZMin()) { ss.str(""); ss << "Z Max (" << getZMax() << ") less than Z Min (" << getZMin() << ")"; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getXMin() < 0) { ss.str(""); ss << "X Min (" << getXMin() << ") less than 0"; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getYMin() < 0) { ss.str(""); ss << "Y Min (" << getYMin() << ") less than 0"; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getZMin() < 0) { ss.str(""); ss <<"Z Min (" << getZMin() << ") less than 0"; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getXMax() > (static_cast<int64_t>(m->getXPoints())-1)) { ss.str(""); ss << "The X Max you entered of " << getXMax() << " is greater than your Max X Point of " << static_cast<int64_t>(m->getXPoints())-1; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5555); } if (getYMax() > (static_cast<int64_t>(m->getYPoints())-1)) { ss.str(""); ss << "The Y Max you entered of " << getYMax() << " is greater than your Max Y Point of " << static_cast<int64_t>(m->getYPoints())-1; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5556); } if (getZMax() > (static_cast<int64_t>(m->getZPoints())-1)) { ss.str(""); ss << "The Z Max you entered of " << getZMax() << ") greater than your Max Z Point of " << static_cast<int64_t>(m->getZPoints())-1; addErrorMessage(getHumanLabel(), ss.str(), -5555); setErrorCondition(-5557); } }
void setupInitialConditions() { auto species = speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies()); species->setDensity(constants::pi / 6.0); double stiffness = 1e5; setParticleDimensions(2); species->setDensity(2500); species->setStiffness(stiffness); species->setSlidingStiffness(2.0 / 7.0 * stiffness); species->setSlidingFrictionCoefficient(0.5); species->setRollingStiffness(2.0 / 5.0 * stiffness); species->setRollingFrictionCoefficient(0.5); species->setTorsionStiffness(2.0 / 5.0 * stiffness); species->setTorsionFrictionCoefficient(0.5); setGravity(Vec3D(0.0, 0.0, 0.0)); setTimeMax(8e-2); setTimeStep(2.0e-4); setFileType(FileType::NO_FILE); setXMin(0.0); setYMin(0.0); setXMax(1.0); setYMax(1.0); PeriodicBoundary b0; b0.set(Vec3D(1, 0, 0), getXMin(), getXMax()); boundaryHandler.copyAndAddObject(b0); b0.set(Vec3D(0, 1, 0), getYMin(), getYMax()); boundaryHandler.copyAndAddObject(b0); BaseParticle P0, P1, P2, P3, P4, P5, P6, P7; //Particle to be removed P0.setPosition(Vec3D(0.1, 0.1, 0.0)); P1.setPosition(Vec3D(0.3, 0.3, 0.0)); //Contacts starts normal becomes periodic P2.setPosition(Vec3D(0.6, 0.041, 0.0)); P2.setAngularVelocity(Vec3D(0.3, 0.6, 0.9)); P3.setPosition(Vec3D(0.4, 0.001, 0.0)); //Normal case P4.setPosition(Vec3D(0.6, 0.82, 0.0)); P4.setAngularVelocity(Vec3D(0.3, 0.6, 0.9)); P5.setPosition(Vec3D(0.4, 0.78, 0.0)); //Contact starts periodic becomes normal and periodic again P6.setPosition(Vec3D(0.02, 0.42, 0.0)); P6.setAngularVelocity(Vec3D(0.3, 0.6, 0.9)); P7.setPosition(Vec3D(0.82, 0.38, 0.0)); P0.setVelocity(Vec3D(0.0, 0.0, 0.0)); P1.setVelocity(Vec3D(0.0, 0.0, 0.0)); P2.setVelocity(Vec3D(-1.0, 0.0, 0.0)); P3.setVelocity(Vec3D(1.0, 0.0, 0.0)); P4.setVelocity(Vec3D(-1.0, 0.0, 0.0)); P5.setVelocity(Vec3D(1.0, 0.0, 0.0)); P6.setVelocity(Vec3D(-1.0, 0.0, 0.0)); P7.setVelocity(Vec3D(1.0, 0.0, 0.0)); P0.setRadius(0.1); P1.setRadius(0.1); P2.setRadius(0.1); P3.setRadius(0.1); P4.setRadius(0.1); P5.setRadius(0.1); P6.setRadius(0.1); P7.setRadius(0.1); particleHandler.copyAndAddObject(P0); particleHandler.copyAndAddObject(P1); particleHandler.copyAndAddObject(P2); particleHandler.copyAndAddObject(P3); particleHandler.copyAndAddObject(P4); particleHandler.copyAndAddObject(P5); particleHandler.copyAndAddObject(P6); particleHandler.copyAndAddObject(P7); }
bool SonarPointCloud::loadStudyCSV() { printf("Loading Study Point Cloud from %s\n", getName().c_str()); FILE *file; file = fopen(getName().c_str(), "r"); if (file == NULL) { printf("ERROR reading file in %s\n", __FUNCTION__); } else { //count points //skip the first linesToSkip lines int skipped = 0; int tries = 0; char tempChar; while (skipped < 1 && tries < 5000) ///1=lines to skip { tries++; tempChar = 'a'; while (tempChar != '\n') { tempChar = fgetc(file); } skipped++; } printf("Skipped %d characters\n", skipped); //now count lines of points double x, y, depth; int flag; unsigned int numPointsInFile = 0u; while (fscanf(file, "%lf,%lf,%lf,%i\n", &x, &y, &depth, &flag) != EOF) //while another valid entry to load numPointsInFile++; initPoints(numPointsInFile); printf("found %d lines of points\n", numPointsInFile); //rewind rewind(file); //skip the first linesToSkip lines skipped = 0; tries = 0; while (skipped < 1 && tries < 5000) ///1=lines to skip { tries++; tempChar = 'a'; while (tempChar != '\n') { tempChar = fgetc(file); } skipped++; } //now load lines of points GLuint index = 0u; double averageDepth = 0.0; while (fscanf(file, "%lf,%lf,%lf,%i\n", &x, &y, &depth, &flag) != EOF) //while another valid entry to load { float tpu = flag == 1 ? 1.f : 0.f; setUncertaintyPoint(index++, x, y, depth, tpu, tpu); averageDepth += depth; assert(depth < 0.); } averageDepth /= m_nPoints; printf("Loaded %d points\n", index); printf("Original Min/Maxes:\n"); printf("X Min: %f Max: %f\n", getXMin(), getXMax()); printf("Y Min: %f Max: %f\n", getYMin(), getYMax()); printf("Depth Min: %f Max: %f\n", getZMin(), getZMax()); printf("Depth Avg: %f\n", averageDepth); fclose(file); adjustPoints(); setRefreshNeeded(); } return true; }
bool SonarPointCloud::loadCARISTxt() { printf("Loading Point Cloud from %s\n", getName().c_str()); FILE *file; file = fopen(getName().c_str(), "r"); if (file == NULL) { printf("ERROR reading file in %s\n", __FUNCTION__); return false; } else { //count points //skip the first linesToSkip lines int skipped = 0; int tries = 0; char tempChar; while (skipped < 1 && tries < 5000) ///1=lines to skip { tries++; tempChar = 'a'; while (tempChar != '\n') { tempChar = fgetc(file); } skipped++; } printf("Skipped %d characters\n", skipped); //now count lines of points double x, y, depth; int profnum, beamnum; float depthTPU, positionTPU, alongAngle, acrossAngle; unsigned int numPointsInFile = 0u; while (fscanf(file, "%lf,%lf,%lf,%d,%d,%f,%f,%f,%f\n", &x, &y, &depth, &profnum, &beamnum, &depthTPU, &positionTPU, &alongAngle, &acrossAngle) != EOF) //while another valid entry to load numPointsInFile++; initPoints(numPointsInFile); printf("found %d lines of points\n", numPointsInFile); //rewind rewind(file); //skip the first linesToSkip lines skipped = 0; tries = 0; while (skipped < 1 && tries < 5000) ///1=lines to skip { tries++; tempChar = 'a'; while (tempChar != '\n') { tempChar = fgetc(file); } skipped++; } //now load lines of points GLuint index = 0u; double averageDepth = 0.0; while (fscanf(file, "%lf,%lf,%lf,%d,%d,%f,%f,%f,%f\n", &x, &y, &depth, &profnum, &beamnum, &depthTPU, &positionTPU, &alongAngle, &acrossAngle) != EOF) //while another valid entry to load { setUncertaintyPoint(index++, x, y, depth, depthTPU, positionTPU); averageDepth += depth; } averageDepth /= m_nPoints; printf("Loaded %d points\n", index); printf("Original Min/Maxes:\n"); printf("X Min: %f Max: %f\n", getXMin(), getXMax()); printf("Y Min: %f Max: %f\n", getYMin(), getYMax()); printf("Depth Min: %f Max: %f\n", getZMin(), getZMax()); printf("Depth Avg: %f\n", averageDepth); fclose(file); adjustPoints(); setRefreshNeeded(); } return true; }