void generateHorizontal(unsigned short *buffer, int resolution, int column, int direction, unsigned char *clipBuffer)
		{
			for(int y = lodFactor; y < resolution - lodFactor; y += 2 * lodFactor)
			{
				int position = y * resolution + column;

				{
					int f1 = position;
					int f2 = position + direction - resolution * lodFactor;
					int f3 = position + direction + resolution * lodFactor;

					createFace(buffer, direction, f1, f2, f3, resolution, clipBuffer);
				}

				if(y < resolution - 2 * lodFactor)
				{
					int f1 = position;
					int f2 = position + direction + resolution * lodFactor;
					int f3 = position + resolution * lodFactor;

					createFace(buffer, direction, f1, f2, f3, resolution, clipBuffer);

					f1 = position + resolution * lodFactor;
					f2 = position + direction + resolution * lodFactor;
					f3 = position + resolution * lodFactor * 2;

					createFace(buffer, direction, f1, f2, f3, resolution, clipBuffer);
				}
			}
		}
		void generateVertical(unsigned short *buffer, int resolution, int row, int direction, unsigned char *clipBuffer)
		{
			for(int x = lodFactor; x < resolution - lodFactor; x += 2 * lodFactor)
			{
				int position = row * resolution + x;

				{
					int f1 = position;
					int f2 = position + lodFactor + direction * resolution;
					int f3 = position - lodFactor + direction * resolution;

					createFace(buffer, direction, f1, f2, f3, resolution, clipBuffer);
				}

				if(x < resolution - 2 * lodFactor)
				{
					int f1 = position;
					int f2 = position + lodFactor;
					int f3 = position + lodFactor + direction * resolution;

					createFace(buffer, direction, f1, f2, f3, resolution, clipBuffer);

					f1 = position + lodFactor;
					f2 = position + 2 * lodFactor;
					f3 = position + lodFactor + direction * resolution;

					createFace(buffer, direction, f1, f2, f3, resolution, clipBuffer);
				}
			}
		}
Example #3
0
void GeometryProject::updateFaceList(heFace* tmpFaceList, int i, nvtPair aPrime, nvtPair bPrime, nvtPair cPrime, nvtPair ab, nvtPair bc, nvtPair ca){

	/*createFace(&tmpFaceList[4*i], ca, aPrime, ab);
	createFace(&tmpFaceList[4*i + 1], ca, bc, cPrime);
	createFace(&tmpFaceList[4*i + 2], ca, ab, bc);
	createFace(&tmpFaceList[4*i + 3], ab, bPrime, bc);*/

	createFace(&tmpFaceList[4*i], aPrime, ab, ca);
	createFace(&tmpFaceList[4*i + 1], ca, bc, cPrime);
	createFace(&tmpFaceList[4*i + 2], ab, bc, ca);
	createFace(&tmpFaceList[4*i + 3], ab, bPrime, bc);

}
Example #4
0
void
EthernetChannel::processIncomingPacket(const uint8_t* packet, size_t length,
                                       const ethernet::Address& sender,
                                       const FaceCreatedCallback& onFaceCreated,
                                       const FaceCreationFailedCallback& onReceiveFailed)
{
  NFD_LOG_CHAN_TRACE("New peer " << sender);

  bool isCreated = false;
  shared_ptr<Face> face;
  try {
    FaceParams params;
    params.persistency = ndn::nfd::FACE_PERSISTENCY_ON_DEMAND;
    std::tie(isCreated, face) = createFace(sender, params);
  }
  catch (const EthernetTransport::Error& e) {
    NFD_LOG_CHAN_DEBUG("Face creation for " << sender << " failed: " << e.what());
    if (onReceiveFailed)
      onReceiveFailed(504, "Face creation failed: "s + e.what());
    return;
  }

  if (isCreated)
    onFaceCreated(face);
  else
    NFD_LOG_CHAN_DEBUG("Received frame for existing face");

  // dispatch the packet to the face for processing
  auto* transport = static_cast<UnicastEthernetTransport*>(face->getTransport());
  transport->receivePayload(packet, length, sender);
}
Example #5
0
    void generateLink(unsigned short *buffer, int resolution, bool leftLod, bool rightLod, bool upLod, bool downLod, unsigned char *clipBuffer)
    {
        int startVertex = lodFactor;
        int endVertex = resolution - lodFactor - 1;

        if (!leftLod)
        {
            generateTriangles(buffer, resolution, 0, startVertex, startVertex, endVertex, clipBuffer);

            createFace(buffer, -1, 0, lodFactor * resolution, lodFactor * resolution + lodFactor, clipBuffer);
            createFace(buffer, -1, (resolution - 1 - lodFactor) * resolution, (resolution - 1) * resolution, (resolution - 1 - lodFactor) * resolution + lodFactor, clipBuffer);

            //createFace(buffer, -1, 0, lodFactor * resolution, lodFactor);
            //createFace(buffer, -1, (resolution - 1 - lodFactor) * resolution, (resolution - 1 ) * resolution, (resolution - 1 - lodFactor) * resolution + lodFactor);
        }
        else
            generateHorizontal(buffer, resolution, startVertex, -lodFactor, clipBuffer);

        if (!rightLod)
        {
            generateTriangles(buffer, resolution, endVertex, startVertex, resolution - 1, endVertex, clipBuffer);

            createFace(buffer, -1, resolution - 1, resolution * lodFactor + resolution - 1 - lodFactor, resolution * lodFactor + resolution - 1, clipBuffer);
            createFace(buffer, -1, (resolution - 1 - lodFactor) * resolution + resolution - 1 - lodFactor, (resolution - 1) * resolution + resolution - 1, (resolution - 1 - lodFactor) * resolution + resolution - 1, clipBuffer);

            //createFace(buffer, -1, resolution - 1, resolution * lodFactor + resolution - 1 - lodFactor, resolution * lodFactor + resolution - 1);
            //createFace(buffer, -1, (resolution - 1) * resolution + resolution - 1 - lodFactor, (resolution - 1) * resolution + resolution - 1, (resolution - 1 - lodFactor) * resolution + resolution - 1);
        }
        else
            generateHorizontal(buffer, resolution, endVertex, lodFactor, clipBuffer);

        if (!upLod)
        {
            generateTriangles(buffer, resolution, startVertex, 0, endVertex, startVertex, clipBuffer);

            createFace(buffer, -1, 0, resolution * lodFactor + lodFactor, lodFactor, clipBuffer);
            createFace(buffer, -1, resolution - 1, endVertex, lodFactor * resolution + endVertex, clipBuffer);

            //createFace(buffer, -1, resolution * lodFactor, resolution * lodFactor + lodFactor, lodFactor);
            //createFace(buffer, -1, resolution - 1, endVertex, lodFactor * resolution + endVertex);
        }
        else
            generateVertical(buffer, resolution, startVertex, -lodFactor, clipBuffer);

        if (!downLod)
        {
            generateTriangles(buffer, resolution, startVertex, endVertex, endVertex, resolution - 1, clipBuffer);

            createFace(buffer, -1, (resolution - 1) * resolution, (resolution - 1) * resolution + lodFactor, (resolution - 1 - lodFactor) * resolution + lodFactor, clipBuffer);
            createFace(buffer, -1, (resolution - 1) * resolution + resolution - 1 - lodFactor, (resolution - 1) * resolution + resolution - 1, (resolution - 1 - lodFactor) * resolution + resolution - 1 - lodFactor, clipBuffer);

            //createFace(buffer, -1, (resolution - 1) * resolution, (resolution - 1) * resolution + lodFactor, (resolution - 1 - lodFactor) * resolution + lodFactor);
            //createFace(buffer, -1, (resolution - 1) * resolution + resolution - 1 - lodFactor, (resolution - 1 - lodFactor) * resolution + resolution - 1, (resolution - 1 - lodFactor) * resolution + resolution - 1 - lodFactor);
        }
        else
            generateVertical(buffer, resolution, endVertex, lodFactor, clipBuffer);
    }
Example #6
0
HarfBuzzFace::HarfBuzzFace(FontPlatformData* platformData, uint64_t uniqueID)
    : m_platformData(platformData)
    , m_uniqueID(uniqueID)
    , m_scriptForVerticalText(HB_SCRIPT_INVALID)
{
    HarfBuzzFaceCache::AddResult result = harfBuzzFaceCache()->add(m_uniqueID, nullptr);
    if (result.isNewEntry)
        result.storedValue->value = FaceCacheEntry::create(createFace());
    result.storedValue->value->ref();
    m_face = result.storedValue->value->face();
    m_glyphCacheForFaceCacheEntry = result.storedValue->value->glyphCache();
}
    FTFaceWrapper::Ptr createFace (const String& fontName, const String& fontStyle)
    {
        const KnownTypeface* ftFace = matchTypeface (fontName, fontStyle);

        if (ftFace == nullptr)  ftFace = matchTypeface (fontName, "Regular");
        if (ftFace == nullptr)  ftFace = matchTypeface (fontName, String());

        if (ftFace != nullptr)
            return createFace (ftFace->file, ftFace->faceIndex);

        return nullptr;
    }
Example #8
0
		void Cube::createMesh()
		{
			m_vertexBuffer.reset(new VertexPositionUVNormalBuffer());
			VertexPositionUVNormalBuffer::BufferType& vBuffer = boost::dynamic_pointer_cast<VertexPositionUVNormalBuffer>(m_vertexBuffer)->data();
			vBuffer.clear();

			m_indexBuffer.reset(new IndexBuffer());
			IndexBuffer::BufferType& iBuffer = m_indexBuffer->data();
			iBuffer.clear();

			createFace(vBuffer, iBuffer, Vector3(-1, 0, 0), m_size);
			createFace(vBuffer, iBuffer, Vector3(1, 0, 0), m_size);
			createFace(vBuffer, iBuffer, Vector3(0, -1, 0), m_size);
			createFace(vBuffer, iBuffer, Vector3(0, 1, 0), m_size);
			createFace(vBuffer, iBuffer, Vector3(0, 0, -1), m_size);
			createFace(vBuffer, iBuffer, Vector3(0, 0, 1), m_size);

			if (m_smooth)
			{
				VertexPositionUVNormalBuffer::BufferType::iterator it = vBuffer.begin();
				for (; it != vBuffer.end(); ++it)
				{
					it->normal = glm::normalize(it->position);
				}
			}

			m_vertexBuffer->dirty();
			m_indexBuffer->dirty();
		}
	void SolventAccessibleSurface::get()
	{
		for (Position i = 0; i < number_of_vertices_; i++)
		{
			createVertex(i);
		}

		for (Position i = 0; i < number_of_edges_; i++)
		{
			createEdge(i);
		}

		for (Position i = 0; i < number_of_faces_; i++)
		{
			createFace(i);
		}
	}
Example #10
0
BOOST_FIXTURE_TEST_CASE(CreateFaceMissingUri, AuthorizedCommandFixture<FaceFixture>)
{
  ControlParameters parameters;

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("create");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  getFace()->onReceiveData +=
    bind(&FaceFixture::validateControlResponse, this, _1,
         command->getName(), 400, "Malformed command");

  createFace(*command, parameters);

  BOOST_REQUIRE(didCallbackFire());
}
Example #11
0
void
EthernetChannel::connect(const ethernet::Address& remoteEndpoint,
                         const FaceParams& params,
                         const FaceCreatedCallback& onFaceCreated,
                         const FaceCreationFailedCallback& onConnectFailed)
{
  shared_ptr<Face> face;
  try {
    face = createFace(remoteEndpoint, params).second;
  }
  catch (const boost::system::system_error& e) {
    NFD_LOG_CHAN_DEBUG("Face creation for " << remoteEndpoint << " failed: " << e.what());
    if (onConnectFailed)
      onConnectFailed(504, "Face creation failed: "s + e.what());
    return;
  }

  // Need to invoke the callback regardless of whether or not we had already
  // created the face so that control responses and such can be sent
  onFaceCreated(face);
}
Example #12
0
BOOST_FIXTURE_TEST_CASE(CreateFaceBadUri, AuthorizedCommandFixture<FaceFixture>)
{
  ControlParameters parameters;
  parameters.setUri("tcp:/127.0.0.1");

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("create");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  getFace()->onReceiveData += [this, command] (const Data& response) {
    this->validateControlResponse(response, command->getName(), 400, "Malformed command");
  };

  createFace(*command, parameters);

  BOOST_REQUIRE(didCallbackFire());
}
Example #13
0
BOOST_FIXTURE_TEST_CASE(CreateFaceUnknownScheme, AuthorizedCommandFixture<FaceFixture>)
{
  ControlParameters parameters;
  // this will be an unsupported protocol because no factories have been
  // added to the face manager
  parameters.setUri("tcp://127.0.0.1");

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("create");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  getFace()->onReceiveData +=
    bind(&FaceFixture::validateControlResponse, this, _1,
         command->getName(), 501, "Unsupported protocol");

  createFace(*command, parameters);

  BOOST_REQUIRE(didCallbackFire());
}
Example #14
0
void Global::createToolBars()
{
    // ----- Tool modes -----

    // Create toolbar
    toolBar_ = mainWindow()->addToolBar(tr("Toolbar"));
    toolBar_->setOrientation(Qt::Vertical);
    toolBar_->setMovable(false);
    mainWindow()->addToolBar(Qt::LeftToolBarArea, toolBar_);

    // Set toolbar size
    int iconWidth = 32;
    toolBar_->setIconSize(QSize(iconWidth,iconWidth));
    currentColor_->setIconSize(QSize(iconWidth,iconWidth));
    currentColor_->updateIcon();

    // Create actions (exclusive checkable)
    QActionGroup * actionGroup = new QActionGroup(this);
    for(int i=0; i<NUMBER_OF_TOOL_MODES; i++)
    {
        toolModeActions[i] = new ToolModeAction(static_cast<ToolMode>(i), actionGroup);
        toolModeActions[i]->setCheckable(true);
        toolModeActions[i]->setShortcutContext(Qt::ApplicationShortcut);
        toolBar_->addAction(toolModeActions[i]);
        connect(toolModeActions[i], SIGNAL(triggered(Global::ToolMode)),
                              this, SLOT(setToolMode(Global::ToolMode)));
    }

    // Select
    toolModeActions[SELECT]->setText(tr("Select and move (F1)"));
    toolModeActions[SELECT]->setIcon(QIcon(":/images/select.png"));
    toolModeActions[SELECT]->setStatusTip(tr("Select objects, move objects, glue objects together, and split curves."));
    toolModeActions[SELECT]->setShortcut(QKeySequence(Qt::Key_F1));

    // Sketch
    toolModeActions[SKETCH]->setText(tr("Sketch (F2)"));
    toolModeActions[SKETCH]->setIcon(QIcon(":/images/sketch.png"));
    toolModeActions[SKETCH]->setStatusTip(tr("Sketch curves."));
    toolModeActions[SKETCH]->setShortcut(QKeySequence(Qt::Key_F2));

    // Paint
    toolModeActions[PAINT]->setText(tr("Paint (F3)"));
    toolModeActions[PAINT]->setIcon(QIcon(":/images/paint.png"));
    toolModeActions[PAINT]->setStatusTip(tr("Paint an empty space or an existing object."));
    toolModeActions[PAINT]->setShortcut(QKeySequence(Qt::Key_F3));

    // Sculpt
    toolModeActions[SCULPT]->setText(tr("Sculpt (F4)"));
    toolModeActions[SCULPT]->setIcon(QIcon(":/images/sculpt.png"));
    toolModeActions[SCULPT]->setStatusTip(tr("Sculpt curves."));
    toolModeActions[SCULPT]->setShortcut(QKeySequence(Qt::Key_F4));

    // ----- Color selectors -----

    // Colors
    colorSelectorAction_ = toolBar_->addWidget(currentColor_);
    colorSelectorAction_->setText(tr("Color"));
    colorSelectorAction_->setToolTip(tr("Color (C)"));
    colorSelectorAction_->setStatusTip(tr("Click to open the color selector"));
    colorSelectorAction_->setShortcut(QKeySequence(Qt::Key_C));
    colorSelectorAction_->setShortcutContext(Qt::ApplicationShortcut);
    connect(colorSelectorAction_, SIGNAL(triggered()), currentColor_, SLOT(click()));

    // ----- Tool Options -----

    toolModeToolBar_ = new QToolBar("Action Bar");
    toolModeToolBar_->setIconSize(QSize(200,iconWidth));
    toolModeToolBar_->setMovable(false);
    mainWindow()->addToolBar(toolModeToolBar_);

    // ---------------------   Color   ------------------------

    actionChangeColor_ = new QAction(this);
    actionChangeColor_->setText(tr("Change color"));
    actionChangeColor_->setIcon(QIcon(":/images/change-color.png"));
    actionChangeColor_->setStatusTip(tr("Change the color of the selected cells"));
    //actionChangeColor_->setShortcut(QKeySequence(Qt::Key_C));
    actionChangeColor_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionChangeColor_);
    connect(actionChangeColor_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(changeColor()));

    // ---------------------   Edges   ------------------------

    actionChangeEdgeWidth_ = new QAction(this);
    actionChangeEdgeWidth_->setText(tr("Change edge width (W)"));
    actionChangeEdgeWidth_->setIcon(QIcon(":/images/change-width.png"));
    actionChangeEdgeWidth_->setStatusTip(tr("Change the width of the selected edges"));
    actionChangeEdgeWidth_->setShortcut(QKeySequence(Qt::Key_W));
    actionChangeEdgeWidth_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionChangeEdgeWidth_);
    connect(actionChangeEdgeWidth_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(changeEdgeWidth()));


    // ---------------------   Faces   ------------------------

    actionCreateFace_ = new QAction(this);
    actionCreateFace_->setText(tr("Create Face (F)"));
    actionCreateFace_->setIcon(QIcon(":/images/create-face.png"));
    actionCreateFace_->setStatusTip(tr("Create a face whose boundary is the selected edges"));
    actionCreateFace_->setShortcut(QKeySequence(Qt::Key_F));
    actionCreateFace_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionCreateFace_);
    connect(actionCreateFace_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(createFace()));

    actionAddCycles_ = new QAction(this);
    actionAddCycles_->setText(tr("Add Holes (H)"));
    actionAddCycles_->setIcon(QIcon(":/images/add-cycles.png"));
    actionAddCycles_->setStatusTip(tr("Add holes to the selected face, whose boundaries are the selected edges"));
    actionAddCycles_->setShortcut(QKeySequence(Qt::Key_H));
    actionAddCycles_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionAddCycles_);
    connect(actionAddCycles_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(addCyclesToFace()));

    actionRemoveCycles_ = new QAction(this);
    actionRemoveCycles_->setText(tr("Remove Holes (Ctrl+H)"));
    actionRemoveCycles_->setIcon(QIcon(":/images/remove-cycles.png"));
    actionRemoveCycles_->setStatusTip(tr("Remove holes from the selected face, whose boundaries are the selected edges"));
    actionRemoveCycles_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H));
    actionRemoveCycles_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionRemoveCycles_);
    connect(actionRemoveCycles_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(removeCyclesFromFace()));

    // ---------------------   Topological operations   ------------------------

    actionGlue_ = new QAction(this);
    actionGlue_->setText(tr("Glue"));
    actionGlue_->setToolTip(tr("Glue (G)"));
    actionGlue_->setIcon(QIcon(":/images/glue.png"));
    actionGlue_->setStatusTip(tr("Glue two endpoints or two curves together"));
    actionGlue_->setShortcut(QKeySequence(Qt::Key_G));
    actionGlue_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionGlue_);
    connect(actionGlue_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(glue()));

    actionUnglue_ = new QAction(this);
    actionUnglue_->setText(tr("Explode"));
    actionUnglue_->setToolTip(tr("Explode (E)"));
    actionUnglue_->setIcon(QIcon(":/images/unglue.png"));
    actionUnglue_->setStatusTip(tr("Duplicate the selected objects to disconnect adjacent curves and surfaces"));
    //actionUnglue_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
    actionUnglue_->setShortcut(QKeySequence(Qt::Key_E));
    actionUnglue_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionUnglue_);
    connect(actionUnglue_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(unglue()));

    actionUncut_ = new QAction(this);
    actionUncut_->setText(tr("Simplify"));
    actionUncut_->setToolTip(tr("Simplify (Backspace)"));
    actionUncut_->setIcon(QIcon(":/images/simplify.png"));
    actionUncut_->setStatusTip(tr("Simplify the selected objects, by merging curves and surfaces together"));
    actionUncut_->setShortcut(QKeySequence(Qt::Key_Backspace));
    actionUncut_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionUncut_);
    connect(actionUncut_, SIGNAL(triggered()), mainWindow()->scene(), SLOT(uncut()));

    // Desired icon size
    double sideLength = 40;

    // ---------------------   Shared actions/options   ------------------------

    // None

    // ---------------------   Select options   ------------------------

    toolModeToolBar_->addAction(actionChangeColor_);
    toolModeToolBar_->addAction(actionChangeEdgeWidth_);
    separatorSelect1_ = toolModeToolBar_->addSeparator();
    toolModeToolBar_->addAction(actionCreateFace_);
    toolModeToolBar_->addAction(actionAddCycles_);
    toolModeToolBar_->addAction(actionRemoveCycles_);
    separatorSelect2_ = toolModeToolBar_->addSeparator();

    toolModeToolBar_->widgetForAction(actionChangeColor_)->setFixedSize(sideLength,sideLength);
    toolModeToolBar_->widgetForAction(actionChangeEdgeWidth_)->setFixedSize(sideLength,sideLength);
    toolModeToolBar_->widgetForAction(actionCreateFace_)->setFixedSize(sideLength,sideLength);
    toolModeToolBar_->widgetForAction(actionAddCycles_)->setFixedSize(sideLength,sideLength);
    toolModeToolBar_->widgetForAction(actionRemoveCycles_)->setFixedSize(sideLength,sideLength);

    toolModeToolBar_->addAction(actionGlue_);
    toolModeToolBar_->addAction(actionUnglue_);
    toolModeToolBar_->addAction(actionUncut_);
    toolModeToolBar_->widgetForAction(actionGlue_)->setFixedSize(sideLength+20,sideLength);
    toolModeToolBar_->widgetForAction(actionUnglue_)->setFixedSize(sideLength+20,sideLength);
    toolModeToolBar_->widgetForAction(actionUncut_)->setFixedSize(sideLength+20,sideLength);


    // ---------------------   Sketch options   ------------------------

    // Tablet pressure
    actionUseTabletPressure_ = new QAction(this);
    actionUseTabletPressure_->setCheckable(true);
    actionUseTabletPressure_->setChecked(true);
    toolModeToolBar_->addAction(actionUseTabletPressure_);
    toolModeToolBar_->widgetForAction(actionUseTabletPressure_)->setFixedSize(sideLength,sideLength);
    actionUseTabletPressure_->setText(tr("Toggle stylus pressure"));
    actionUseTabletPressure_->setIcon(QIcon(":/images/pressure.png"));
    actionUseTabletPressure_->setStatusTip(tr("Enable or disable stylus pressure (only for users with a pen tablet)"));
    //actionUseTabletPressure_->setShortcut(QKeySequence(Qt::Key_Backspace));
    actionUseTabletPressure_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionUseTabletPressure_);
    connect(actionUseTabletPressure_, SIGNAL(triggered()), this, SLOT(toggleStylusPressure()));

    // Edge width
    edgeWidth_ = new SpinBox();
    edgeWidth_->setCaption(tr(" pen width "));
    edgeWidth_->setValue(settings().edgeWidth());
    actionEdgeWidth_ = toolModeToolBar_->addWidget(edgeWidth_);
    connect(edgeWidth_, SIGNAL(valueChanged(double)), this, SLOT(setEdgeWidth_(double)));

    // Separator
    separatorSketch1_ = toolModeToolBar_->addSeparator();

    // Planar map mode
    actionPlanarMapMode_ = new QAction(this);
    actionPlanarMapMode_->setCheckable(true);
    actionPlanarMapMode_->setChecked(true);
    toolModeToolBar_->addAction(actionPlanarMapMode_);
    toolModeToolBar_->widgetForAction(actionPlanarMapMode_)->setFixedSize(110,sideLength);
    actionPlanarMapMode_->setText(tr("Toggle intersections"));
    actionPlanarMapMode_->setIcon(QIcon(":/images/planar-map-on.png"));
    actionPlanarMapMode_->setStatusTip(tr("When intersections are enabled, the sketched curve automatically splits existing curves and surfaces."));
    //actionPlanarMapMode_->setShortcut(QKeySequence(Qt::Key_Backspace));
    actionPlanarMapMode_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionPlanarMapMode_);
    connect(actionPlanarMapMode_, SIGNAL(triggered()), this, SLOT(togglePlanarMapMode()));

    // Separator
    separatorSketch2_ = toolModeToolBar_->addSeparator();

    // Snapping
    actionSnapMode_ = new QAction(this);
    actionSnapMode_->setCheckable(true);
    actionSnapMode_->setChecked(true);
    toolModeToolBar_->addAction(actionSnapMode_);
    toolModeToolBar_->widgetForAction(actionSnapMode_)->setFixedSize(110,sideLength);
    actionSnapMode_->setText(tr("Toggle snapping"));
    actionSnapMode_->setIcon(QIcon(":/images/snapping-on.png"));
    actionSnapMode_->setStatusTip(tr("When snapping is enabled, the sketched curve is automatically glued to existing curves."));
    //actionSnapMode_->setShortcut(QKeySequence(Qt::Key_Backspace));
    actionSnapMode_->setShortcutContext(Qt::ApplicationShortcut);
    mainWindow()->addAction(actionSnapMode_);
    connect(actionSnapMode_, SIGNAL(triggered()), this, SLOT(toggleSnapping()));

    // Edge width
    actionSnapThreshold_ = toolModeToolBar_->addWidget(snapThreshold_);

    // ---------------------   Sculpt options   ------------------------

    actionSculptRadius_ = toolModeToolBar_->addWidget(sculptRadius_);

    // ---------------------   Cut options   ------------------------

    // Set default Tool Mode
    setToolMode(SKETCH);
}
Example #15
0
void BlockDef::createFaces(World * world, Position & camPosition, Vector3d pos, int visibleFaces, FloatArray & vertices, IntArray & indexes) {
	for (int i = 0; i < 6; i++)
		if (visibleFaces & (1 << i))
			createFace(world, camPosition, pos, (Dir)i, vertices, indexes);
}
Example #16
0
void QHull3d::createInitialTetrahedron()
{
	float d;
	float dmax;

	int epidx[6];
	int tetraidx[4];

	// Get extreme points (EP)
	for (int i = 0; i < 6; ++i)
		epidx[i] = -1;

	for (int i = 0; i < _pointcount; ++i)
	{
		const gk::Point& p = _points[i];

		if (epidx[0] < 0 || p.x < _points[epidx[0]].x)
			epidx[0] = i;
		if (epidx[1] < 0 || p.x > _points[epidx[1]].x)
			epidx[1] = i;

		if (epidx[2] < 0 || p.y < _points[epidx[2]].y)
			epidx[2] = i;
		if (epidx[3] < 0 || p.y > _points[epidx[3]].y)
			epidx[3] = i;

		if (epidx[4] < 0 || p.z < _points[epidx[4]].z)
			epidx[4] = i;
		if (epidx[5] < 0 || p.z > _points[epidx[5]].z)
			epidx[5] = i;
	}

	// Find the most distant EP pair to build base triangle's first edge
	dmax = 0.f;

	for (int i = 0; i < 5; ++i)
	{
		for (int j = i + 1; j < 6; ++j)
		{
			gk::Vector vij(_points[epidx[i]], _points[epidx[j]]);

			if ((d = vij.LengthSquared()) > dmax)
			{
				tetraidx[0] = epidx[i];
				tetraidx[1] = epidx[j];

				dmax = d;
			}
		}
	}

	// Find the most distant EP from the first edge's support line to complete the base triangle
	dmax = 0.f;
	tetraidx[2] = -1;

	const gk::Point& t0 = _points[tetraidx[0]];
	gk::Vector t01 = gk::Normalize(gk::Vector(t0, _points[tetraidx[1]]));

	for (int i = 0; i < 6; ++i)
	{
		if (epidx[i] == tetraidx[0] || epidx[i] == tetraidx[1])
			continue;

		gk::Vector t0i(t0, _points[epidx[i]]);
		float pprojlength = gk::Dot(t0i, t01);
		d = t0i.LengthSquared() - (pprojlength * pprojlength);

		if (d > dmax)
		{
			tetraidx[2] = epidx[i];

			dmax = d;
		}
	}

	// Special case where there are only 2 extreme points => Pick any remaining point
	if (tetraidx[2] < 0)
	{
		for (int i = 0; i < _pointcount; ++i)
		{
			if (i != tetraidx[0] && i != tetraidx[1])
			{
				tetraidx[2] = i;
				break;
			}
		}
	}

	// Find the most distant point from the base triangle within the point cloud to complete the initial tetrahedron
	dmax = 0.f;
	HEFace* tetrabase = createFace(tetraidx[0], tetraidx[1], tetraidx[2]);

	for (int i = 0; i < _pointcount; ++i)
	{
		if (i == tetraidx[0] || i == tetraidx[1] || i == tetraidx[2])
			continue;

		//if (fabs(d = tetrabase->distance(_points[i])) > fabs(dmax))
		if (fabs(d = tetrabase->distance(_points[i])) >= fabs(dmax))
		{
			tetraidx[3] = i;

			dmax = d;
		}
	}

	// Coplanarity detection
	if (dmax == 0)
	{
		initialize2d();

		return;
	}

	// Reverse the base triangle if not counter clockwise oriented according to the tetrahedron outer surface
	if (dmax > 0)
		tetrabase->reverse();

	// Complete the tetrahedron's mesh
	std::vector<HEFace*> tetrafaces = extrudeOut(tetrabase, tetraidx[3]);
	tetrafaces.insert(tetrafaces.begin(), tetrabase);

	// Assign remaining points to their corresponding face
	for (int i = 0; i < _pointcount; ++i)
	{
		if (i == tetraidx[0] || i == tetraidx[1] || i == tetraidx[2] || i == tetraidx[3])
			continue;

		for (int f = 0; f < (int)tetrafaces.size(); ++f)
		{
			if (tetrafaces[f]->tryAssignVertex(_vertices[i].get()))
				break;
		}
	}

	//! Add the tetrahedron's not empty faces to the processing stack
	for (int i = 0; i < (int)tetrafaces.size(); ++i)
		if (!tetrafaces[i]->vertices.empty())
			_processingfaces.push(tetrafaces[i]);

	// Store hull first vertex
	_hull = _vertices[tetraidx[0]].get();

	//////////////////////////////////////////////////////////////////////////
	// ToDo JRA: Remove this test code

	assertManifoldValidity(_hull);
}
Example #17
0
//-----------------------------------------------------------------------------------
inline void vertexFty::splitFace( MIntArray& faceVtx, MIntArray& matchVtx, int faceID)
//-----------------------------------------------------------------------------------
{//matchVtx ist immer gepruned, wenn er hier ankommt
	//faceID wird nur zum erstellen der neuen Faces benötigt

	//jetzt erstmal lookup arrays aufbauen, mit denen gearbeitet wird
	UINT i;
	UINT l = faceVtx.length();
	
	MPointArray points;

	ftyCreator->getVtxPositions(faceVtx,points);
	refValue = ftyCreator->getFaceSize(points);
	


	UCHAR* f = (UCHAR*)malloc(l);	//'f'lagLUT - kann mit bitOperationen getestet werden
	

	//jetzt die LUT Arrays beschreiben
	for(i = null; i < l; i++)
	{
		//flags setzen - isValid ist true, alles andere ist eingangs false
		f[i] = iv;

	}

	
	//selectedVtxArray schreiben - lokale indices finden
	for(i = null; i < matchVtx.length(); i++)
	{
		for(UINT x = null; x < l; x++)
		{
			if(matchVtx[i] == faceVtx[x])
			{
				f[x] += is;	//an dieser Stelle ist also ein Vtx gewählt
				break;
			}

		}
	}



	MIntArray	nf(l);							//speicher für neue Faces ('N'ew'F'ace) (temp) - groß genug, um das ganze Face nochmal zu halten (um reallocs zu vermeiden)
												//newFaces sind so konfiguriert, dass man mit createPoly und changePoly problemlos neue faces erstellen kann
	
	int			x,z;							//verwendet für iterationen,  dis  = distance ->wie weit entfernt von gegenwärtiger position soll gesucht werden?
	UINT		tsb, teb;						//tmpStartBound, tmpEndBound: Dient der festsetzung von arraybereichen, die da neue Face definieren
												//erst wenn das neue Face verifiziert wurde dürfen auch die memoryArrays entsprechend angepasst werden

	UINT tsb2, teb2;							//die erweiterte start/EndBoundary für die Kommenden Faces - sie werden definiert durch bis zu 4 corners
												//und beliebig vielen vertizen

	bool success = false;						//flag, ob die whileSchleife mindestens 1 face erstellt hat
	bool go = true;								//Für EndlosSchleife
					

	UCHAR		flagValue;						//tmpWert für Flags, damit man nicht immer auf array zugreifen muss

	list<MIntArray> newFaces;					//verkettete Liste von IntArrays, die alle neuen Faces aus "nf" speichert, um dann zum Schluss der prozedur alle Polys
												//zu erstellen (wobei der 1 Eintrag dafür sorgt, dass das originalface entsprechend geändert wird

	bool changeFace = false;					//flag, damit das Face nicht verändert wird, wenn kein gültiges Face gefunden wurde

	bool (vertexFty::*condition)(UCHAR) ;			//ptr zu bestimmtem Conditiontest
	condition = &vertexFty::isSelected;				//defaultCondition ist isSelected;
	
	
	
	//----------------------------------------------
	//jetzt die splits ermitteln
	//----------------------------------------------
	
	//es soll versucht werden, unabhängig vom startPunkt konsistente Ergebnisse zu erzielen.
	//dies bedeutet, dass man im forraus nicht genau weiß, wann die Sache beendet sein wird, eventuell
	//muss das Face mehrmals durchgearbeitet werden. Wenn "svtd" auf null ist, wurde jeder SelVtx bearbeitet

	//erstmal runup machen zum spinWert
	i = null;
	UINT l3 = null;	//couter für schleifendurchlauf
	for(UINT u = null; u < spin; u++)
	{
		for(i = (i+1) % l; i < l; i = (i+1)%l)
		{
			if(f[i] & is)
			{
				break;
			}
		}
	}

	for(UINT o = null; o < 2; o++)
	{//äußere Schleife
		l3 = null;
		//for(i = 0; i < l; i++)
		for(; l3++ != l; i = (i+1)%l)	//damit spin mit einbezogen wird
		{//jeden Vtx im Array bearbeiten, der selected ist

			if( f[i]&is^is || f[i]&iv^iv)	//ohne klammerung, da operatorvorrang eindeutig
				continue;	//wenn er nich gewählt ist oder nicht gültig, dann mit nächstem Vtx fortfahren

			//jetzt checken ob in ArrayRichtung mindestens 1 ungewählter Vtx vorhanden ist
			//und natürlich ob die richtung noch nicht geblockt ist
	

			for(x = 1; x > -2; x-=2)	//x fungiert als multiplikator
			{

				flagValue = f[(i+x+l)%l];


				if( !( (this->*condition)( flagValue ) ) && flagValue&iv )
				{//richtung ist gültig und der nächste Vertex ist  nicht Selected (bzw er ist selected, aber die bedingung wurde geändert
					//jetzt solange suchen, bis ein selektierter Vtx gefunden wurde, und dann weitersehen


					tsb = i;	//momentaner lowBound, muss eventuell später umgesetzt werden
					


					for(z = (i+x+x+l)%l; ; z = (z+x+l)%l)
					{// jetzt den nächstbesten selVtx finden


						//hier findet er auf jeden Fall nen passenden Vtx, weshalb man keinen LoopSchutz einbauen muss

						if(f[z] & is && f[z] & iv)
						{//schleife beenden und endBound setzen
							
							teb = z;
							break;
						}
						

					}

					//Nach möglichkeit sollten Quads oder nGons erstellt werden, weshalb für den Fall, dass es ein dreieck ist, noch in die andere Richtung
					//geschaut wird
					//->>nein, der User entscheidet durch seine Auswahl, was er haben will - mit spin kann er das dann noch verändern

					//jetzt das Aray fürs neue Face aufbauen
					//wenn die richtung umgekehrt, dann müssen auch die Bounds umgekehrt werden, damit er nicht das falsche Face erstell

					if( (x == 1) ? (! createFace(tsb,teb,f,faceVtx,nf) ) : (! createFace(teb,tsb,f,faceVtx,nf) ) )
					{//face ist ungültig, also mit nächster Richtung weitermachen
						continue;
					}

				
					changeFace = true;
					
					//ansonsten face zur liste hinzufügen
					newFaces.push_back(nf);

					

					
					tsb2 = tsb; teb2 = teb;		//-->jetzt dienen tsb2&teb2 aber als backup für original tsb/teb, falls die while schleife nix findet
					success = false;			//flag, ob die whileSchleife mindestens 1 fce erstellt hat
					go = true;					//EndlosSchleife

					//jetzt noch noch versuchen, weitere Faces anhand dieser methode zu erstellen
					while(go)
					{
						UINT t = tsb = teb;
						

						flagValue = f[(t+x+l)%l];

						//hier wird die Condition nicht benutzt
						if( flagValue & is || flagValue & iv^iv )
						//wenn vtx selected oder nicht gültig ist, abbruch
							break;

						//ansonsten die selben schritte ausführen wie zuvor schon
						for(z = (t+x+x+l)%l; ; z = (z+x+l)%l)
						{// jetzt den nächstbesten selVtx finden
							
							//in dem moment, wo der vtx ungültig ist, 
							//muss die Suche eh gestoppt werden
							if(f[z] & iv ^ iv)
								goto machWeiter;
							
							if(f[z] & is )
							{//schleife beenden und endBound setzen
								
								teb = z;
								break;
							}
							
						}

						//jetzt das Face erstellen
						if( (x == 1) ? (! createFace(tsb,teb,f,faceVtx,nf) ) : (! createFace(teb,tsb,f,faceVtx,nf) ) )
						{//face ist ungültig, also enfach mit nächster Iteration fortfahren
							continue;
						}
						else
						{//face ist gültig, es also auf liste packen
							changeFace = true;
							success = true;
							newFaces.push_back(nf);
						}

					}
					
					//wenn Sache nicht erfolgreich war, dann originalWerte zurückholen und weitermachen
					if(!success)
					{
						tsb = tsb2;
						teb = teb2;
					}
					
					//jetzt die erweiterte Suche starten, um den Rest der Faces zu erstellen 
					UINT bounds[4];



					while(go)
					{

						//jetzt von tsb ausgehen und nächstbesten selVtx finden (--> op beachten, +l zur sicherheit, da op auch negativ sein kann)
						for(z = (tsb+l-x)%l; ; z = (z+l-x)%l)
						{
							if( f[z] & iv ^ iv )
								//wenn ungültiger Vtx gefunden wurde, muss abgebrochen werden
								goto machWeiter;

							if( f[z] & is )
							{
								tsb2 = z;
								break;
							}

						}

						//und auch von teb aus in richtung der operation teb2 finden
						for(z = (teb+l+x)%l; ; z = (z+l+x)%l)
						{
							
							if( f[z] & iv ^ iv )
								//wenn ungültiger Vtx gefunden wurde, muss abgebrochen werden
								goto machWeiter;

							if( f[z] & is )
							{
								teb2 = z;
								break;
							}

						}
	

						//letztendlich Face erstellen, wenn alles korrekt
						if(x == -1)
						{//wenn op negativ, dann können bounds bleiben wie gehabt
							bounds[null] = tsb;			bounds[1] = tsb2;
							bounds[2] = teb;			bounds[3] = teb2;

						//	op = 1;	//richtung ist ab jetzt nicht mehr vertauscht
						}
						else
						{//wenn op positiv, müssen bounds umgekehrt werden
							bounds[2] = tsb;			bounds[3] = tsb2;
							bounds[null] = teb;			bounds[1] = teb2;
						}


						if( tsb == teb2 || teb == tsb2 || !createExtraFace( &bounds[null],f,faceVtx,nf)  )
						{// Okay, hier kann man nicht mehr weitermachen
							//also einfach die Bounds umsetzen und so mit nächstem face weitermachen

							
							tsb = tsb2;
							teb = teb2;


							continue;
						}

						//ansonsten ist alles in ordnung, und man kann die Marker umsetzen und das Face erstellen
						newFaces.push_back(nf);
						changeFace = true;

						tsb = tsb2;
						teb = teb2;

					}
					
					//da er einen gültigen Einstiegspunkt gefunden hat, muss er auf jeden Fall aussteigen aus allen Schleifen
					goto machWeiter;
					

				}


			}//for(x = 1; x > -2; x-=2)

			
		}//for(i = 0; i < l; i++


		//wenn er hier hinkommt, dann hat die obige Schleife keinen einstiegspunkt finden können
		condition = &vertexFty::gimmeFalse;
		//da die condition jetzt auf ginmmeFalse umgesetzt wurde, wird beim nächsten durchlauf auf jeden Fall ein passender Vtx gefunden
		


	}//for(UINT o = 0; o < 2; o++)
	

machWeiter:;
	//----------------------------------------------------------------------------------------
	//zuguterletzt die faces erstellen mit dem creator - er kümmert sich um UVs und Normalen
	//----------------------------------------------------------------------------------------

	if(!changeFace)
	{//wenn face nicht verändert wurde, dann speicher freigeben und raus hier
		free((void*)f);
		
		return;
	}

	//ansonsten zuerst noch die verbliebenen ValidVertex zu Face hinzufügen
	nf.clear();


	for(i = null; i < l; i++)
	{
		if(f[i] & iv)
			nf.append(faceVtx[i]);

	}

	if(nf.length() > 2)	//wenn nur 2 vertizen in diesem Face gewählt sind, bleiben auch nur 2 vertizen übrig - daraus sollte man kein Face macen :)
		newFaces.push_back(nf);
	
	//das erste Face sorgt für die Änderung des OriginalFaces
	MIntArray	 DummyArray;												//wird der changeUVIDs methode als leeres Array übergeben, weil es verlangt wird



	std::list<MIntArray>::iterator iter = newFaces.begin();


	
	
	ftyCreator->changePolyVtxIDs(faceID, *iter);


	ftyCreator->changeUVIds(faceID,DummyArray,*iter,faceVtx);


	ftyCreator->changeNormals(faceID,*iter);


	//aufs nächste Face schalten
	++iter;

	l = newFaces.size();
	for(i = 1; i < l; i++)
	{//jetzt die anderen faces erstellen

	 INVIS(helper.printArray(*iter," = FaceToCreate");)
	 
		ftyCreator->createPoly(*iter);


			ftyCreator->changeUVIds(faceID,DummyArray,*iter, faceVtx,true);


			ftyCreator->changeNormals(faceID,*iter,true);

		iter++;
	}